Skip to content

Commit

Permalink
No error handling for invalid status input. Fixed syntax for test par…
Browse files Browse the repository at this point in the history
…ametrization
  • Loading branch information
jaymedina committed Mar 1, 2024
1 parent 0858373 commit 457cc5f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 69 deletions.
33 changes: 0 additions & 33 deletions src/orca/services/synapse/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,6 @@ def trigger_indexing(self, synapse_view: str) -> None:
"""
self.client.tableQuery(f"select * from {synapse_view} limit 1")

def is_valid_submission_status(self, submission_status: str) -> bool:
"""
Check if submission status is valid. Based on:
https://rest-docs.synapse.org/rest/org/sagebionetworks/evaluation/model/SubmissionStatusEnum.html
Arguments:
submission_status: The submission status to check.
Returns:
Boolean indicating if submission status is valid.
"""

# List all the available status options based on API docs
status_options = [
"OPEN",
"CLOSED",
"SCORED",
"INVALID",
"VALIDATED",
"EVALUATION_IN_PROGRESS",
"RECEIVED",
"REJECTED",
]
# Ensure that input status is valid (case-sensitive)
if submission_status.upper() not in status_options:
return False

return True

def get_submissions_with_status(
self, submission_view: str, submission_status: str = "RECEIVED"
Expand All @@ -118,11 +90,6 @@ def get_submissions_with_status(
A list of submission IDs.
"""
# Check if submission status is valid
if not self.is_valid_submission_status(submission_status):
message = f"Invalid submission status '{submission_status}'"
raise ValueError(message)

# Trigger indexing
self.trigger_indexing(submission_view)

Expand Down
37 changes: 1 addition & 36 deletions tests/services/synapse/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,6 @@ def test_trigger_indexing(mocker: pytest.fixture, mocked_ops: MagicMock) -> None
)


def test_is_valid_submission_status():
"""
Tests that the ``is_valid_submission_status`` method in ``SynapseOps``
returns a boolean indicating if the submission status is valid.
"""
submission_status = "receiveD"
assert SynapseOps().is_valid_submission_status(submission_status)


def test_is_valid_submission_status_incorrect_status():
"""
Tests that the ``is_valid_submission_status`` method in ``SynapseOps``
returns a boolean indicating if the submission status is valid.
"""
submission_status = "receved"
assert not SynapseOps().is_valid_submission_status(submission_status)


def test_get_submissions_with_status(
mocker: pytest.fixture, mocked_ops: MagicMock
) -> None:
Expand Down Expand Up @@ -160,21 +140,6 @@ def test_get_submissions_with_status(
assert result == input_dict["id"]


def test_get_submissions_with_status_incorrect_status():
"""
Tests that the ``get_submissions_with_status`` method in ``SynapseOps``
returns a list of submission IDs.
"""
submission_view = "syn111"
submission_status = "oops"
error_message = f"Invalid submission status '{submission_status}'"

# No need to mock anything here as it will fail before call to tableQuery
with pytest.raises(ValueError, match=error_message):
SynapseOps().get_submissions_with_status(submission_view, submission_status)


def test_update_submission_status(
mocker: pytest.fixture, mocked_ops: MagicMock
) -> None:
Expand Down Expand Up @@ -211,7 +176,7 @@ def test_update_submission_status(
)


@pytest.mark.parametrize("submission_id", [(111.0, [111], (111))])
@pytest.mark.parametrize("submission_id", (111.0, [111]))
def test_update_submission_status_with_wrong_data_type(submission_id) -> None:
"""
Tests that the ``update_submission_status`` method in ``SynapseOps``
Expand Down

0 comments on commit 457cc5f

Please sign in to comment.