def test_get_device_by_period_date_outside(
        mock_data: dict, mock_ucam_config: MagicMock) -> None:
    patient = PatientWithDevices.serialize(mock_data["patients"][5])
    start_wear = format_weartime("2020-09-10T00:00:00", "ucam")
    end_wear = format_weartime("2020-09-13T00:00:01", "ucam")

    result = ucam.device_by_wear_period(patient.devices, start_wear, end_wear)

    assert result is None
def test_get_device_by_period_date_end_wear_none(
        mock_data: dict, mock_ucam_config: MagicMock) -> None:
    patient = PatientWithDevices.serialize(mock_data["patients"][5])
    start_wear = format_weartime("2020-09-29T00:00:00", "ucam")
    end_wear = format_weartime("2020-10-02T00:00:01", "ucam")

    result = ucam.device_by_wear_period(patient.devices, start_wear, end_wear)

    assert result.vttsma_id == "VTT_COMPLEX_HASH"
Exemple #3
0
 def serialize(cls, payload: dict) -> Device:
     return cls(
         start_wear=format_weartime(payload["start_wear"], "ucam"),
         end_wear=format_weartime(payload["end_wear"], "ucam")
         if payload["end_wear"] else None,
         deviations=payload["deviations"],
         vttsma_id=payload["vttsma_id"],
         device_id=payload["device_id"],
     )
Exemple #4
0
 def serialize(cls, payload: dict) -> Patient:
     return cls(
         start_wear=format_weartime(payload["start_wear"], "ucam"),
         end_wear=format_weartime(payload["end_wear"], "ucam")
         if payload["end_wear"] else None,
         deviations=payload["deviations"],
         vttsma_id=payload["vttsma_id"],
         patient_id=payload["patient_id"],
         disease=DiseaseType(int(payload["disease"])),
     )
def test_get_patient_by_period_invalid_patient_id(mock_payload: dict) -> None:
    get_response = MagicMock(json=lambda: mock_payload)

    device_id = "WRONG-DEVICE-ID"
    start_wear = format_weartime("2020-06-20T00:00:00", "ucam")
    end_wear = format_weartime("2020-06-20T00:00:01", "ucam")

    with patch("requests.get", return_value=get_response):

        result = ucam.patient_by_wear_period(device_id, start_wear, end_wear)

        assert result is None
Exemple #6
0
def test_record_by_device_id_date_outside(
    mock_inventory_history_response: dict,
    mock_inv_config: MagicMock,
) -> None:
    response = MagicMock()
    response.json = lambda: mock_inventory_history_response

    with patch("requests.get", return_value=response):
        start_wear = utils.format_weartime("2021-03-17 12:11:55", "inventory")
        end_wear = utils.format_weartime("2021-03-17 22:11:55", "inventory")

        result = inventory.record_by_device_id("BTF-123456", start_wear, end_wear)

        assert result is None
def test_get_patient_by_period_date_within(mock_data: dict,
                                           mock_payload: dict) -> None:
    mock_payload.update({
        "data":
        [d for d in mock_data["devices"] if d["device_id"] == "NR3-DEVICE"]
    })
    get_response = MagicMock(json=lambda: mock_payload)

    device_id = "NR3-DEVICE"
    start_wear = format_weartime("2020-06-20T00:00:00", "ucam")
    end_wear = format_weartime("2020-06-20T00:00:01", "ucam")

    with patch("requests.get", return_value=get_response):

        result = ucam.patient_by_wear_period(device_id, start_wear, end_wear)

        assert result.patient_id == "B-PATIENT"