Skip to content

Commit e9fe527

Browse files
committed
tests: improved toolRepo tests
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 2254703 commit e9fe527

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

tests/test_model_tool_repository.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,13 @@ def test_tool_with_component_and_service_load_xml(self) -> None:
6868
tuple(bom.metadata.tools.tools),
6969
tuple(expected.metadata.tools.tools), 'tools')
7070

71-
def test_assign_component(self) -> None:
72-
t = ToolsRepository()
73-
t.components = SortedSet([Component(name='test-component')])
74-
s = t.components.pop()
75-
self.assertEqual('test-component', s.name)
76-
77-
def test_assign_service(self) -> None:
78-
t = ToolsRepository()
79-
t.services = SortedSet([Service(name='test-service')])
80-
s = t.services.pop()
81-
self.assertEqual('test-service', s.name)
82-
8371
def test_invalid_tool_repo_properties(self) -> None:
8472
with self.assertRaises(MutuallyExclusivePropertiesException):
8573
ToolsRepository(
8674
components=[Component(name='test-component')],
87-
services=[Service(name='test-service')], tools=[Tool()])
75+
services=[Service(name='test-service')],
76+
tools=[Tool(name='test-tool')]
77+
)
8878

8979
def test_assign_component_with_existing_tool(self) -> None:
9080
tr = ToolsRepository(tools=[Tool()])
@@ -96,25 +86,42 @@ def test_assign_service_with_existing_tool(self) -> None:
9686
with self.assertRaises(MutuallyExclusivePropertiesException):
9787
tr.services = SortedSet([Service(name='test-service')])
9888

99-
def test_equal_other_objectd(self) -> None:
89+
def test_unequal_different_type(self) -> None:
10090
tr = ToolsRepository()
10191
self.assertFalse(tr == 'other')
10292

103-
def test_equal_object(self) -> None:
93+
def test_equal_self(self) -> None:
10494
tr = ToolsRepository()
95+
tr.tools.add(Tool(name='my-tool'))
10596
self.assertTrue(tr == tr)
10697

98+
def test_unequal(self) -> None:
99+
tr1 = ToolsRepository()
100+
tr1.components.add(Component(name='my-component'))
101+
tr1.services.add(Service(name='my-service'))
102+
tr1.tools.add(Tool(name='my-tool'))
103+
tr2 = ToolsRepository()
104+
self.assertFalse(tr1 == tr2)
105+
106+
def test_equal(self) -> None:
107+
c = Component(name='my-component')
108+
s = Service(name='my-service')
109+
t = Tool(name='my-tool')
110+
tr1 = ToolsRepository()
111+
tr1.components.add(c)
112+
tr1.services.add(s)
113+
tr1.tools.add(t)
114+
tr2 = ToolsRepository()
115+
tr2.components.add(c)
116+
tr2.services.add(s)
117+
tr2.tools.add(t)
118+
self.assertTrue(tr1 == tr2)
119+
107120
def test_assign_tool_with_existing_component(self) -> None:
108121
tr = ToolsRepository(components=SortedSet([Component(name='test-component')]))
109122
with self.assertRaises(MutuallyExclusivePropertiesException):
110123
tr.tools = SortedSet([Tool()])
111124

112-
def test_assign_tool(self) -> None:
113-
tr = ToolsRepository()
114-
tr.tools = SortedSet([Tool(name='test-tool')])
115-
t = tr.tools.pop()
116-
self.assertEqual('test-tool', t.name)
117-
118125
def test_proper_service_provider_conversion(self) -> None:
119126
o = OrganizationalEntity(name='test-org')
120127
s = Service(name='test-service', provider=o)

0 commit comments

Comments
 (0)