Skip to content

Commit

Permalink
Add test cohorts to user2, if candig_url is available
Browse files Browse the repository at this point in the history
  • Loading branch information
daisieh committed Mar 1, 2024
1 parent 1d41c78 commit 868baa5
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tests/test_htsget_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ def get_headers(username=USERNAME, password=PASSWORD):
return headers


def test_remove_objects():
cohorts = ["test-htsget", "1000genomes"]
def test_remove_objects(cohorts):
headers = get_headers()
candig_url = os.getenv("CANDIG_URL")

for cohort in cohorts:
if candig_url is not None:
response = requests.delete(f"{candig_url}/ingest/program/{cohort}/email/{USERNAME}@test.ca", headers=get_headers())

url = f"{HOST}/ga4gh/drs/v1/cohorts/{cohort}"
response = requests.request("GET", url, headers=headers)
if response.status_code == 200:
Expand All @@ -53,13 +57,20 @@ def test_remove_objects():
assert obj["cohort"] != cohort


def test_post_objects(drs_objects):
def test_post_objects(drs_objects, cohorts):
"""
Install test objects. Will fail if any post request returns an error.
"""
# clean up old objects in db:
url = f"{HOST}/ga4gh/drs/v1/objects"
headers = get_headers()
candig_url = os.getenv("CANDIG_URL")

for cohort in cohorts:
if candig_url is not None:
response = requests.post(f"{candig_url}/ingest/program/{cohort}/email/{USERNAME}@test.ca", headers=get_headers())
print(response.text)

response = requests.request("GET", url, headers=headers)

for obj in drs_objects:
Expand Down Expand Up @@ -512,6 +523,11 @@ def test_vcf_json():
assert len(res.json()['variants']) == 7


@pytest.fixture
def cohorts():
return ["test-htsget", "1000genomes"]


@pytest.fixture
def drs_objects():
drs_objects = {}
Expand Down

0 comments on commit 868baa5

Please sign in to comment.