Skip to content

Commit 7c864d0

Browse files
committed
Remedy Test License ID Clashing
1 parent ac1b7ee commit 7c864d0

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

tests/helpers/constants.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
VALID_GENE = "BRCA1"
1515

1616
SAVED_PUBMED_PUBLICATION = {
17+
"recordType": "PublicationIdentifier",
1718
"identifier": "20711194",
1819
"dbName": "PubMed",
1920
"title": "None",
@@ -28,6 +29,7 @@
2829
}
2930

3031
SAVED_DOI_IDENTIFIER = {
32+
"recordType": "DoiIdentifier",
3133
"identifier": TEST_CROSSREF_IDENTIFIER,
3234
"url": f"https://doi.org/{TEST_CROSSREF_IDENTIFIER}",
3335
"id": 1,
@@ -51,6 +53,7 @@
5153
}
5254

5355
SAVED_CONTRIBUTOR = {
56+
"recordType": "Contributor",
5457
"orcidId": TEST_USER["username"],
5558
"givenName": TEST_USER["first_name"],
5659
"familyName": TEST_USER["last_name"],
@@ -80,6 +83,7 @@
8083
}
8184

8285
SAVED_EXTRA_CONTRIBUTOR = {
86+
"recordType": "Contributor",
8387
"orcidId": EXTRA_USER["username"],
8488
"givenName": EXTRA_USER["first_name"],
8589
"familyName": EXTRA_USER["last_name"],
@@ -350,22 +354,14 @@
350354
"active": True,
351355
}
352356

353-
TEST_INACTIVE_LICENSE = {
354-
"id": 2,
355-
"short_name": "Long",
356-
"long_name": "Short",
357-
"text": "Be evil.",
358-
"link": "localhost",
359-
"version": "1.0",
360-
"active": False,
361-
}
362-
363357
SAVED_SHORT_TEST_LICENSE = {
358+
"recordType": "ShortLicense",
364359
"id": TEST_LICENSE["id"],
365360
"shortName": TEST_LICENSE["short_name"],
366361
"longName": TEST_LICENSE["long_name"],
367362
"link": TEST_LICENSE["link"],
368363
"version": TEST_LICENSE["version"],
364+
"active": TEST_LICENSE["active"],
369365
}
370366

371367
EXTRA_LICENSE = {
@@ -375,14 +371,37 @@
375371
"text": "Don't be tooooo evil.",
376372
"link": "localhost",
377373
"version": "1.0",
374+
"active": True,
378375
}
379376

380377
SAVED_SHORT_EXTRA_LICENSE = {
378+
"recordType": "ShortLicense",
381379
"id": EXTRA_LICENSE["id"],
382380
"shortName": EXTRA_LICENSE["short_name"],
383381
"longName": EXTRA_LICENSE["long_name"],
384382
"link": EXTRA_LICENSE["link"],
385383
"version": EXTRA_LICENSE["version"],
384+
"active": EXTRA_LICENSE["active"],
385+
}
386+
387+
TEST_INACTIVE_LICENSE = {
388+
"id": 3,
389+
"short_name": "Long",
390+
"long_name": "Short",
391+
"text": "Be evil.",
392+
"link": "localhost",
393+
"version": "1.0",
394+
"active": False,
395+
}
396+
397+
SAVED_SHORT_INACTIVE_LICENSE = {
398+
"recordType": "ShortLicense",
399+
"id": TEST_INACTIVE_LICENSE["id"],
400+
"shortName": TEST_INACTIVE_LICENSE["short_name"],
401+
"longName": TEST_INACTIVE_LICENSE["long_name"],
402+
"link": TEST_INACTIVE_LICENSE["link"],
403+
"version": TEST_INACTIVE_LICENSE["version"],
404+
"active": TEST_INACTIVE_LICENSE["active"],
386405
}
387406

388407
TEST_SEQ_SCORESET = {

tests/routers/test_licenses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_can_list_licenses_as_any_user_class(setup_router_db, client, user_overr
1515

1616
assert response.status_code == 200
1717
response_value = response.json()
18-
assert len(response_value) == 2
18+
assert len(response_value) == 3
1919

2020

2121
@pytest.mark.parametrize("user_overrides", [None, "anonymous_app_overrides", "admin_app_overrides"])
@@ -29,7 +29,7 @@ def test_can_list_active_licenses_as_any_user_class(setup_router_db, client, use
2929

3030
assert response.status_code == 200
3131
response_value = response.json()
32-
assert len(response_value) == 1
32+
assert len(response_value) == 2
3333
license_state = [_license["active"] for _license in response_value]
3434
assert all(license_state)
3535

tests/routers/test_score_set.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
TEST_SAVED_SCORESET_RANGE,
3030
TEST_MINIMAL_ACC_SCORESET_RESPONSE,
3131
TEST_USER,
32+
TEST_INACTIVE_LICENSE,
3233
SAVED_DOI_IDENTIFIER,
3334
SAVED_EXTRA_CONTRIBUTOR,
3435
SAVED_PUBMED_PUBLICATION,
@@ -1532,7 +1533,7 @@ def test_cannot_create_score_set_with_inactive_license(session, client, setup_ro
15321533
experiment = create_experiment(client)
15331534
score_set_post_payload = deepcopy(TEST_MINIMAL_SEQ_SCORESET)
15341535
score_set_post_payload["experimentUrn"] = experiment["urn"]
1535-
score_set_post_payload["licenseId"] = 2
1536+
score_set_post_payload["licenseId"] = TEST_INACTIVE_LICENSE["id"]
15361537
response = client.post("/api/v1/score-sets/", json=score_set_post_payload)
15371538
assert response.status_code == 400
15381539

@@ -1541,7 +1542,7 @@ def test_cannot_modify_score_set_to_inactive_license(session, client, setup_rout
15411542
experiment = create_experiment(client)
15421543
score_set = create_seq_score_set(client, experiment["urn"])
15431544
score_set_post_payload = score_set.copy()
1544-
score_set_post_payload.update({"licenseId": 2, "urn": score_set["urn"]})
1545+
score_set_post_payload.update({"licenseId": TEST_INACTIVE_LICENSE["id"], "urn": score_set["urn"]})
15451546
response = client.put(f"/api/v1/score-sets/{score_set['urn']}", json=score_set_post_payload)
15461547
assert response.status_code == 400
15471548

0 commit comments

Comments
 (0)