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
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 calculate_national_metrics_data( transfers: List[Transfer], time_range: DateTimeRange) -> NationalMetricsPresentation: national_metrics = calculate_national_metrics(transfers=transfers) return construct_national_metrics( national_metrics=national_metrics, year=time_range.start.year, month=time_range.start.month, )
def test_has_pending_percentage(): initiated_transfer_count = 4 national_metrics = _build_national_metrics( initiated_transfer_count=initiated_transfer_count, pending_transfer_count=3) expected_percentage = 75.0 actual = construct_national_metrics(national_metrics, a_year, a_month) assert actual.metrics[0].pending.transfer_percentage == expected_percentage
def test_has_failed_percentage(): initiated_transfer_count = 3 national_metrics = _build_national_metrics( initiated_transfer_count=initiated_transfer_count, failed_transfer_count=2) expected_percentage = 66.67 actual = construct_national_metrics(national_metrics, a_year, a_month) assert actual.metrics[0].failed.transfer_percentage == expected_percentage
def test_has_integrated_percentage(): initiated_transfer_count = 3 national_metrics = _build_national_metrics( initiated_transfer_count=initiated_transfer_count, integrated_transfer_count=1) expected_percentage = 33.33 actual = construct_national_metrics(national_metrics, a_year, a_month) assert actual.metrics[ 0].integrated.transfer_percentage == expected_percentage
def test_has_correct_generated_on_given_time(): expected_generated_on = datetime(year=2019, month=6, day=2, hour=23, second=42, tzinfo=tzutc()) national_metrics = _build_national_metrics() actual = construct_national_metrics(national_metrics, a_year, a_month) assert actual.generated_on == expected_generated_on
def test_has_2021_year_and_jan_month(): expected_year = 2021 expected_month = 1 national_metrics = _build_national_metrics() actual = construct_national_metrics(national_metrics, expected_year, expected_month) assert actual.metrics[0].year == expected_year assert actual.metrics[0].month == expected_month
def test_has_paper_fallback_transfer_percentage(): transfer_count = 18 national_metrics = _build_national_metrics(transfer_count=transfer_count, within_3_days=10, within_8_days=5, beyond_8_days=3) expected_percentage = 16.67 actual = construct_national_metrics(national_metrics, a_year, a_month) assert actual.metrics[ 0].paper_fallback.transfer_percentage == expected_percentage
def test_has_paper_fallback_transfer_count(): initiated_transfer_count = 10 national_metrics = _build_national_metrics( initiated_transfer_count=initiated_transfer_count, within_3_days=5, within_8_days=2, beyond_8_days=1, ) actual = construct_national_metrics(national_metrics, a_year, a_month) expected = 3 assert actual.metrics[0].paper_fallback.transfer_count == expected
def test_returns_integrated_transfer_count_by_sla_duration( national_metrics_integrated): national_metrics = _build_national_metrics( within_3_days=national_metrics_integrated["within_3_days"], within_8_days=national_metrics_integrated["within_8_days"], beyond_8_days=national_metrics_integrated["beyond_8_days"], ) actual_integrated_metrics = (construct_national_metrics( national_metrics, a_year, a_month).metrics[0].integrated) assert actual_integrated_metrics.within_3_days == national_metrics_integrated[ "within_3_days"] assert actual_integrated_metrics.within_8_days == national_metrics_integrated[ "within_8_days"] assert actual_integrated_metrics.beyond_8_days == national_metrics_integrated[ "beyond_8_days"]