Example #1
0
    def test_current(self, monkeypatch: MonkeyPatch) -> None:
        def today() -> FiscalDate:
            return FiscalDate(2016, 10, 1)

        monkeypatch.setattr(FiscalDate, "today", today)
        current = FiscalMonth.current()
        assert current == FiscalMonth(2017, 1)
Example #2
0
    def test_start(self, a: FiscalMonth, c: FiscalMonth) -> None:
        assert a.start == FiscalYear(a.fiscal_year).start
        assert c.start == FiscalDateTime(2016, 9, 1, 0, 0, 0)

        with fiscalyear.fiscal_calendar(*US_FEDERAL):
            assert a.start == datetime.datetime(2015, 10, 1, 0, 0, 0)

        with fiscalyear.fiscal_calendar(*UK_PERSONAL):
            assert a.start == datetime.datetime(2016, 4, 6, 0, 0, 0)
            assert FiscalMonth(2016, 12).start == datetime.datetime(
                2017, 3, 6, 0, 0, 0)
Example #3
0
    def test_contains(self, a: FiscalDay, b: FiscalDay, d: FiscalDay) -> None:
        assert b in b
        assert a not in d

        assert FiscalDateTime(2015, 10, 1, 0, 0, 0) in a
        assert datetime.datetime(2015, 10, 1, 0, 0, 0) in a
        assert FiscalDate(2015, 10, 1) in a
        assert datetime.date(2015, 10, 1) in a

        assert b in FiscalMonth(2016, 1)
        assert b in FiscalQuarter(2016, 1)
        assert b in FiscalYear(2016)
Example #4
0
 def test_next_fiscal_month(self, a: FiscalDateTime) -> None:
     assert a.next_fiscal_month == FiscalMonth(2017, 5)
Example #5
0
 def test_prev_fiscal_month(self, a: FiscalDateTime) -> None:
     assert a.prev_fiscal_month == FiscalMonth(2017, 3)
Example #6
0
 def test_prev_fiscal_year(self, a: FiscalMonth, b: FiscalMonth) -> None:
     assert a == b.prev_fiscal_month
     assert a.prev_fiscal_month == FiscalMonth(2015, 12)
Example #7
0
    def test_out_of_range(self) -> None:
        with pytest.raises(ValueError):
            FiscalMonth(2016, 0)

        with pytest.raises(ValueError):
            FiscalMonth(2016, -12)
Example #8
0
 def c(self) -> FiscalMonth:
     return FiscalMonth(2016, 12)
Example #9
0
 def b(self) -> FiscalMonth:
     return FiscalMonth(2016, 2)
Example #10
0
 def a(self) -> FiscalMonth:
     return FiscalMonth(2016, 1)
Example #11
0
 def d(self) -> FiscalMonth:
     return FiscalMonth(2017, 1)