Skip to content

Commit

Permalink
updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zavoraad committed Dec 6, 2024
1 parent 2e994da commit 13ee227
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dbignite/fhir_mapping_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def us_core_fhir_resource_mapping(cls):
#
def custom_fhir_resource_mapping(self, resource_list: list[str]) -> "FhirSchemaModel":
custom_mapping = {
resource_type: FhirSchemaModel.__read_schema(schema_path)
resource_type: FhirSchemaModel._read_schema(schema_path)
for resource_type, schema_path in self._get_schema_paths()
if resource_type in resource_list
}
Expand Down
7 changes: 4 additions & 3 deletions tests/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def test_encoder(self):
from dbignite.writer.fhir_encoder import FhirEncoder
e = FhirEncoder(False, False, lambda x: int(x.strip()))
assert( e.f("123") == 123 )
assert( e.f("12a") is None )
assert( e.f("12a") == "" )

def test_encoder_manager(self):
from dbignite.writer.fhir_encoder import FhirEncoderManager, SchemaDataType, FhirEncoder
em = FhirEncoderManager()
assert(em.get_encoder("string", ["Patient", "multipleBirthInteger"]).f("1234") == 1234)
assert(em.get_encoder("string", ["Patient", "multipleBirthInteger"]).f("abcdefg") == None)
assert(em.get_encoder("string", ["Patient", "multipleBirthInteger"]).f("abcdefg") == "")

#test overrides
em = FhirEncoderManager(override_encoders = {"Patient.multipleBirthInteger": FhirEncoder(False, False, lambda x: float(x) + 1)})
Expand All @@ -27,7 +27,8 @@ def test_target_datatype(self):
from dbignite.writer.fhir_encoder import SchemaDataType
from dbignite.fhir_mapping_model import FhirSchemaModel
field = "Patient.name.given"
tgt_schema = FhirSchemaModel.custom_fhir_resource_mapping(field.split(".")[0]).schema(field.split(".")[0])
s = FhirSchemaModel()
tgt_schema = s.custom_fhir_resource_mapping(field.split(".")[0]).schema(field.split(".")[0])
result = SchemaDataType.traverse_schema(field.split(".")[1:], tgt_schema)
assert( result == "array<string>")

Expand Down

0 comments on commit 13ee227

Please sign in to comment.