-
Notifications
You must be signed in to change notification settings - Fork 75
[SYNPY-1861] remove submissionInstructionsMessage and submissionReceiptMessage from required attributes #1401
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
base: develop
Are you sure you want to change the base?
Changes from all commits
385c8cb
5800f93
ccb2709
4531daf
a781a94
d1b36ef
149e61f
16f9caf
e3c0b3c
89dd012
b6ccf3b
7cc9628
e05dd84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,18 +17,12 @@ def init(self, syn: Synapse, schedule_for_cleanup: Callable[..., None]) -> None: | |
| self.syn = syn | ||
| self.schedule_for_cleanup = schedule_for_cleanup | ||
|
|
||
| async def test_create_evaluation(self): | ||
| # GIVEN a project to work with | ||
| project = await Project(name=f"test_project_{uuid.uuid4()}").store_async( | ||
| synapse_client=self.syn | ||
| ) | ||
| self.schedule_for_cleanup(project.id) | ||
|
|
||
| async def test_create_evaluation(self, project_model: Project): | ||
| # WHEN I create an evaluation using the dataclass method | ||
| evaluation = Evaluation( | ||
| name=f"test_evaluation_{uuid.uuid4()}", | ||
| description="A test evaluation for testing purposes", | ||
| content_source=project.id, | ||
| content_source=project_model.id, | ||
| submission_instructions_message="Please submit your results in CSV format", | ||
| submission_receipt_message="Thank you for your submission!", | ||
| ) | ||
|
|
@@ -42,10 +36,45 @@ async def test_create_evaluation(self): | |
| assert ( | ||
| created_evaluation.description == "A test evaluation for testing purposes" | ||
| ) | ||
| assert created_evaluation.content_source == project.id | ||
| assert created_evaluation.content_source == project_model.id | ||
| assert created_evaluation.owner_id is not None # Check that owner_id is set | ||
|
jaymedina marked this conversation as resolved.
jaymedina marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: This comment has been generated with AI assistance and reviewed by me ✍️ Updated the |
||
| assert created_evaluation.created_on is not None # Check that created_on is set | ||
|
|
||
| async def test_create_evaluation_without_optional_message_fields( | ||
| self, project_model: Project | ||
| ): | ||
| # WHEN I create an evaluation without submission_instructions_message or submission_receipt_message | ||
| evaluation = Evaluation( | ||
| name=f"test_evaluation_{uuid.uuid4()}", | ||
| description="A test evaluation without optional message fields", | ||
| content_source=project_model.id, | ||
| ) | ||
| created_evaluation = await evaluation.store_async(synapse_client=self.syn) | ||
| self.schedule_for_cleanup(created_evaluation.id) | ||
|
|
||
| # THEN the evaluation should be created successfully | ||
| assert created_evaluation.id is not None | ||
| assert created_evaluation.etag is not None | ||
| assert created_evaluation.name == evaluation.name | ||
| assert created_evaluation.content_source == project_model.id | ||
| assert created_evaluation.submission_instructions_message is None | ||
| assert created_evaluation.submission_receipt_message is None | ||
|
|
||
| # WHEN I update a field without setting message fields | ||
| new_description = f"Updated description {uuid.uuid4()}" | ||
| old_etag = created_evaluation.etag | ||
| created_evaluation.description = new_description | ||
| updated_evaluation = await created_evaluation.store_async( | ||
| synapse_client=self.syn | ||
| ) | ||
|
|
||
| # THEN the update should also succeed without message fields | ||
| assert updated_evaluation.description == new_description | ||
| assert updated_evaluation.id == created_evaluation.id | ||
| assert updated_evaluation.etag != old_etag | ||
| assert updated_evaluation.submission_instructions_message is None | ||
| assert updated_evaluation.submission_receipt_message is None | ||
|
|
||
|
|
||
| class TestGetEvaluation: | ||
| @pytest.fixture(autouse=True, scope="function") | ||
|
|
@@ -519,54 +548,3 @@ async def test_update_acl_async_with_full_dictionary( | |
| user_access is not None | ||
| ), f"User {current_user_id} not found in updated ACL" | ||
| assert set(user_access["accessType"]) == set(["READ", "DELETE", "SUBMIT"]) | ||
|
|
||
|
|
||
| class TestEvaluationValidation: | ||
| @pytest.fixture(autouse=True, scope="function") | ||
| def init(self, syn: Synapse, schedule_for_cleanup: Callable[..., None]) -> None: | ||
| self.syn = syn | ||
| self.schedule_for_cleanup = schedule_for_cleanup | ||
|
|
||
| async def test_create_evaluation_missing_required_fields(self): | ||
| # WHEN I try to create an evaluation with missing required fields | ||
| evaluation = Evaluation(name="test_evaluation") | ||
|
|
||
| # THEN it should raise a ValueError | ||
| with pytest.raises(ValueError, match="missing the 'description' attribute"): | ||
| await evaluation.store_async(synapse_client=self.syn) | ||
|
|
||
| async def test_get_evaluation_missing_id_and_name(self): | ||
| # WHEN I try to get an evaluation without id or name | ||
| evaluation = Evaluation() | ||
|
|
||
| # THEN it should raise a ValueError | ||
| with pytest.raises( | ||
| ValueError, match="Either id or name must be set to get an evaluation" | ||
| ): | ||
| await evaluation.get_async(synapse_client=self.syn) | ||
|
|
||
| async def test_delete_evaluation_missing_id(self): | ||
| # WHEN I try to delete an evaluation without an id | ||
| evaluation = Evaluation(name="test_evaluation") | ||
|
|
||
| # THEN it should raise a ValueError | ||
| with pytest.raises(ValueError, match="id must be set to delete an evaluation"): | ||
| await evaluation.delete_async(synapse_client=self.syn) | ||
|
|
||
| async def test_get_acl_missing_id(self): | ||
| # WHEN I try to get ACL for an evaluation without an id | ||
| evaluation = Evaluation(name="test_evaluation") | ||
|
|
||
| # THEN it should raise a ValueError | ||
| with pytest.raises(ValueError, match="id must be set to get evaluation ACL"): | ||
| await evaluation.get_acl_async(synapse_client=self.syn) | ||
|
|
||
| async def test_get_permissions_missing_id(self): | ||
| # WHEN I try to get permissions for an evaluation without an id | ||
| evaluation = Evaluation(name="test_evaluation") | ||
|
|
||
| # THEN it should raise a ValueError | ||
| with pytest.raises( | ||
| ValueError, match="id must be set to get evaluation permissions" | ||
| ): | ||
| await evaluation.get_permissions_async(synapse_client=self.syn) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,6 +98,40 @@ async def test_store_submission_successfully_async( | |
| assert created_submission.created_on is not None | ||
| assert created_submission.version_number is not None | ||
|
|
||
| async def test_store_submission_to_evaluation_without_message_fields_async( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: the submission tests shouldn't care whether
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: This comment has been generated with AI assistance and reviewed by me ✍️ The intent of |
||
| self, | ||
| test_project: Project, | ||
| test_file: File, | ||
| ): | ||
| # GIVEN an evaluation created without submission_instructions_message or submission_receipt_message | ||
| evaluation = Evaluation( | ||
| name=f"test_evaluation_{uuid.uuid4()}", | ||
| description="Evaluation without optional message fields", | ||
| content_source=test_project.id, | ||
| ) | ||
| created_evaluation = await evaluation.store_async(synapse_client=self.syn) | ||
| self.schedule_for_cleanup(created_evaluation.id) | ||
|
|
||
| # WHEN I submit to that evaluation | ||
| submission = Submission( | ||
| entity_id=test_file.id, | ||
| evaluation_id=created_evaluation.id, | ||
| name=f"Test Submission {uuid.uuid4()}", | ||
| ) | ||
| created_submission = await submission.store_async(synapse_client=self.syn) | ||
| self.schedule_for_cleanup(created_submission.id) | ||
|
|
||
| # THEN the submission should be created successfully | ||
| assert created_submission.id is not None | ||
| assert created_submission.entity_id == test_file.id | ||
| assert created_submission.evaluation_id == created_evaluation.id | ||
|
|
||
| # AND retrieving the submission should also work | ||
| retrieved = await Submission(id=created_submission.id).get_async( | ||
| synapse_client=self.syn | ||
| ) | ||
| assert retrieved.id == created_submission.id | ||
|
|
||
| async def test_store_submission_without_entity_id_async( | ||
| self, test_evaluation: Evaluation | ||
| ): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.