Skip to content

Commit

Permalink
fix cage id (#231)
Browse files Browse the repository at this point in the history
* fix cage id

* adds test case
  • Loading branch information
mekhlakapoor authored May 16, 2024
1 parent 81da617 commit 835d44f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/aind_metadata_service/labtracks/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ def _map_housing(
-------
Optional[Housing]
"""
room_id = None if room_id is None or int(room_id) < 0 else room_id
cage_id = None if cage_id is None or int(cage_id) < 0 else cage_id
room_id = None if room_id is None or int(room_id) < 0 else str(room_id)
cage_id = None if cage_id is None or int(cage_id) < 0 else str(cage_id)

return (
Housing.model_construct(room_id=room_id, cage_id=cage_id)
Expand Down
3 changes: 3 additions & 0 deletions tests/labtracks/test_response_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,21 @@ def test_map_housing(self):
housing2 = Housing.model_construct(room_id="000")
housing3 = Housing.model_construct(cage_id="1234")
housing4 = Housing.model_construct(room_id="000", cage_id="1234")
housing5 = Housing.model_construct(room_id="123", cage_id="456")

subject_housing1 = self.rh._map_housing(
room_id="-99999999999", cage_id=None
)
subject_housing2 = self.rh._map_housing(room_id="000", cage_id=None)
subject_housing3 = self.rh._map_housing(room_id=None, cage_id="1234")
subject_housing4 = self.rh._map_housing(room_id="000", cage_id="1234")
subject_housing5 = self.rh._map_housing(room_id=123, cage_id=456)

self.assertIsNone(subject_housing1)
self.assertEqual(subject_housing2, housing2)
self.assertEqual(subject_housing3, housing3)
self.assertEqual(subject_housing4, housing4)
self.assertEqual(subject_housing5, housing5)


if __name__ == "__main__":
Expand Down

0 comments on commit 835d44f

Please sign in to comment.