Skip to content

Commit

Permalink
test: add unitspec/mouse validation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklatimer committed Jun 25, 2024
1 parent 3de1710 commit 0a20676
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import unittest
from pathlib import Path
from unittest.mock import MagicMock, patch
from copy import deepcopy

from slims.internal import Record

Expand Down Expand Up @@ -69,6 +70,22 @@ def test_fetch_mouse_content_many_mouse(
"Warning, Multiple mice in SLIMS with barcode 123456, using pk=3038"
)

@patch("logging.Logger.error")
@patch("slims.slims.Slims.fetch")
def test_fetch_mouse_content_validation_fail(
self, mock_fetch: MagicMock, mock_log_error: MagicMock
):
"""Test fetch_mouse when successful"""
wrong_return = deepcopy(self.example_fetch_mouse_response)
wrong_return[0].cntn_cf_waterRestricted.value = 14
mock_fetch.return_value = wrong_return
mouse_info = fetch_mouse_content(self.example_client, mouse_name="123456")
self.assertEqual(
self.example_fetch_mouse_response[0].json_entity,
mouse_info,
)
mock_log_error.assert_called()


if __name__ == "__main__":
unittest.main()
4 changes: 4 additions & 0 deletions tests/test_slimsmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ class TestModelAlias(SlimsBaseModel):
expected = {"alias": "value2"}
self.assertEqual(serialized, expected)

def test_unitspec(self):
"""Test unitspec with no arguments"""
self.assertRaises(ValueError, UnitSpec)


if __name__ == "__main__":
unittest.main()

0 comments on commit 0a20676

Please sign in to comment.