コード例 #1
0
 def test_invalid_init_input(self):
     with pytest.raises(TypeError):
         DateRange()
     with pytest.raises(TypeError):
         DateRange(1, "")
     with pytest.raises(ValueError):
         DateRange(end="alice", start="bob")
コード例 #2
0
 def test_bad_period(self):
     with pytest.raises(ValueError):
         DateRange(start="2019-01-01", end="2018-12-31")
     with pytest.raises(ValueError):
         DateRange(start="2019-01-01", end="2019-12-31").end = "2018-12-31"
     with pytest.raises(ValueError):
         DateRange(start="2019-01-01",
                   end="2019-12-31").start = "2020-12-31"
コード例 #3
0
 def test_equals(self, year_2019_from_strs, year_2019_from_dates, year_2020,
                 year_2020_other):
     assert year_2019_from_strs == DateRange(end="2019-12-31",
                                             start="2019-01-01")
     assert year_2019_from_dates == DateRange(end="2019-12-31",
                                              start="2019-01-01")
     assert year_2020 != DateRange(end="2019-12-31", start="2019-01-01")
     assert year_2020 != year_2019_from_dates
     assert year_2020 != year_2019_from_strs
     assert year_2020 == year_2020_other
コード例 #4
0
    def test_run_saxony(self, calc, region_saxony):
        totals, _ = calc.run(region_saxony,
                             DateRange(start='2020-02-10', end='2020-02-10'),
                             TimeAggregation.MONTHLY, Pollutant.NO2)
        assert 0.04 * 4 <= totals.iloc[-1, 0] <= 0.05 * 4
        assert 71 <= totals.iloc[-1, 1] <= 72
        assert 71 <= totals.iloc[-1, 2] <= 72

        totals, _ = calc.run(region_saxony,
                             DateRange(start='2020-02-29', end='2020-03-01'),
                             TimeAggregation.MONTHLY, Pollutant.NO2)
        assert 0.09 * 4 <= totals.iloc[-1, 0] <= 0.1 * 4
        assert 50 <= totals.iloc[-1, 1] <= 51
        assert 50 <= totals.iloc[-1, 2] <= 51
コード例 #5
0
 def test_run_germany(self, calc, region_germany):
     totals, _ = calc.run(region_germany,
                          DateRange(start='2018-08-01', end='2018-08-31'),
                          TimeAggregation.MONTHLY, Pollutant.NO2)
     assert 22.5 * 4 <= totals.iloc[-1, 0] <= 22.6 * 4
     assert 3.49 <= totals.iloc[-1, 1] <= 3.5
     assert 3.49 <= totals.iloc[-1, 2] <= 3.5
コード例 #6
0
def period_medium():
    return DateRange("2019-01-01", "2020-01-31")
コード例 #7
0
def year_2019_from_strs():
    return DateRange("2019-01-01", "2019-12-31")
コード例 #8
0
def period_very_short():
    return DateRange("2018-10-15", "2018-10-25")
コード例 #9
0
def period_short():
    return DateRange("2020-02-01", "2020-02-29")
コード例 #10
0
def august_2018():
    return DateRange("2018-08-01", "2018-08-31")
コード例 #11
0
def year_2020_other():
    return DateRange("2020-01-01", "2020-12-31")
コード例 #12
0
def period_too_short():
    return DateRange("2100-01-01", "2100-01-31")
コード例 #13
0
def period_not_supported_other():
    return DateRange("2000-01-01", "9999-12-31")
コード例 #14
0
def period_not_supported():
    return DateRange("0001-01-01", "2019-12-31")
コード例 #15
0
def year_2019_from_dates():
    return DateRange(date.fromisoformat("2019-01-01"),
                     date.fromisoformat("2019-12-31"))
コード例 #16
0
def period_medium_other():
    return DateRange("2019-11-01", "2020-12-31")
コード例 #17
0
def period_medium_third():
    return DateRange("2020-01-01", "2020-11-15")
コード例 #18
0
def one_day():
    return DateRange("2018-08-01", "2018-08-01")
コード例 #19
0
def period_short_other():
    return DateRange("2020-02-01", "2020-02-20")
コード例 #20
0
def future_short():
    return DateRange("2030-01-15", "2030-04-30")
コード例 #21
0
def period_long():
    return DateRange("2018-10-15", "2020-02-29")
コード例 #22
0
def future_long():
    return DateRange("2030-01-15", "2042-12-31")