Esempio n. 1
0
 def test_patch_resource(self, store: FHIRStore, test_patient):
     """patch() finds a document in the database"""
     store.create(test_patient)
     store.patch("Patient", test_patient["id"], {"gender": "other"})
     assert store.read("Patient", test_patient["id"]) == {
         **test_patient, "gender": "other"
     }
Esempio n. 2
0
        data["id"] = str(uuid4())
    start = timer()
    res = store.create(data)
    end = timer()
    stats[example] = end - start
    inserted.append(res)

values = stats.values()
print(f"insertions per second (on average): {1/statistics.mean(values):.2f}")
print(f"average: {statistics.mean(values)*1000:.2f} milliseconds")
print(f"median: {statistics.median(values)*1000:.2f} milliseconds")
print(f"min: {min(values)*1000:.2f} milliseconds")
print(f"max: {max(values)*1000:.2f} milliseconds")
print(f"spread: {statistics.variance(values)}")

examples = tqdm(inserted, desc="Running read benchmark")
stats = {}
for doc in examples:
    start = timer()
    store.read(doc["resourceType"], doc["id"])
    end = timer()
    stats[doc["id"]] = end - start

values = stats.values()
print(f"reads per second (on average): {1/statistics.mean(values):.2f}")
print(f"average: {statistics.mean(values)*1000:.2f} milliseconds")
print(f"median: {statistics.median(values)*1000:.2f} milliseconds")
print(f"min: {min(values)*1000:.2f} milliseconds")
print(f"max: {max(values)*1000:.2f} milliseconds")
print(f"spread: {statistics.variance(values)}")
Esempio n. 3
0
    def test_read_resource_not_found(self, store: FHIRStore, test_patient):
        """read() returns None when no matching document was found"""

        with raises(NotFoundError):
            store.read("Patient", test_patient["id"])
Esempio n. 4
0
 def test_read_resource(self, store: FHIRStore, test_patient):
     """read() finds a document in the database"""
     store.create(test_patient)
     result = store.read("Patient", test_patient["id"])
     assert result == test_patient
Esempio n. 5
0
    def test_read_bad_resource_type(self, store: FHIRStore):
        """read() raises if resource type is unknown"""

        with raises(NotFoundError,
                    match='unsupported FHIR resource: "unknown"'):
            store.read("unknown", "864321")