Skip to content

Commit 412fda1

Browse files
committed
fix format
1 parent 61456c9 commit 412fda1

File tree

1 file changed

+37
-28
lines changed

1 file changed

+37
-28
lines changed

tests/test_api.py

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -163,37 +163,39 @@ def test_bulk_operations_workflow(self):
163163
# Step 1: Create 10 users using bulk creation
164164
users_data = []
165165
for i in range(10):
166-
users_data.append({
167-
"profile": {
168-
"email": f"bulktest{random.randint(1000, 999999)}@example.com",
169-
"name": f"Bulk Test User {i+1}",
170-
"phone": str(random.randint(1000000, 9999999)),
166+
users_data.append(
167+
{
168+
"profile": {
169+
"email": f"bulktest{random.randint(1000, 999999)}@example.com",
170+
"name": f"Bulk Test User {i+1}",
171+
"phone": str(random.randint(1000000, 9999999)),
172+
}
171173
}
172-
})
173-
174+
)
175+
174176
# Create users in bulk
175177
bulk_options = {"finaltime": "1y", "slidingtime": "30d"}
176178
create_result = self.api.create_users_bulk(users_data, bulk_options)
177-
179+
178180
# Verify bulk creation was successful
179181
self.assertIsInstance(create_result, dict)
180182
self.assertEqual(create_result.get("status"), "ok")
181183
self.assertIn("created", create_result)
182184
self.assertEqual(len(create_result["created"]), 10)
183-
185+
184186
# Store created user tokens for verification
185187
created_tokens = [user["token"] for user in create_result["created"]]
186-
188+
187189
# Step 2: Initiate bulk list unlock operation
188190
unlock_result = self.api.bulk_list_unlock()
189-
191+
190192
# Verify unlock operation was successful
191193
self.assertIsInstance(unlock_result, dict)
192194
self.assertEqual(unlock_result.get("status"), "ok")
193195
self.assertIn("unlockuuid", unlock_result)
194-
196+
195197
unlock_uuid = unlock_result["unlockuuid"]
196-
198+
197199
# Step 3: Fetch all users using bulk list operation
198200
# First, get the total count by fetching with a large limit
199201
bulk_users_result = self.api.bulk_list_users(unlock_uuid, offset=0, limit=100)
@@ -202,11 +204,11 @@ def test_bulk_operations_workflow(self):
202204
self.assertIsInstance(bulk_users_result, dict)
203205
self.assertEqual(bulk_users_result.get("status"), "ok")
204206
self.assertIn("rows", bulk_users_result)
205-
207+
206208
# Verify we can find our created users in the bulk results
207209
bulk_users = bulk_users_result["rows"]
208210
found_created_users = 0
209-
211+
210212
for bulk_user in bulk_users:
211213
if "token" in bulk_user and bulk_user["token"] in created_tokens:
212214
found_created_users += 1
@@ -215,34 +217,41 @@ def test_bulk_operations_workflow(self):
215217
self.assertIn("email", user_profile)
216218
self.assertIn("name", user_profile)
217219
self.assertIn("phone", user_profile)
218-
220+
219221
# Verify we found all our created users
220-
self.assertEqual(found_created_users, 10,
221-
f"Expected to find 10 created users in bulk results, but found {found_created_users}")
222-
222+
self.assertEqual(
223+
found_created_users,
224+
10,
225+
f"Expected to find 10 created users in bulk results, but found {found_created_users}",
226+
)
227+
223228
# Step 4: Test pagination by fetching users in smaller batches
224229
paginated_users = []
225230
offset = 0
226231
limit = 5
227-
232+
228233
while True:
229-
page_result = self.api.bulk_list_users(unlock_uuid, offset=offset, limit=limit)
234+
page_result = self.api.bulk_list_users(
235+
unlock_uuid, offset=offset, limit=limit
236+
)
230237
self.assertEqual(page_result.get("status"), "ok")
231-
238+
232239
page_users = page_result.get("rows", [])
233240
if not page_users:
234241
break
235-
242+
236243
paginated_users.extend(page_users)
237244
offset += limit
238-
245+
239246
# Safety break to prevent infinite loops
240247
if offset > 100:
241248
break
242-
249+
243250
# Verify pagination worked and we got users
244-
self.assertGreater(len(paginated_users), 0, "Pagination should return some users")
245-
251+
self.assertGreater(
252+
len(paginated_users), 0, "Pagination should return some users"
253+
)
254+
246255
# Clean up: Delete the created users
247256
for token in created_tokens:
248257
try:
@@ -252,7 +261,7 @@ def test_bulk_operations_workflow(self):
252261
print(f"Warning: Failed to delete user with token {token}")
253262
except Exception as e:
254263
print(f"Warning: Exception during cleanup for token {token}: {str(e)}")
255-
264+
256265
return created_tokens
257266

258267

0 commit comments

Comments
 (0)