Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 10, 2024
1 parent 1857e6f commit 5039e01
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tests/cores/common/test_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from comps import OpeaComponent, OpeaComponentController


class TestOpeaComponent(unittest.TestCase):
class MockOpeaComponent(OpeaComponent):
def check_health(self) -> bool:
Expand All @@ -16,27 +17,28 @@ def invoke(self, *args, **kwargs):

def test_initialization(self):
component = self.MockOpeaComponent("TestComponent", "embedding", "Test description")

self.assertEqual(component.name, "TestComponent")
self.assertEqual(component.type, "embedding")
self.assertEqual(component.description, "Test description")
self.assertEqual(component.config, {})

def test_get_meta(self):
component = self.MockOpeaComponent("TestComponent", "embedding", "Test description", {"key": "value"})
meta = component.get_meta()

self.assertEqual(meta["name"], "TestComponent")
self.assertEqual(meta["type"], "embedding")
self.assertEqual(meta["description"], "Test description")
self.assertEqual(meta["config"], {"key": "value"})

def test_update_config(self):
component = self.MockOpeaComponent("TestComponent", "embedding", "Test description")
component.update_config("key", "new_value")

self.assertEqual(component.config["key"], "new_value")


class TestOpeaComponentController(unittest.TestCase):
def test_register_component(self):
controller = OpeaComponentController()
Expand Down Expand Up @@ -100,9 +102,7 @@ def test_invoke_with_active_component(self):
component.invoke.assert_called_with("arg1", key="value")

def test_discover_then_invoke(self):
"""
Ensures that `discover_and_activate` and `invoke` work correctly when called sequentially.
"""
"""Ensures that `discover_and_activate` and `invoke` work correctly when called sequentially."""
controller = OpeaComponentController()

# Mock a healthy component
Expand Down Expand Up @@ -144,6 +144,5 @@ def test_list_components(self):
self.assertIn("Component2", components_list)


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()

0 comments on commit 5039e01

Please sign in to comment.