1
1
# SPDX-License-Identifier: Apache-2.0
2
2
# Copyright 2022 Atlan Pte. Ltd.
3
+ import math
3
4
from datetime import datetime , timedelta
4
5
from typing import Generator
5
6
@@ -48,6 +49,17 @@ def group(client: AtlanClient) -> Generator[CreateGroupResponse, None, None]:
48
49
delete_group (client , g .group )
49
50
50
51
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
+
51
63
def test_create_group (client : AtlanClient , group : CreateGroupResponse ):
52
64
assert group
53
65
r = client .group .get_by_name (GROUP_NAME )
@@ -81,6 +93,16 @@ def test_retrieve_all_groups(client: AtlanClient, group: CreateGroupResponse):
81
93
_default_group_count += 1
82
94
83
95
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
+
84
106
def test_group_get_pagination (client : AtlanClient , group : CreateGroupResponse ):
85
107
response = client .group .get (limit = 1 , count = True )
86
108
@@ -100,6 +122,16 @@ def test_group_get_pagination(client: AtlanClient, group: CreateGroupResponse):
100
122
assert len (current_page ) == 0
101
123
102
124
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
+
103
135
def test_group_get_members_pagination (client : AtlanClient , group : CreateGroupResponse ):
104
136
groups = client .group .get_by_name (alias = GROUP_NAME )
105
137
assert groups
@@ -166,6 +198,46 @@ def test_user_groups_pagination(client: AtlanClient, group: CreateGroupResponse)
166
198
assert len (current_page ) == 0
167
199
168
200
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
+
169
241
@pytest .mark .order (after = "test_retrieve_all_groups" )
170
242
def test_retrieve_existing_user (client : AtlanClient , group : CreateGroupResponse ):
171
243
global _default_group_count
0 commit comments