Skip to content

Commit

Permalink
Split pagination tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad0n20 committed Nov 8, 2024
1 parent d53360c commit 6364cfa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions addon_imps/tests/storage/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async def test_list_child_items_not_found(self):
with self.assertRaises(ItemNotFound):
await self.imp.list_child_items(item_id="1:missing_folder")

async def test_list_root_items_pagination(self):
async def test_list_root_items_first_page(self):
mock_response_page_1 = [
{"id": "1", "name": "repo1", "path_with_namespace": "repo1"},
{"id": "2", "name": "repo2", "path_with_namespace": "repo2"},
Expand All @@ -160,9 +160,10 @@ async def test_list_root_items_pagination(self):
ItemResult(item_id="repo1:", item_name="repo1", item_type=ItemType.FOLDER),
ItemResult(item_id="repo2:", item_name="repo2", item_type=ItemType.FOLDER),
]

self.assertEqual(result_page_1.items, expected_items_page_1)
self.assertEqual(result_page_1.next_sample_cursor, "page=2")

async def test_list_root_items_second_page(self):
mock_response_page_2 = [
{"id": "3", "name": "repo3", "path_with_namespace": "repo3"},
]
Expand All @@ -171,11 +172,10 @@ async def test_list_root_items_pagination(self):
expected_items_page_2 = [
ItemResult(item_id="repo3:", item_name="repo3", item_type=ItemType.FOLDER),
]

self.assertEqual(result_page_2.items, expected_items_page_2)
self.assertIsNone(result_page_2.next_sample_cursor)

async def test_list_child_items_pagination(self):
async def test_list_child_items_first_page(self):
folder_mock_page_1 = [
{"name": "src", "path": "src", "type": "tree"},
{"name": "README.md", "path": "README.md", "type": "blob"},
Expand All @@ -193,9 +193,10 @@ async def test_list_child_items_pagination(self):
item_id="1:README.md", item_name="README.md", item_type=ItemType.FILE
),
]

self.assertEqual(result_page_1.items, expected_items_page_1)
self.assertEqual(result_page_1.next_sample_cursor, "page=2")

async def test_list_child_items_second_page(self):
folder_mock_page_2 = [
{"name": "LICENSE", "path": "LICENSE", "type": "blob"},
]
Expand All @@ -206,6 +207,5 @@ async def test_list_child_items_pagination(self):
item_id="1:LICENSE", item_name="LICENSE", item_type=ItemType.FILE
),
]

self.assertEqual(result_page_2.items, expected_items_page_2)
self.assertIsNone(result_page_2.next_sample_cursor)

0 comments on commit 6364cfa

Please sign in to comment.