Exemple #1
0
def test_MeasurementValues(capsys):
    """Testing entity MeasurementValues"""
    m = entity.Measurement(10, 20, 30, 40)

    assert m.oxygen == 10
    assert m.pulse == 20
    assert m.blood_pressure_systolic == 30
    assert m.blood_pressure_diastolic == 40
Exemple #2
0
def test_Measurement(capsys):
    """Testing entity Measurement"""
    m = entity.Measurement()

    assert m.oxygen is None
    assert m.pulse is None
    assert m.blood_pressure_systolic is None
    assert m.blood_pressure_diastolic is None
Exemple #3
0
def test_MeasurementResult(capsys):
    """Testing entity MeasurementResult"""
    m = entity.Measurement()
    mr = entity.MeasurementResult(m)

    assert mr.oxygen_status is entity.StatusEnum.MISSING
    assert mr.pulse_status is entity.StatusEnum.MISSING
    assert mr.blood_pressure_systolic_status is entity.StatusEnum.MISSING
    assert mr.blood_pressure_diastolic_status is entity.StatusEnum.MISSING
    assert mr.m is m
Exemple #4
0
def test_MockRecording(capsys):
    """Testing entity MockRecording"""
    mr = entity.MockRecording([entity.Measurement(10)])

    assert len(mr.results) == 1
    assert mr.results[0].oxygen == 10
    assert mr.results[0].pulse is None

    for x in mr.get_iterator():
        assert mr.results[0] == x

    assert mr.__iter__() == mr.results
Exemple #5
0
def test_MeasurementResultValues(capsys):
    """Testing entity MeasurementResultValues"""
    m = entity.Measurement(10, 20, 30, 40)
    mr = entity.MeasurementResult(
        m,
        entity.StatusEnum.MISSING,
        entity.StatusEnum.OK,
        entity.StatusEnum.MINOR,
        entity.StatusEnum.MAJOR,
    )

    assert mr.oxygen_status == entity.StatusEnum.MISSING
    assert mr.pulse_status == entity.StatusEnum.OK
    assert mr.blood_pressure_systolic_status == entity.StatusEnum.MINOR
    assert mr.blood_pressure_diastolic_status == entity.StatusEnum.MAJOR
Exemple #6
0
def test_output_parse4(capsys):
    m = entity.Measurement(90, 100, 110, 120)
    mr = entity.MeasurementResult(
        m,
        entity.StatusEnum.OK,
        entity.StatusEnum.OK,
        entity.StatusEnum.MISSING,
        entity.StatusEnum.OK,
    )
    res = output_parser.format_status(mr)
    assert "100" in res
    assert "90" in res
    assert "120" in res
    assert "OK" in res
    assert "MISSING" in res
Exemple #7
0
def test_output_parse(capsys):
    m = entity.Measurement(90, 100, 110, 120)
    mr = entity.MeasurementResult(
        m,
        entity.StatusEnum.MINOR,
        entity.StatusEnum.OK,
        entity.StatusEnum.LIFE_THREATENING,
        entity.StatusEnum.MAJOR,
    )

    output = output_parser.format_status(mr)
    assert "90" in output
    assert "100" in output
    assert "110" in output
    assert "120" in output
Exemple #8
0
def test_output_parse2(capsys):
    m = entity.Measurement(90, 100, 110, 120)
    mr = entity.MeasurementResult(
        m,
        entity.StatusEnum.MISSING,
        entity.StatusEnum.OK,
        entity.StatusEnum.LIFE_THREATENING,
        entity.StatusEnum.MAJOR,
    )
    res = output_parser.format_status(mr)
    assert "0" in res
    assert "100" in res
    assert "110" in res
    assert "120" in res
    assert "MISSING" in res
    assert "OK" in res
    assert "LIFE_THREATENING" in res
    assert "MAJOR" in res
Exemple #9
0
def test_processing_agent2(capsys):
    m = entity.Measurement(95, 90, 100, 70)
    statistics = entity.Statistics(entity.MeasurementStatistics(),
                                   entity.MeasurementStatistics(),
                                   entity.MeasurementStatistics(),
                                   entity.MeasurementStatistics())
    assert m.blood_pressure_diastolic == 70
    assert m.blood_pressure_systolic == 100
    assert m.oxygen == 95
    assert m.pulse == 90
    measurement_results = processor.processing_agent(
        m, statistics)  # entity.MeasurementResult
    assert measurement_results.m == m
    assert measurement_results.m.blood_pressure_diastolic == 70
    assert measurement_results.m.blood_pressure_systolic == 100
    assert measurement_results.m.oxygen == 95
    assert measurement_results.m.pulse == 90
    assert measurement_results.blood_pressure_diastolic_status == entity.StatusEnum.OK
    assert measurement_results.blood_pressure_systolic_status == entity.StatusEnum.OK
    assert measurement_results.oxygen_status == entity.StatusEnum.OK
    assert measurement_results.pulse_status == entity.StatusEnum.OK
Exemple #10
0
def test_processing_agent1(capsys):
    m = entity.Measurement()
    statistics = entity.Statistics(entity.MeasurementStatistics(),
                                   entity.MeasurementStatistics(),
                                   entity.MeasurementStatistics(),
                                   entity.MeasurementStatistics())
    assert m.blood_pressure_diastolic is None
    assert m.blood_pressure_systolic is None
    assert m.oxygen is None
    assert m.pulse is None
    measurement_results = processor.processing_agent(
        m, statistics)  # entity.MeasurementResult
    assert measurement_results.m == m
    assert measurement_results.m.blood_pressure_diastolic is None
    assert measurement_results.m.blood_pressure_systolic is None
    assert measurement_results.m.oxygen is None
    assert measurement_results.m.pulse is None
    assert measurement_results.blood_pressure_diastolic_status == entity.StatusEnum.MISSING
    assert measurement_results.blood_pressure_systolic_status == entity.StatusEnum.MISSING
    assert measurement_results.oxygen_status == entity.StatusEnum.MISSING
    assert measurement_results.pulse_status == entity.StatusEnum.MISSING
Exemple #11
0
"""Tests for `heartmonitor` package."""
import pytest
import processor, entity
from numbers import Number

m1 = entity.Measurement(90, 50, 30, 40)
m2 = entity.Measurement(22, 88, 44, 66)
m3 = entity.Measurement(36, 0, 1, 44)
m4 = entity.Measurement(234, 36, 453, 24)
mock = entity.MockRecording([m1, m2, m3, m4])


def test_processing_agent1(capsys):
    m = entity.Measurement()
    statistics = entity.Statistics(entity.MeasurementStatistics(),
                                   entity.MeasurementStatistics(),
                                   entity.MeasurementStatistics(),
                                   entity.MeasurementStatistics())
    assert m.blood_pressure_diastolic is None
    assert m.blood_pressure_systolic is None
    assert m.oxygen is None
    assert m.pulse is None
    measurement_results = processor.processing_agent(
        m, statistics)  # entity.MeasurementResult
    assert measurement_results.m == m
    assert measurement_results.m.blood_pressure_diastolic is None
    assert measurement_results.m.blood_pressure_systolic is None
    assert measurement_results.m.oxygen is None
    assert measurement_results.m.pulse is None
    assert measurement_results.blood_pressure_diastolic_status == entity.StatusEnum.MISSING
    assert measurement_results.blood_pressure_systolic_status == entity.StatusEnum.MISSING