Beispiel #1
0
def test_create_fiscal_year_list():
    assert fyh.create_fiscal_year_list(
        start_year=2004, end_year=2008) == [2004, 2005, 2006, 2007]
    years = [
        x for x in range(2000,
                         FiscalDate.today().next_fiscal_year.fiscal_year)
    ]
    assert fyh.create_fiscal_year_list() == years
Beispiel #2
0
def test_spending_over_time(client, monkeypatch, elasticsearch_transaction_index, mock_tas_data):
    setup_elasticsearch_test(monkeypatch, elasticsearch_transaction_index)

    data = {"group": "fiscal_year", "filters": {"tas_codes": [{"aid": "028", "main": "8006"}]}, "subawards": False}
    resp = client.post("/api/v2/search/spending_over_time", content_type="application/json", data=json.dumps(data))
    assert resp.status_code == status.HTTP_200_OK
    earliest_fiscal_year_we_care_about = datetime.strptime(settings.API_SEARCH_MIN_DATE, "%Y-%m-%d").year
    assert len(resp.data["results"]) == FiscalDate.today().fiscal_year - earliest_fiscal_year_we_care_about
Beispiel #3
0
def create_fiscal_year_list(start_year=2000, end_year=None):
    """
    return the list of fiscal year as integers
        start_year: int default 2000 FY to start at (inclusive)
        end_year: int default None: FY to end at (exclusive)
            if no end_date is provided, use the current FY
    """
    if end_year is None:
        # to return the current FY, we add 1 here for the range generator below
        end_year = FiscalDate.today().next_fiscal_year.fiscal_year

    if start_year is None or start_year >= end_year:
        raise Exception("Invalid start_year and end_year values")

    return [year for year in range(start_year, end_year)]
def test_current_fiscal_year():
    current_fiscal_year = FiscalDate.today().fiscal_year
    fiscal_year_list = fyh.create_fiscal_year_list(start_year=2010)
    assert fiscal_year_list[0] == 2010
    assert fiscal_year_list[-1] == current_fiscal_year