@@ -220,14 +220,13 @@ def test_create_from_gh_data(self):
220
220
221
221
@pytest .mark .asyncio
222
222
async def test_aget_from_event (self , ainstallation , create_event ):
223
- installation = await ainstallation
224
223
event = create_event (
225
- {"installation" : {"id" : installation .installation_id }}, "installation"
224
+ {"installation" : {"id" : ainstallation .installation_id }}, "installation"
226
225
)
227
226
228
227
result = await Installation .objects .aget_from_event (event )
229
228
230
- assert result == installation
229
+ assert result == ainstallation
231
230
232
231
@pytest .mark .asyncio
233
232
async def test_aget_from_event_doesnotexist (self , installation_id , create_event ):
@@ -287,15 +286,13 @@ async def test_arefresh_from_gh(
287
286
get_mock_github_api ,
288
287
override_app_settings ,
289
288
):
290
- installation = await ainstallation
291
-
292
289
mock_github_api = get_mock_github_api ({"foo" : "bar" })
293
- installation .get_gh_client = MagicMock (return_value = mock_github_api )
290
+ ainstallation .get_gh_client = MagicMock (return_value = mock_github_api )
294
291
295
292
with override_app_settings (PRIVATE_KEY = private_key ):
296
- await installation .arefresh_from_gh (account_type , "test" )
293
+ await ainstallation .arefresh_from_gh (account_type , "test" )
297
294
298
- assert installation .data == {"foo" : "bar" }
295
+ assert ainstallation .data == {"foo" : "bar" }
299
296
300
297
@pytest .mark .parametrize ("account_type" , ["org" , "user" ])
301
298
def test_refresh_from_gh (
@@ -320,9 +317,7 @@ def test_refresh_from_gh_invalid_account_type(self, installation):
320
317
321
318
@pytest .mark .asyncio
322
319
async def test_aget_repos (self , ainstallation ):
323
- installation = await ainstallation
324
-
325
- repos = await installation .aget_repos ()
320
+ repos = await ainstallation .aget_repos ()
326
321
327
322
assert len (repos ) == 2
328
323
assert repos [0 ]["node_id" ] == "node1"
@@ -353,20 +348,21 @@ def test_app_slug(self):
353
348
class TestRepositoryManager :
354
349
@pytest .mark .asyncio
355
350
async def test_acreate_from_gh_data_list (self , ainstallation ):
356
- installation = await ainstallation
357
351
data = [
358
352
{"id" : seq .next (), "node_id" : "node1" , "full_name" : "owner/repo1" },
359
353
{"id" : seq .next (), "node_id" : "node2" , "full_name" : "owner/repo2" },
360
354
]
361
355
362
- repositories = await Repository .objects .acreate_from_gh_data (data , installation )
356
+ repositories = await Repository .objects .acreate_from_gh_data (
357
+ data , ainstallation
358
+ )
363
359
364
360
assert len (repositories ) == len (data )
365
361
for i , repo in enumerate (repositories ):
366
362
assert repo .repository_id == data [i ]["id" ]
367
363
assert repo .repository_node_id == data [i ]["node_id" ]
368
364
assert repo .full_name == data [i ]["full_name" ]
369
- assert repo .installation_id == installation .id
365
+ assert repo .installation_id == ainstallation .id
370
366
371
367
def test_create_from_gh_data_list (self , installation ):
372
368
data = [
@@ -385,15 +381,14 @@ def test_create_from_gh_data_list(self, installation):
385
381
386
382
@pytest .mark .asyncio
387
383
async def test_acreate_from_gh_data_single (self , ainstallation ):
388
- installation = await ainstallation
389
384
data = {"id" : seq .next (), "node_id" : "node1" , "full_name" : "owner/repo1" }
390
385
391
- repository = await Repository .objects .acreate_from_gh_data (data , installation )
386
+ repository = await Repository .objects .acreate_from_gh_data (data , ainstallation )
392
387
393
388
assert repository .repository_id == data ["id" ]
394
389
assert repository .repository_node_id == data ["node_id" ]
395
390
assert repository .full_name == data ["full_name" ]
396
- assert repository .installation_id == installation .id
391
+ assert repository .installation_id == ainstallation .id
397
392
398
393
def test_create_from_gh_data_single (self , installation ):
399
394
data = {"id" : seq .next (), "node_id" : "node1" , "full_name" : "owner/repo1" }
@@ -407,13 +402,11 @@ def test_create_from_gh_data_single(self, installation):
407
402
408
403
@pytest .mark .asyncio
409
404
async def test_aget_from_event (self , arepository , create_event ):
410
- repository = await arepository
411
-
412
405
data = {
413
406
"repository" : {
414
- "id" : repository .repository_id ,
415
- "node_id" : repository .repository_node_id ,
416
- "full_name" : repository .full_name ,
407
+ "id" : arepository .repository_id ,
408
+ "node_id" : arepository .repository_node_id ,
409
+ "full_name" : arepository .full_name ,
417
410
}
418
411
}
419
412
@@ -424,7 +417,7 @@ async def test_aget_from_event(self, arepository, create_event):
424
417
assert repo .repository_id == data ["repository" ]["id" ]
425
418
assert repo .repository_node_id == data ["repository" ]["node_id" ]
426
419
assert repo .full_name == data ["repository" ]["full_name" ]
427
- assert repo .installation_id == repository .installation .id
420
+ assert repo .installation_id == arepository .installation .id
428
421
429
422
@pytest .mark .asyncio
430
423
async def test_aget_from_event_doesnotexist (self , repository_id , create_event ):
@@ -466,9 +459,7 @@ def test_get_gh_client(self, repository):
466
459
467
460
@pytest .mark .asyncio
468
461
async def test_aget_issues (self , arepository ):
469
- repository = await arepository
470
-
471
- issues = await repository .aget_issues ()
462
+ issues = await arepository .aget_issues ()
472
463
473
464
assert len (issues ) == 2
474
465
assert issues [0 ]["number" ] == 1
0 commit comments