From 365b9f862b7d01ca1fa66df1210916f1e8d0cc92 Mon Sep 17 00:00:00 2001 From: SimonKonar Date: Mon, 4 Nov 2024 11:42:21 +0100 Subject: [PATCH 1/2] fix: change collection_json[extension] to get(extension,[]) --- miabis_model/collection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miabis_model/collection.py b/miabis_model/collection.py index dbc2be8..6503ccc 100644 --- a/miabis_model/collection.py +++ b/miabis_model/collection.py @@ -230,7 +230,7 @@ def from_json(cls, collection_json: dict, managing_collection_organization_id: s characteristics = cls._get_characteristics(collection_json["characteristic"]) managing_collection_fhir_id = parse_reference_id( get_nested_value(collection_json, ["managingEntity", "reference"])) - extensions = cls._get_extensions(collection_json["extension"]) + extensions = cls._get_extensions(collection_json.get("extension", [])) instance = cls(identifier, name, managing_collection_organization_id, characteristics["sex"], characteristics["material_type"], characteristics["age_range_low"], characteristics["age_range_high"], characteristics["storage_temperature"], From 0dea2a209fab7977ef6dbf290336a97e3c89ec86 Mon Sep 17 00:00:00 2001 From: SimonKonar Date: Mon, 4 Nov 2024 11:43:06 +0100 Subject: [PATCH 2/2] remove extension from collection) --- test/service/test_blaze_client.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/service/test_blaze_client.py b/test/service/test_blaze_client.py index a653a9a..d1da61e 100644 --- a/test/service/test_blaze_client.py +++ b/test/service/test_blaze_client.py @@ -48,8 +48,8 @@ class TestBlazeService(unittest.TestCase): "description", "LifeStyle", "Human", "Environment", ["CaseControl"], ["CommercialUse"], ["publication"]) - example_collection = Collection("collectionId", "collectionName", "collectionOrgId", [Gender.MALE], ["DNA"], - inclusion_criteria=["HealthStatus"]) + example_collection = Collection("collectionId", "collectionName", "collectionOrgId", [Gender.MALE], ["DNA"],) + # inclusion_criteria=["HealthStatus"]) example_network_org = NetworkOrganization("networkOrgId", "networkOrgName", "biobankId", "contactName", "contactSurname", "contactEmail", "country", ["Charter"], @@ -102,6 +102,15 @@ def test_blaze_service_unreachable_raises_httpError(self): def test_is_resource_present_in_blaze_false(self): self.assertFalse(self.blaze_service.is_resource_present_in_blaze("Patient", "nonexistentId")) + def test_is_resource_present_in_blaze_with_search_param_true(self): + self.blaze_service.upload_donor(self.example_donor) + self.assertTrue( + self.blaze_service.is_resource_present_in_blaze("Patient", self.example_donor.identifier, "identifier")) + + def test_is_resource_present_in_blaze_with_search_param_false(self): + self.assertFalse( + self.blaze_service.is_resource_present_in_blaze("Patient", "nonexistentIdentifier", "identifier")) + def test_get_fhir_resource_as_json_existing(self): donor_fhir_id = self.blaze_service.upload_donor(self.example_donor) donor_json = self.blaze_service.get_fhir_resource_as_json("Patient", donor_fhir_id) @@ -769,4 +778,3 @@ def test_delete_sample_present_in_collection(self): self.assertTrue(updated) deleted = self.blaze_service.delete_sample(sample_fhir_id1) self.assertTrue(deleted) -