From 341ed16a582977ccf418bfa5e026e7fa202109db Mon Sep 17 00:00:00 2001 From: Mekhla Kapoor <54870020+mekhlakapoor@users.noreply.github.com> Date: Fri, 6 Oct 2023 15:29:25 -0700 Subject: [PATCH] negative room or cage (#146) * negative room or cage * removes accidental change in pyproject.toml --- src/aind_metadata_service/labtracks/client.py | 13 +++++-------- tests/labtracks/test_response_handler.py | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/aind_metadata_service/labtracks/client.py b/src/aind_metadata_service/labtracks/client.py index 96f5fcc2..2330e899 100644 --- a/src/aind_metadata_service/labtracks/client.py +++ b/src/aind_metadata_service/labtracks/client.py @@ -346,14 +346,11 @@ def _map_housing( ------- Optional[Housing] """ - if room_id is None and cage_id is None: - return None - else: - housing = Housing.construct( - room_id=room_id if room_id else None, - cage_id=cage_id if cage_id else None, - ) - return 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 + + return Housing.construct(room_id=room_id, + cage_id=cage_id) if room_id is not None or cage_id is not None else None def map_response_to_subject(self, results: List[dict]) -> List[Subject]: """ diff --git a/tests/labtracks/test_response_handler.py b/tests/labtracks/test_response_handler.py index 5c331042..5e9f7b55 100644 --- a/tests/labtracks/test_response_handler.py +++ b/tests/labtracks/test_response_handler.py @@ -241,7 +241,7 @@ def test_map_housing(self): housing3 = Housing.construct(cage_id="1234") housing4 = Housing.construct(room_id="000", cage_id="1234") - subject_housing1 = self.rh._map_housing(room_id=None, cage_id=None) + 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")