Skip to content

Commit

Permalink
Assert that the TSV file contains submission data
Browse files Browse the repository at this point in the history
  • Loading branch information
eecavanna committed Aug 20, 2024
1 parent 8ce7a34 commit 4893236
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions tests/test_submission.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from datetime import datetime, timedelta
from csv import DictReader

import pytest
from sqlalchemy.orm.session import Session
Expand Down Expand Up @@ -47,14 +48,33 @@ def test_get_metadata_submissions_report_as_admin(
user_orcid=logged_in_user.orcid,
role=SubmissionEditorRole.owner,
)

# TODO: Create additional submissions.
db.commit()

# TODO: Check additional aspects of the HTTP response.
response = client.request(method="GET", url="/api/metadata_submission/report")
assert response.status_code == 200

# Confirm the response payload is a TSV file having the fields and values we expect.
# Reference: https://docs.python.org/3/library/csv.html#csv.DictReader
header_row = [
"Submission ID",
"Author ORCID",
"Author Name",
"Study Name",
"PI Name",
"PI Email",
]
reader = DictReader(response.text.splitlines(), fieldnames=header_row, delimiter="\t")
data_rows = [data_row for data_row in reader]
assert len(data_rows) == 1 # does not count the header row
row = data_rows[0]
assert len(list(row.keys())) == len(header_row)
assert row["Submission ID"] == str(submission.id)
assert row["Author ORCID"] == logged_in_user.orcid
assert row["Author Name"] == logged_in_user.name
assert row["Study Name"] == ""
assert row["PI Name"] == ""
assert row["PI Email"] == ""


def test_try_edit_locked_submission(db: Session, client: TestClient, logged_in_user):
# Locked by a random user at utcnow by default
Expand Down

0 comments on commit 4893236

Please sign in to comment.