-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some basic tests. #279
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for these Estelle! I think we already have tests for what you added in the experiment router file (linked in separate comment), but once you go ahead and remove that duplication this looks good to merge in.
tests/routers/test_experiments.py
Outdated
def test_can_update_own_private_experiment_short_description(session, client, setup_router_db): | ||
experiment = create_experiment(client) | ||
experiment_post_payload = deepcopy(TEST_MINIMAL_EXPERIMENT) | ||
experiment_post_payload.update({"experimentSetUrn": experiment["experimentSetUrn"], "shortDescription": "New description"}) | ||
response = client.post("/api/v1/experiments/", json=experiment_post_payload) | ||
assert response.status_code == 200 | ||
assert response.json()["experimentSetUrn"] == experiment["experimentSetUrn"] | ||
assert response.json()["shortDescription"] == "New description" | ||
|
||
|
||
def test_can_update_own_private_experiment_abstract(session, client, setup_router_db): | ||
experiment = create_experiment(client) | ||
experiment_post_payload = deepcopy(TEST_MINIMAL_EXPERIMENT) | ||
experiment_post_payload.update({"experimentSetUrn": experiment["experimentSetUrn"], "abstractText": "New abstract"}) | ||
response = client.post("/api/v1/experiments/", json=experiment_post_payload) | ||
assert response.status_code == 200 | ||
assert response.json()["experimentSetUrn"] == experiment["experimentSetUrn"] | ||
assert response.json()["abstractText"] == "New abstract" | ||
|
||
|
||
def test_can_update_own_private_experiment_method(session, client, setup_router_db): | ||
experiment = create_experiment(client) | ||
experiment_post_payload = deepcopy(TEST_MINIMAL_EXPERIMENT) | ||
experiment_post_payload.update({"experimentSetUrn": experiment["experimentSetUrn"], "methodText": "New method"}) | ||
response = client.post("/api/v1/experiments/", json=experiment_post_payload) | ||
assert response.status_code == 200 | ||
assert response.json()["experimentSetUrn"] == experiment["experimentSetUrn"] | ||
assert response.json()["methodText"] == "New method" | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we have tests already for these operations:
mavedb-api/tests/routers/test_experiments.py
Lines 566 to 583 in d87b726
@pytest.mark.parametrize( | |
"test_field,test_value", | |
[ | |
("title", "Edited Title"), | |
("shortDescription", "Edited Short Description"), | |
("abstractText", "Edited Abstract"), | |
("methodText", "Edited Methods"), | |
], | |
) | |
def test_can_edit_private_experiment(client, setup_router_db, test_field, test_value): | |
experiment = create_experiment(client) | |
experiment_post_payload = experiment.copy() | |
experiment_post_payload.update({test_field: test_value, "urn": experiment["urn"]}) | |
response = client.put(f"/api/v1/experiments/{experiment['urn']}", json=experiment_post_payload) | |
assert response.status_code == 200 | |
response_data = response.json() | |
jsonschema.validate(instance=response_data, schema=Experiment.schema()) | |
assert (test_field, response_data[test_field]) == (test_field, test_value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Ben! I didn't notice this test. I'll delete the duplicate tests.
Mainly in experiment and score set view models.