Skip to content

Commit a51f848

Browse files
committed
refactor(test-projects): apply suggestions and use fixtures
1 parent 9be0875 commit a51f848

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

tests/unit/objects/test_projects.py

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"name": "name",
5353
},
5454
}
55-
delete_project_content = {"message": "202 Accepted"}
5655
upload_file_content = {
5756
"alt": "filename",
5857
"url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/filename.png",
@@ -99,7 +98,7 @@ def resp_get_project():
9998

10099

101100
@pytest.fixture
102-
def resp_post_project():
101+
def resp_create_project():
103102
with responses.RequestsMock() as rsps:
104103
rsps.add(
105104
method=responses.POST,
@@ -112,7 +111,7 @@ def resp_post_project():
112111

113112

114113
@pytest.fixture
115-
def resp_post_project_user():
114+
def resp_create_user_project():
116115
with responses.RequestsMock() as rsps:
117116
rsps.add(
118117
method=responses.POST,
@@ -125,7 +124,7 @@ def resp_post_project_user():
125124

126125

127126
@pytest.fixture
128-
def resp_post_fork_project():
127+
def resp_fork_project():
129128
with responses.RequestsMock() as rsps:
130129
rsps.add(
131130
method=responses.POST,
@@ -138,7 +137,7 @@ def resp_post_fork_project():
138137

139138

140139
@pytest.fixture
141-
def resp_put_project():
140+
def resp_update_project():
142141
with responses.RequestsMock() as rsps:
143142
rsps.add(
144143
method=responses.PUT,
@@ -164,7 +163,7 @@ def resp_get_project_storage():
164163

165164

166165
@pytest.fixture
167-
def resp_user_projects():
166+
def resp_list_user_projects():
168167
with responses.RequestsMock() as rsps:
169168
rsps.add(
170169
method=responses.GET,
@@ -203,7 +202,7 @@ def resp_unstar_project():
203202

204203

205204
@pytest.fixture
206-
def resp_project_starrers():
205+
def resp_list_project_starrers():
207206
with responses.RequestsMock() as rsps:
208207
rsps.add(
209208
method=responses.GET,
@@ -216,7 +215,7 @@ def resp_project_starrers():
216215

217216

218217
@pytest.fixture
219-
def resp_starred_projects():
218+
def resp_list_starred_projects():
220219
with responses.RequestsMock() as rsps:
221220
rsps.add(
222221
method=responses.GET,
@@ -323,12 +322,12 @@ def resp_unarchive_project():
323322

324323

325324
@pytest.fixture
326-
def resp_delete_project():
325+
def resp_delete_project(accepted_content):
327326
with responses.RequestsMock() as rsps:
328327
rsps.add(
329328
method=responses.DELETE,
330329
url="http://localhost/api/v4/projects/1",
331-
json=delete_project_content,
330+
json=accepted_content,
332331
content_type="application/json",
333332
status=202,
334333
)
@@ -362,12 +361,12 @@ def resp_share_project():
362361

363362

364363
@pytest.fixture
365-
def resp_unshare_project():
364+
def resp_unshare_project(no_content):
366365
with responses.RequestsMock() as rsps:
367366
rsps.add(
368367
method=responses.DELETE,
369368
url="http://localhost/api/v4/projects/1/share/1",
370-
json=None,
369+
json=no_content,
371370
content_type="application/json",
372371
status=204,
373372
)
@@ -388,12 +387,12 @@ def resp_create_fork_relation():
388387

389388

390389
@pytest.fixture
391-
def resp_delete_fork_relation():
390+
def resp_delete_fork_relation(no_content):
392391
with responses.RequestsMock() as rsps:
393392
rsps.add(
394393
method=responses.DELETE,
395394
url="http://localhost/api/v4/projects/2/fork",
396-
json=None,
395+
json=no_content,
397396
content_type="application/json",
398397
status=204,
399398
)
@@ -440,7 +439,7 @@ def resp_start_housekeeping():
440439

441440

442441
@pytest.fixture
443-
def resp_get_push_rules_project():
442+
def resp_list_push_rules_project():
444443
with responses.RequestsMock() as rsps:
445444
rsps.add(
446445
method=responses.GET,
@@ -453,7 +452,7 @@ def resp_get_push_rules_project():
453452

454453

455454
@pytest.fixture
456-
def resp_post_push_rules_project():
455+
def resp_create_push_rules_project():
457456
with responses.RequestsMock() as rsps:
458457
rsps.add(
459458
method=responses.POST,
@@ -486,7 +485,7 @@ def resp_update_push_rules_project():
486485

487486

488487
@pytest.fixture
489-
def resp_delete_push_rules_project():
488+
def resp_delete_push_rules_project(no_content):
490489
with responses.RequestsMock() as rsps:
491490
rsps.add(
492491
method=responses.GET,
@@ -498,7 +497,7 @@ def resp_delete_push_rules_project():
498497
rsps.add(
499498
method=responses.DELETE,
500499
url="http://localhost/api/v4/projects/1/push_rule",
501-
json=None,
500+
json=no_content,
502501
content_type="application/json",
503502
status=204,
504503
)
@@ -555,14 +554,14 @@ def test_list_projects(gl, resp_list_projects):
555554
assert projects[0].name == "name"
556555

557556

558-
def test_list_user_projects(user, resp_user_projects):
557+
def test_list_user_projects(user, resp_list_user_projects):
559558
user_project = user.projects.list()[0]
560559
assert isinstance(user_project, UserProject)
561560
assert user_project.name == "name"
562561
assert user_project.id == 1
563562

564563

565-
def test_list_user_starred_projects(user, resp_starred_projects):
564+
def test_list_user_starred_projects(user, resp_list_starred_projects):
566565
starred_projects = user.starred_projects.list()[0]
567566
assert isinstance(starred_projects, StarredProject)
568567
assert starred_projects.name == "name"
@@ -577,13 +576,13 @@ def test_list_project_users(project, resp_list_users):
577576
assert user.state == "active"
578577

579578

580-
def test_create_project(gl, resp_post_project):
579+
def test_create_project(gl, resp_create_project):
581580
project = gl.projects.create({"name": "name"})
582581
assert project.id == 1
583582
assert project.name == "name"
584583

585584

586-
def test_create_user_project(user, resp_post_project_user):
585+
def test_create_user_project(user, resp_create_user_project):
587586
user_project = user.projects.create({"name": "name"})
588587
assert user_project.id == 1
589588
assert user_project.name == "name"
@@ -593,12 +592,12 @@ def test_create_user_project(user, resp_post_project_user):
593592
assert user_project.owner.get("username") == "owner_username"
594593

595594

596-
def test_update_project(project, resp_put_project):
595+
def test_update_project(project, resp_update_project):
597596
project.snippets_enabled = 1
598597
project.save()
599598

600599

601-
def test_fork_project(project, resp_post_fork_project):
600+
def test_fork_project(project, resp_fork_project):
602601
fork = project.forks.create({})
603602
assert fork.id == 2
604603
assert fork.name == "name"
@@ -624,7 +623,7 @@ def test_unstar_project(project, resp_unstar_project):
624623

625624

626625
@pytest.mark.skip(reason="missing test")
627-
def test_list_project_starrers(project, resp_project_starrers):
626+
def test_list_project_starrers(project, resp_list_project_starrers):
628627
pass
629628

630629

@@ -712,13 +711,13 @@ def test_project_housekeeping(project, resp_start_housekeeping):
712711
project.housekeeping()
713712

714713

715-
def test_get_project_push_rules(project, resp_get_push_rules_project):
714+
def test_list_project_push_rules(project, resp_list_push_rules_project):
716715
pr = project.pushrules.get()
717716
assert pr
718717
assert pr.deny_delete_tag
719718

720719

721-
def test_create_project_push_rule(project, resp_post_push_rules_project):
720+
def test_create_project_push_rule(project, resp_create_push_rules_project):
722721
project.pushrules.create({"deny_delete_tag": True})
723722

724723

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy