コード例 #1
0
def test_calculate_sla_by_practice_calculates_sla_given_transfers_for_2_practices(
):
    transfers = [
        build_transfer(requesting_practice_ods="A12345",
                       sla_duration=timedelta(days=8, hours=1, minutes=10)),
        build_transfer(requesting_practice_ods="B12345",
                       sla_duration=timedelta(days=4, hours=1, minutes=10)),
        build_transfer(requesting_practice_ods="A12345",
                       sla_duration=timedelta(days=0, hours=1, minutes=10)),
        build_transfer(requesting_practice_ods="B12345",
                       sla_duration=timedelta(days=8, hours=1, minutes=10)),
        build_transfer(requesting_practice_ods="B12345",
                       sla_duration=timedelta(days=5, hours=1, minutes=10)),
    ]

    expected = [
        PracticeSlaMetrics(ods="A12345",
                           within_3_days=1,
                           within_8_days=0,
                           beyond_8_days=1),
        PracticeSlaMetrics(ods="B12345",
                           within_3_days=0,
                           within_8_days=2,
                           beyond_8_days=1),
    ]

    actual = calculate_sla_by_practice(transfers)
    actual_sorted = sorted(actual, key=lambda p: p.ods)

    assert actual_sorted == expected
コード例 #2
0
def test_calculate_sla_by_practice_groups_by_ods_given_two_transfers_from_the_same_practice(
):
    transfers = [
        build_transfer(requesting_practice_ods="A12345"),
        build_transfer(requesting_practice_ods="A12345"),
    ]

    actual = calculate_sla_by_practice(transfers)

    _assert_has_ods_codes(actual, {"A12345"})
コード例 #3
0
def test_filter_pending_transfers_doesnt_exclude_completed():
    pending_transfer = build_transfer(pending=True)
    completed_transfer = build_transfer(pending=False)

    transfers = [pending_transfer, completed_transfer]

    actual = filter_pending_transfers(transfers)
    expected = [completed_transfer]

    assert list(actual) == expected
コード例 #4
0
def test_calculate_sla_by_practice_calculates_sla_given_one_transfer_within_3_days(
):
    transfer = build_transfer(sla_duration=timedelta(hours=1, minutes=10))
    actual = calculate_sla_by_practice([transfer])

    _assert_first_summary_has_sla_counts(actual,
                                         within_3_days=1,
                                         within_8_days=0,
                                         beyond_8_days=0)
コード例 #5
0
def test_filter_pending_transfers_excludes_pending():
    pending_transfer = build_transfer(pending=True)

    transfers = [pending_transfer]

    actual = filter_pending_transfers(transfers)
    expected = []

    assert list(actual) == expected
コード例 #6
0
def test_filter_failed_transfers_excludes_failed():
    failed_transfer = build_transfer(error_code=99)
    transfers = [failed_transfer]

    actual = filter_failed_transfers(transfers)

    expected = []

    assert list(actual) == expected
コード例 #7
0
def test_filter_failed_transfers_doesnt_exclude_suppressions():
    suppressed_transfer = build_transfer(error_code=15)
    transfers = [suppressed_transfer]

    actual = filter_failed_transfers(transfers)

    expected = [suppressed_transfer]

    assert list(actual) == expected
コード例 #8
0
def test_calculate_sla_by_practice_groups_by_ods_given_single_transfer():
    transfers = [build_transfer(requesting_practice_ods="A12345")]

    actual = calculate_sla_by_practice(transfers)

    _assert_has_ods_codes(actual, {"A12345"})