Skip to content
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

Merged
merged 7 commits into from
Sep 20, 2024
Merged

Add some basic tests. #279

merged 7 commits into from
Sep 20, 2024

Conversation

EstelleDa
Copy link
Member

Mainly in experiment and score set view models.

@EstelleDa EstelleDa requested a review from bencap August 30, 2024 01:39
@bencap bencap added the type: tests Tests for this project label Sep 3, 2024
@EstelleDa EstelleDa self-assigned this Sep 5, 2024
Base automatically changed from release-2024.3.1 to release-2024.4.0 September 13, 2024 21:51
@bencap bencap changed the base branch from release-2024.4.0 to release-2024.4.1 September 14, 2024 16:18
Copy link
Collaborator

@bencap bencap left a 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.

Comment on lines 122 to 151
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"


Copy link
Collaborator

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:

@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)

Copy link
Member Author

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.

@EstelleDa EstelleDa merged commit ca0226a into release-2024.4.1 Sep 20, 2024
4 checks passed
@EstelleDa EstelleDa deleted the estelle/addTests branch September 20, 2024 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: tests Tests for this project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants