Skip to content

Commit 12f8640

Browse files
committed
Add test focused on API response for admin user
1 parent f530bce commit 12f8640

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

tests/test_submission.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ def test_list_submissions(db: Session, client: TestClient, logged_in_user):
2727
assert response.json()["results"][0]["id"] == str(submission.id)
2828

2929

30-
def test_get_metadata_submissions_report(db: Session, client: TestClient, logged_in_user):
30+
def test_get_metadata_submissions_report_as_non_admin(db: Session, client: TestClient, logged_in_user):
31+
response = client.request(method="GET", url="/api/metadata_submission/report")
32+
assert response.status_code == 403
33+
34+
35+
def test_get_metadata_submissions_report_as_admin(db: Session, client: TestClient, logged_in_admin_user):
36+
logged_in_user = logged_in_admin_user # makes a concise alias (also allows for verbatim code snippet reuse)
3137
submission = fakes.MetadataSubmissionFactory(
3238
author=logged_in_user, author_orcid=logged_in_user.orcid
3339
)
@@ -39,19 +45,11 @@ def test_get_metadata_submissions_report(db: Session, client: TestClient, logged
3945
)
4046

4147
# TODO: Create additional submissions.
42-
4348
db.commit()
4449

4550
# TODO: Check additional aspects of the HTTP response.
46-
47-
# The server will return an HTTP 403 Response when the client isn't an admin.
48-
#
49-
# TODO: Find an example of where a test request is submitted as an admin, or even
50-
# as any logged-in user (I assume the endpoint would have returned a 401
51-
# if the user wasn't logged in at all).
52-
#
5351
response = client.request(method="GET", url="/api/metadata_submission/report")
54-
assert response.status_code == 403
52+
assert response.status_code == 200
5553

5654

5755
def test_try_edit_locked_submission(db: Session, client: TestClient, logged_in_user):

0 commit comments

Comments
 (0)