Skip to content

Commit d07cc43

Browse files
committed
feat: updated test for updating and added test for pagination
1 parent c65735a commit d07cc43

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

sdk/python/tests/test_component.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def setUp(self):
2424
self.server.start()
2525
self.instance_id = list(finding_table.keys())[0]
2626
self.component = Component(
27-
instance_id=self.instance_id, # Use the first key from the test data
27+
instance_id=self.instance_id,
2828
db_type=DBTypeEnum.REMOTE,
2929
logger=log
3030
)
@@ -68,10 +68,34 @@ def test_grpc_update_findings(self):
6868

6969
# Verify that the new finding is now in the database
7070
updated_findings = temp_component.get_findings()
71+
self.assertIsInstance(updated_findings, list, "The updated findings should be returned as a list")
7172

72-
self.assertListEqual(list(finding_table.values())[2], updated_findings, "The new finding should be present in the updated findings")
73+
self.assertListEqual(list(finding_table.values())[0][:-1], updated_findings, "The new finding should be present in the updated findings")
7374
del temp_component # Clean up the temporary component instance
7475

76+
def test_grpc_get_findings_with_pagination(self):
77+
"""
78+
Test the get_findings method of the Component instance with pagination.
79+
"""
80+
81+
temp_component = Component(
82+
instance_id=list(finding_table.keys())[1],
83+
db_type=DBTypeEnum.REMOTE,
84+
logger=log
85+
)
86+
# Manually set the page size for the remote client to make sure we can test pagination.
87+
temp_component.db_manager.page_size = 1
88+
# Get findings with pagination
89+
page_num = 0
90+
findings_page_1 = temp_component.get_findings(page_num=page_num)
91+
92+
self.assertIsInstance(findings_page_1, list, "The findings should be returned as a list")
93+
94+
# Verify that the findings retrieved are from the first page
95+
self.assertEqual(len(findings_page_1), 1, "The number of findings on the first page should 1, as we have set the page size to 1 manually")
96+
97+
del temp_component
98+
7599
def test_grpc_create_findings(self):
76100
"""
77101
Test the create_findings method of the Component instance.

0 commit comments

Comments
 (0)