def test_secretary_tool_updates_only_matured_reports(
    test_perf_alert, create_record, record_from_mature_report
):
    # create new report with records
    create_record(test_perf_alert)

    assert BackfillRecord.objects.count() == 2
    assert BackfillRecord.objects.filter(status=BackfillRecord.PRELIMINARY).count() == 2

    SecretaryTool.mark_reports_for_backfill()
    assert BackfillRecord.objects.filter(status=BackfillRecord.PRELIMINARY).count() == 1
Example #2
0
def test_secretary_tool_updates_only_matured_reports(test_perf_alert,
                                                     test_perf_alert_2,
                                                     create_record):
    # create new report with records
    create_record(test_perf_alert)
    # create mature report with records
    date_past = datetime.utcnow() - timedelta(hours=5)
    with patch('django.utils.timezone.now', Mock(return_value=date_past)):
        create_record(test_perf_alert_2)

    assert BackfillRecord.objects.count() == 2
    assert BackfillRecord.objects.filter(
        status=BackfillRecord.PRELIMINARY).count() == 2

    SecretaryTool.mark_reports_for_backfill()
    assert BackfillRecord.objects.filter(
        status=BackfillRecord.PRELIMINARY).count() == 1