11# SPDX-License-Identifier: Apache-2.0
22# Copyright 2022 Atlan Pte. Ltd.
3+ import math
34from datetime import datetime , timedelta
45from typing import Generator
56
@@ -48,6 +49,17 @@ def group(client: AtlanClient) -> Generator[CreateGroupResponse, None, None]:
4849 delete_group (client , g .group )
4950
5051
52+ def _assert_search_results (results , size , TOTAL_ASSETS ):
53+ assert results .total_record > size
54+ assert len (results .records ) == size
55+ counter = 0
56+ for result in results :
57+ assert result
58+ counter += 1
59+ assert counter == TOTAL_ASSETS
60+ assert results
61+
62+
5163def test_create_group (client : AtlanClient , group : CreateGroupResponse ):
5264 assert group
5365 r = client .group .get_by_name (GROUP_NAME )
@@ -81,6 +93,16 @@ def test_retrieve_all_groups(client: AtlanClient, group: CreateGroupResponse):
8193 _default_group_count += 1
8294
8395
96+ def test_group_get_all_pagination (client : AtlanClient ):
97+ results = client .group .get_all (limit = 0 )
98+ assert results is not None
99+ assert results .filter_record is not None
100+ TOTAL_ASSETS = results .filter_record
101+ limit = max (1 , math .ceil (TOTAL_ASSETS / 5 ))
102+ groups = client .group .get_all (limit = limit )
103+ _assert_search_results (groups , limit , TOTAL_ASSETS )
104+
105+
84106def test_group_get_pagination (client : AtlanClient , group : CreateGroupResponse ):
85107 response = client .group .get (limit = 1 , count = True )
86108
@@ -100,6 +122,16 @@ def test_group_get_pagination(client: AtlanClient, group: CreateGroupResponse):
100122 assert len (current_page ) == 0
101123
102124
125+ def test_group_get_by_name_pagination (client : AtlanClient ):
126+ results = client .group .get_by_name (alias = GROUP_NAME , limit = 0 )
127+ assert results is not None
128+ assert results .filter_record is not None
129+ TOTAL_ASSETS = results .filter_record
130+ limit = max (1 , math .ceil (TOTAL_ASSETS / 5 ))
131+ groups = client .group .get_by_name (alias = GROUP_NAME , limit = limit )
132+ _assert_search_results (groups , limit , TOTAL_ASSETS )
133+
134+
103135def test_group_get_members_pagination (client : AtlanClient , group : CreateGroupResponse ):
104136 groups = client .group .get_by_name (alias = GROUP_NAME )
105137 assert groups
@@ -166,6 +198,46 @@ def test_user_groups_pagination(client: AtlanClient, group: CreateGroupResponse)
166198 assert len (current_page ) == 0
167199
168200
201+ def test_user_get_all_pagination (client : AtlanClient ):
202+ results = client .user .get_all (limit = 0 )
203+ assert results is not None
204+ assert results .filter_record is not None
205+ TOTAL_ASSETS = results .filter_record
206+ limit = max (1 , math .ceil (TOTAL_ASSETS / 5 ))
207+ users = client .user .get_all (limit = limit )
208+ _assert_search_results (users , limit , TOTAL_ASSETS )
209+
210+
211+ def test_user_get_by_usernames_pagination (client : AtlanClient ):
212+ results = client .user .get_by_usernames (usernames = [FIXED_USER ], limit = 0 )
213+ assert results is not None
214+ assert results .filter_record is not None
215+ TOTAL_ASSETS = results .filter_record
216+ limit = max (1 , math .ceil (TOTAL_ASSETS / 5 ))
217+ users = client .user .get_by_usernames (usernames = [FIXED_USER ], limit = limit )
218+ _assert_search_results (users , limit , TOTAL_ASSETS )
219+
220+
221+ def test_user_get_by_email_and_emails_pagination (client : AtlanClient ):
222+ results = client .user .get_by_email (email = EMAIL_DOMAIN , limit = 0 )
223+ assert results is not None
224+ assert results .filter_record is not None
225+ TOTAL_ASSETS = results .filter_record
226+ assert results .records is not None
227+ email = results .records [0 ].email
228+ limit = max (1 , math .ceil (TOTAL_ASSETS / 5 ))
229+ emails = client .user .get_by_email (email = EMAIL_DOMAIN , limit = limit )
230+ _assert_search_results (emails , limit , TOTAL_ASSETS )
231+ assert email is not None
232+ results = client .user .get_by_emails (emails = [email ], limit = 0 )
233+ assert results is not None
234+ assert results .filter_record is not None
235+ TOTAL_ASSETS = results .filter_record
236+ limit = max (1 , math .ceil (TOTAL_ASSETS / 5 ))
237+ emails = client .user .get_by_emails (emails = [email ], limit = limit )
238+ _assert_search_results (emails , limit , TOTAL_ASSETS )
239+
240+
169241@pytest .mark .order (after = "test_retrieve_all_groups" )
170242def test_retrieve_existing_user (client : AtlanClient , group : CreateGroupResponse ):
171243 global _default_group_count
0 commit comments