Skip to content

Commit

Permalink
DIG-1272: Clinical ingest integration tests (#329)
Browse files Browse the repository at this point in the history
* Update candigv2-ingest

* sometimes you clean up a thing and it doesn't exist. That's OK.

* add basic clinical ingest test

* Update candigv2-ingest

* (temporary until merged)

* Update candigv2-ingest

* Revert "(temporary until merged)"
  • Loading branch information
daisieh authored Nov 13, 2023
1 parent c603ff5 commit 19de81d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
42 changes: 41 additions & 1 deletion etc/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def clean_up_program(test_id):
headers=get_headers(is_admin=True),
)
assert (
delete_response.status_code == HTTPStatus.NO_CONTENT
delete_response.status_code == HTTPStatus.NO_CONTENT or delete_response.status_code == HTTPStatus.NOT_FOUND
), f"CLEAN_UP_PROGRAM Expected status code {HTTPStatus.NO_CONTENT}, but got {delete_response.status_code}."
f" Response content: {delete_response.content}"

Expand Down Expand Up @@ -797,6 +797,46 @@ def test_katsu_users_data_access():

# =========================|| KATSU TEST END ||=============================== #

def test_ingest_permissions():
clean_up_program("SYNTHETIC-2")
clean_up_program("TEST_2")

test_loc = "https://raw.githubusercontent.com/CanDIG/candigv2-ingest/develop/tests/single_ingest.json"
test_data = requests.get(test_loc).json()

token = get_token(
username=ENV["CANDIG_NOT_ADMIN_USER"],
password=ENV["CANDIG_NOT_ADMIN_PASSWORD"],
)
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json; charset=utf-8",
}

response = requests.post(f"{ENV['CANDIG_URL']}/ingest/ingest/clinical_donors", headers=headers, json=test_data)
# when the user has no admin access, they should not be allowed
assert response.status_code == 403

token = get_token(
username=ENV["CANDIG_SITE_ADMIN_USER"],
password=ENV["CANDIG_SITE_ADMIN_PASSWORD"],
)
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json; charset=utf-8",
}
response = requests.post(f"{ENV['CANDIG_URL']}/ingest/ingest/clinical_donors", headers=headers, json=test_data)
# when the user has admin access, they should be allowed
print(response.json())
assert response.status_code == 201
assert len(response.json()["SYNTHETIC-2"]["errors"]) == 0
assert len(response.json()["TEST_2"]["errors"]) == 0
assert len(response.json()["SYNTHETIC-2"]["results"]) == 12
assert len(response.json()["TEST_2"]["results"]) == 5

clean_up_program("SYNTHETIC-2")
clean_up_program("TEST_2")


## HTSGet + katsu:
def test_add_sample_to_genomic():
Expand Down

0 comments on commit 19de81d

Please sign in to comment.