Skip to content

Commit

Permalink
Merge pull request #109 from Lightmatter/develop
Browse files Browse the repository at this point in the history
v0.1.4
  • Loading branch information
samamorgan authored May 10, 2024
2 parents a490d46 + 2f1054e commit 30da940
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "welkin"
version = "0.1.3"
version = "0.1.4"
description = "Python Welkin Health API Wrapper."
authors = ["Sam Morgan <sama4mail@gmail.com>"]
license = "GPL-3.0-or-later"
Expand Down
25 changes: 16 additions & 9 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ def redact(field_name, extra=""):
RESPONSE_BLACKLIST = [
"token",
"createdBy",
"created_by",
"createdByName",
"created_by_name",
"updatedBy",
"updated_by",
"updatedByName",
"updated_by_name",
]
CLIENT_INIT = {
"tenant": os.environ["WELKIN_TENANT"],
Expand All @@ -50,14 +54,15 @@ def client():


@pytest.fixture(scope="module")
def vcr(vcr):
vcr.filter_headers = HEADER_BLACKLIST
vcr.filter_post_data_parameters = POST_DATA_BLACKLIST
vcr.before_record_request = scrub_request(CLIENT_INIT)
vcr.before_record_response = scrub_response(RESPONSE_BLACKLIST)
vcr.decode_compressed_response = True

return vcr
def vcr_config():
return {
"filter_headers": HEADER_BLACKLIST,
"filter_post_data_parameters": POST_DATA_BLACKLIST,
"before_record_request": scrub_request(CLIENT_INIT),
"before_record_response": scrub_response(RESPONSE_BLACKLIST),
"decode_compressed_response": True,
"match_on": ("method", "scheme", "host", "port", "path", "query", "body"),
}


def scrub_request(blacklist, replacement="REDACTED"):
Expand Down Expand Up @@ -102,7 +107,9 @@ def filter_body(body, blacklist, replacement):

def body_hook(blacklist, replacement):
def hook(dct):
for k in dct:
for k, v in dct.items():
if isinstance(v, dict):
dct[k] = hook(v)
if k in blacklist:
dct[k] = redact(k, replacement)

Expand Down
1 change: 1 addition & 0 deletions test/test_assessments.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def test_assessment_record_get_w_patient_id(client, vcr_cassette):
assert len(vcr_cassette) == 1


@pytest.mark.skip(reason="Need to figure out request matching on PUT body")
@pytest.mark.vcr
def test_assessment_record_update(client, vcr_cassette):
patient = client.Patient(id="371dd15c-cedc-4425-a394-d666c8d3fc01")
Expand Down
2 changes: 1 addition & 1 deletion test/test_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@pytest.mark.vcr
def test_calendar_event_create(client, vcr_cassette):
start = datetime.now(tz=UTC) + timedelta(hours=6)
start = datetime(2022, 6, 30, 17, 59, 47, 790000, tzinfo=UTC)
end = start + timedelta(hours=1)

event = client.CalendarEvent(
Expand Down
2 changes: 1 addition & 1 deletion test/test_encounters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@pytest.mark.vcr
def test_encounter_create(client, vcr_cassette):
patient = client.Patient(id="371dd15c-cedc-4425-a394-d666c8d3fc01")
start = datetime.now(tz=UTC) + timedelta(hours=6)
start = datetime(2022, 7, 26, 20, 6, 33, 744000, tzinfo=UTC)
end = start + timedelta(hours=1)

data = {
Expand Down
2 changes: 1 addition & 1 deletion test/test_patients.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_patient_create_birthdate(client, vcr_cassette):
patient = client.Patient(
firstName="happy",
lastName="borf",
birthDate=date.today(), # noqa: DTZ011
birthDate=date(2022, 8, 9),
).create()

assert isinstance(patient, Patient)
Expand Down
5 changes: 4 additions & 1 deletion welkin/models/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,8 @@ class Patients(Collection):
def get(self, filter: dict | None = None, *args, **kwargs): # noqa: A002
# TODO: Add sort and query arguments.
return super().post(
f"{self._client.instance}/by-filter/patients", *args, json=filter, **kwargs
f"{self._client.instance}/by-filter/patients",
*args,
json=filter or {},
**kwargs,
)

0 comments on commit 30da940

Please sign in to comment.