def build_practice_sla_metrics(**kwargs):
    return PracticeSlaMetrics(
        ods=kwargs.get("ods", a_string(6)),
        within_3_days=kwargs.get("within_3_days", an_integer()),
        within_8_days=kwargs.get("within_8_days", an_integer()),
        beyond_8_days=kwargs.get("beyond_8_days", an_integer()),
    )
def test_returns_failed_transfer_count():
    transfer_count = an_integer(7, 10)
    failed_transfer_count = an_integer(2, 4)
    transfers = build_transfers(transfer_count=transfer_count,
                                failed_transfer_count=failed_transfer_count)
    national_metrics = calculate_national_metrics(transfers)
    assert national_metrics.failed_transfer_count == failed_transfer_count
def test_returns_integrated_transfer_count():
    transfer_count = an_integer(7, 10)
    integrated_transfer_count = an_integer(2, 4)
    transfers = build_transfers(
        transfer_count=transfer_count,
        integrated_transfer_count=integrated_transfer_count)
    national_metrics = calculate_national_metrics(transfers)
    assert national_metrics.integrated.transfer_count == integrated_transfer_count
def build_practice_metrics(**kwargs):
    return PracticeMetrics(
        ods_code=kwargs.get("ods_code", a_string(6)),
        name=kwargs.get("name", a_string()),
        integrated=IntegratedPracticeMetrics(
            transfer_count=kwargs.get("transfer_count", an_integer()),
            within_3_days=kwargs.get("within_3_days", an_integer()),
            within_8_days=kwargs.get("within_8_days", an_integer()),
            beyond_8_days=kwargs.get("beyond_8_days", an_integer()),
        ),
    )
Beispiel #5
0
def test_calculates_paper_fallback_count_given_all_transfers_within_sla():
    national_metrics = NationalMetrics(
        initiated_transfer_count=2,
        pending_transfer_count=an_integer(),
        failed_transfer_count=an_integer(),
        integrated=IntegratedMetrics(
            transfer_count=an_integer(),
            within_3_days=1,
            within_8_days=1,
            beyond_8_days=an_integer(),
        ),
    )
    expected_paper_fallback_count = 0

    assert national_metrics.calculate_paper_fallback() == expected_paper_fallback_count
Beispiel #6
0
def test_calculates_paper_fallback_count_given_unsuccessful_and_late_integrations():
    national_metrics = NationalMetrics(
        initiated_transfer_count=5,
        pending_transfer_count=an_integer(),
        failed_transfer_count=an_integer(),
        integrated=IntegratedMetrics(
            transfer_count=an_integer(),
            within_3_days=1,
            within_8_days=0,
            beyond_8_days=an_integer(),
        ),
    )
    expected_paper_fallback_count = 4

    assert national_metrics.calculate_paper_fallback() == expected_paper_fallback_count
Beispiel #7
0
def test_has_integrated_transfer_count():
    expected_integrated_transfer_count = an_integer(2, 7)
    national_metrics = _build_national_metrics(
        integrated_transfer_count=expected_integrated_transfer_count)
    actual = construct_national_metrics(national_metrics, a_year, a_month)

    assert actual.metrics[
        0].integrated.transfer_count == expected_integrated_transfer_count
Beispiel #8
0
def test_has_pending_transfer_count():
    expected_pending_transfer_count = an_integer(2, 6)
    national_metrics = _build_national_metrics(
        pending_transfer_count=expected_pending_transfer_count)
    actual = construct_national_metrics(national_metrics, a_year, a_month)

    assert actual.metrics[
        0].pending.transfer_count == expected_pending_transfer_count
def test_returns_integrated_transfer_count_defaults_given_no_successful_transfers(
):
    transfer_count = an_integer(2, 10)
    transfers = build_transfers(transfer_count=transfer_count)
    national_metrics = calculate_national_metrics(transfers)
    assert national_metrics.integrated.transfer_count == 0
    assert national_metrics.integrated.within_3_days == 0
    assert national_metrics.integrated.within_8_days == 0
    assert national_metrics.integrated.beyond_8_days == 0
Beispiel #10
0
def _build_national_metrics(**kwargs) -> NationalMetrics:
    within_3_days = kwargs.get("within_3_days", an_integer())
    within_8_days = kwargs.get("within_8_days", an_integer())
    beyond_8_days = kwargs.get("beyond_8_days", an_integer())
    summed_transfer_count = within_3_days + within_8_days + beyond_8_days

    return NationalMetrics(
        initiated_transfer_count=kwargs.get("initiated_transfer_count",
                                            summed_transfer_count),
        pending_transfer_count=kwargs.get("pending_transfer_count",
                                          an_integer()),
        failed_transfer_count=kwargs.get("failed_transfer_count",
                                         an_integer()),
        integrated=IntegratedMetrics(
            transfer_count=kwargs.get("integrated_transfer_count",
                                      summed_transfer_count),
            within_3_days=within_3_days,
            within_8_days=within_8_days,
            beyond_8_days=beyond_8_days,
        ),
    )
def build_transfers(**kwargs) -> List[Transfer]:
    transfer_count = kwargs.get("transfer_count", an_integer(2, 7))
    integrated_transfer_count = kwargs.get("integrated_transfer_count", 0)
    failed_transfer_count = kwargs.get("failed_transfer_count", 0)
    sla_duration = kwargs.get("sla_duration", a_duration())
    transfers: List[Transfer] = []
    transfers.extend((build_transfer() for _ in range(transfer_count)))
    transfers.extend(
        (
            an_integrated_transfer(sla_duration=sla_duration)
            for _ in range(integrated_transfer_count)
        )
    )
    transfers.extend((a_failed_transfer() for _ in range(failed_transfer_count)))
    return transfers
Beispiel #12
0
def multiple_sender_acknowledgements(**kwargs) -> List[Message]:
    """
    The GP2GP request is acknowledged by the sender, not with the usual single acknowledgement,
    but twice by two separate messages.
    """
    error_codes = kwargs.get("error_codes", [None] * an_integer(2, 4))

    conversation_id = a_string()

    test_case = GP2GPTestCase(conversation_id=conversation_id).with_request()

    for code in error_codes:
        test_case = test_case.with_sender_acknowledgement(
            message_ref=conversation_id, error_code=code)

    return test_case.build()
def test_returns_integrated_transfer_count_by_sla_duration(
        sla_duration, expected):
    transfer_count = an_integer(7, 10)
    integrated_transfer_count = 2
    transfers = build_transfers(
        transfer_count=transfer_count,
        integrated_transfer_count=integrated_transfer_count,
        sla_duration=sla_duration,
    )
    national_metrics = calculate_national_metrics(transfers)
    assert national_metrics.integrated.within_3_days == expected[
        "within_3_days"]
    assert national_metrics.integrated.within_8_days == expected[
        "within_8_days"]
    assert national_metrics.integrated.beyond_8_days == expected[
        "beyond_8_days"]
def test_returns_initiated_transfer_count():
    initiated_transfer_count = an_integer(2, 10)
    transfers = build_transfers(transfer_count=initiated_transfer_count)
    national_metrics = calculate_national_metrics(transfers)
    assert national_metrics.initiated_transfer_count == initiated_transfer_count