Skip to content

Commit

Permalink
NSB surgery protocol (#229)
Browse files Browse the repository at this point in the history
* NSB surgery protocol

* fix coverage
  • Loading branch information
mekhlakapoor authored May 13, 2024
1 parent df65dde commit ae8221e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/aind_metadata_service/smartsheet/protocols/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ def integrate_protocols(
if len(response.aind_models) > 0:
pre_procedures = response.aind_models[0]
for subject_procedure in pre_procedures.subject_procedures:
if isinstance(subject_procedure, Surgery):
if (
isinstance(subject_procedure, Surgery)
and hasattr(subject_procedure, "experimenter_full_name")
and "NSB" in subject_procedure.experimenter_full_name
):
protocol_name = ProtocolNames.SURGERY.value
smartsheet_response = protocols_mapping.get(protocol_name)
if (
Expand Down
13 changes: 10 additions & 3 deletions tests/smartsheet/test_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ def test_integrate_protocols(self):
self.surgery_name: protocols_response2.map_to_json_response(),
}
nanoject_inj = NanojectInjection.model_construct()
surgery = Surgery.model_construct(procedures=[nanoject_inj])
surgery = Surgery.model_construct(
experimenter_full_name="NSB-123", procedures=[nanoject_inj]
)
procedures_response = ModelResponse(
aind_models=[
Procedures(subject_id="12345", subject_procedures=[surgery])
Expand All @@ -297,6 +299,7 @@ def test_integrate_protocols(self):
)
expected_surgery = Surgery.model_construct(
protocol_id="dx.doi.org/some/doi/2",
experimenter_full_name="NSB-123",
procedures=[
NanojectInjection.model_construct(
protocol_id="dx.doi.org/some/doi/1"
Expand Down Expand Up @@ -330,7 +333,9 @@ def test_integrate_protocols_error(self):
self.surgery_name: protocols_response.map_to_json_response(),
}
nanoject_inj = NanojectInjection.model_construct()
surgery = Surgery.model_construct(procedures=[nanoject_inj])
surgery = Surgery.model_construct(
experimenter_full_name="NSB-123", procedures=[nanoject_inj]
)
procedures_response = ModelResponse(
aind_models=[
Procedures(subject_id="12345", subject_procedures=[surgery])
Expand All @@ -354,7 +359,9 @@ def test_integrate_protocols_multi_status(self):
self.surgery_name: protocols_response.map_to_json_response(),
}
nanoject_inj = NanojectInjection.model_construct()
surgery = Surgery.model_construct(procedures=[nanoject_inj])
surgery = Surgery.model_construct(
experimenter_full_name="NSB-123", procedures=[nanoject_inj]
)
procedures_response = ModelResponse(
aind_models=[
Procedures(subject_id="12345", subject_procedures=[surgery])
Expand Down

0 comments on commit ae8221e

Please sign in to comment.