コード例 #1
0
def test_loop_start_dates_invalid_final_greater_than_max():
    test_max_date = pd.to_datetime('2019-08-31T00:00:00.000Z')
    invalid_initial_date = '2019-07-31'
    invalid_final_date = '2019-09-30'
    with pytest.raises(ValueError):
        get_transform_data.loop_start_dates(
            test_max_date, invalid_initial_date, invalid_final_date)
コード例 #2
0
def test_loop_start_dates():
    test_max_date = pd.to_datetime('2019-08-31T00:00:00.000Z')
    invalid_initial_date = '2016-12-31'
    invalid_final_date = '2017-12-01'
    # Depending on the version of pandas, the data type of the datetime object
    # can vary between 'datetime64[ns, UTC]' and 'datetime64[ns]'
    utc_tz = False
    if test_max_date.tzinfo:
        utc_tz = True
    expected = {'initial_date': pd.to_datetime('2017-12-31', utc=utc_tz),
                'final_date': pd.to_datetime('2018-12-01', utc=utc_tz)}
    assert get_transform_data.loop_start_dates(
        test_max_date, invalid_initial_date, invalid_final_date) == expected