Пример #1
0
def test_FileRecording31(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    r = fr._line_to_measurement(["1", "2", "a", "4"],
                                make_invalid_measurement_missing=True)
    assert r.blood_pressure_systolic is None
Пример #2
0
def test_FileRecording33(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    r = fr._line_to_measurement(["a", "2", "3", "4"],
                                make_invalid_measurement_missing=True)
    assert r.oxygen is None
Пример #3
0
def test_FileRecording63(capsys):
    """Testing FileRecording"""
    happend = False
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_4.csv")
    data = fr.__iter__().__next__()  # type: entity.Measurement
    assert data.pulse is None
Пример #4
0
def test_FileRecording20(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    assert True
    res = list(fr._get_indices(["b", "a", "c"], ["a", "b"]))
    assert res[0] == 1
    assert res[1] == 0
Пример #5
0
def test_FileRecording22(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    fr._validate_heading([
        "oxygen", "pulse", "blood_pressure_systolic",
        "blood_pressure_diastolic"
    ])
    assert True
Пример #6
0
def test_FileRecording44(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    m = fr._line_to_measurement(["", "", "", ""],
                                make_invalid_measurement_missing=False)
    assert m.blood_pressure_diastolic is None
    assert m.blood_pressure_systolic is None
    assert m.oxygen is None
    assert m.pulse is None
Пример #7
0
def test_FileRecording24(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    happend = False
    try:
        fr._validate_heading(["oxygen"])
    except AssertionError:
        happend = True
    assert happend
Пример #8
0
def test_FileRecording58(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    happend = False
    try:
        fr._parse_field(["0", "54", "a"], 2)
    except ValueError:
        happend = True
    assert happend
Пример #9
0
def test_FileRecording61(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    happend = False
    try:
        fr._line_to_measurement(["a", "2", "3", "4"])
    except ValueError:
        happend = True
    assert happend
Пример #10
0
def test_FileRecording43(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    happend = False
    try:
        fr._line_to_measurement([], make_invalid_measurement_missing=False)
    except IndexError:
        happend = True
    assert happend
Пример #11
0
def test_FileRecording7(capsys):
    """Testing FileRecording"""
    happend = False
    try:
        entity.FileRecording(
            "heartmonitor/tests/test_files/file_recording/heading_missing_6.csv"
        )
    except AssertionError:
        happend = True
    assert happend
Пример #12
0
def test_FileRecording27(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    happend = False
    try:
        fr._validate_heading(
            ["oxygen", "pulse", "a", "blood_pressure_diastolic"])
    except AssertionError:
        happend = True
    assert happend
Пример #13
0
def test_FileRecording37(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    m = fr._line_to_measurement(["1", "2", "3", "4"],
                                make_invalid_measurement_missing=False)
    assert isinstance(m, entity.Measurement)
    assert m.oxygen == 1
    assert m.pulse == 2
    assert m.blood_pressure_systolic == 3
    assert m.blood_pressure_diastolic == 4
Пример #14
0
def test_FileRecording56(capsys):
    """Testing FileRecording"""
    happend = False
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/heading_extras_8.csv")
    fr.__iter__().__next__()
    try:
        fr.__iter__().__next__()
    except StopIteration:
        happend = True
    assert happend
Пример #15
0
def test_FileRecording62(capsys):
    """Testing FileRecording"""
    happend = False
    data = None  # type: entity.Measurement
    try:
        fr = entity.FileRecording(
            "heartmonitor/tests/test_files/file_recording/data_4.csv")
        data = fr.__iter__().__next__(make_invalid_measurement_missing=True)
    except StopIteration:
        happend = True
    assert not happend
    assert data.pulse is None
Пример #16
0
def test_FileRecording17(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    assert True

    fp = fr._fpointer

    # Destuct the file recording.
    fr = None

    assert fp.closed
Пример #17
0
def test_FileRecording57(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    happend = False
    try:
        fr._parse_field(["0", "54", "a"],
                        2,
                        make_invalid_measurement_missing=True)
    except ValueError:
        happend = True
    assert not happend
Пример #18
0
def test_FileRecording45(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    assert (fr._parse_field(["0", "54", "a"],
                            0,
                            make_invalid_measurement_missing=True) == 0)
    assert (fr._parse_field(["0", "54", "a"],
                            1,
                            make_invalid_measurement_missing=True) == 54)
    assert (fr._parse_field(
        ["0", "54", "a"], 2, make_invalid_measurement_missing=True) is None)
Пример #19
0
def test_FileRecording16(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_7.csv")
    assert True

    it = fr.get_iterator()
    assert fr == it

    counter = 0
    for _ in it:
        counter += 1

    assert counter == 0
Пример #20
0
def test_FileRecording8(capsys):
    """Testing FileRecording"""
    happend = False  # type: entity.FileRecording
    fr = None
    msg = ""
    try:
        fr = entity.FileRecording(
            "heartmonitor/tests/test_files/file_recording/not_existing.csv")
    except entity.FileNotFound as ex:
        msg = str(ex)
        happend = True
    assert happend
    assert fr is None
    assert msg == "Could not find recording file."
Пример #21
0
def main(argv: List[str]):
    csv_location = None  # type: str
    try:
        csv_location = argv_parser.parse(argv, "--path")
    except:
        print_help()
        sys.exit(1)
        return

    # Create statistics
    oxygen_ms = entity.MeasurementStatistics()
    pulse_ms = entity.MeasurementStatistics()
    blood_pressure_systolic_ms = entity.MeasurementStatistics()
    blood_pressure_diastolic_ms = entity.MeasurementStatistics()
    statistics = entity.Statistics(oxygen_ms, pulse_ms,
                                   blood_pressure_systolic_ms,
                                   blood_pressure_diastolic_ms)
    number_of_measurements = 0
    try:
        recording = None  # type: entity.FileRecording
        try:
            recording = entity.FileRecording(csv_location).get_iterator()
        except:
            print_help()
            sys.exit(1)
            return

        while True:
            m = None  # type: entity.Measurement
            try:
                m = recording.__next__(make_invalid_measurement_missing=True)
            except StopIteration:
                break

            measurement_results = processor.processing_agent(m, statistics)
            result_string = output_parser.format_status(measurement_results)
            print(result_string, flush=True)
            logger.log(result_string)
            number_of_measurements += 1
            wait_on_new_measurement()
    except KeyboardInterrupt:
        # When someone wants to stop the program prematurely.
        pass
    statistics_string = output_parser.format_statistics(statistics)
    print(statistics_string, flush=True)
    logger.log(statistics_string)
    print(f"Processed {number_of_measurements} measurements")
Пример #22
0
def test_FileRecording15(capsys):
    """Testing FileRecording"""
    fr = entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/data_6.csv")
    assert True

    it = fr.get_iterator()
    assert fr == it

    counter = 0
    for x in it:
        assert x.oxygen is None
        assert x.pulse is None
        assert x.blood_pressure_systolic is None
        assert x.blood_pressure_diastolic is None
        counter += 1

    assert counter == 1
Пример #23
0
def test_FileRecording(capsys):
    """Testing FileRecording"""
    entity.FileRecording(
        "heartmonitor/tests/test_files/file_recording/heading_ok.csv")
    assert True