Exemple #1
0
    def test_start(self, a, e):
        assert a.start == fiscalyear.FiscalYear(a.fiscal_year).start
        assert e.start == fiscalyear.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 fiscalyear.FiscalMonth(2016, 12).start == datetime.datetime(
                2017, 3, 6, 0, 0, 0)
Exemple #2
0
    def test_contains(self, a, b, c, f):
        assert b in c
        assert a not in f

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

        assert b in fiscalyear.FiscalMonth(2016, 1)
        assert b in fiscalyear.FiscalQuarter(2016, 1)
        assert b in fiscalyear.FiscalYear(2016)

        with pytest.raises(TypeError):
            "hello world" in a
Exemple #3
0
    def test_out_of_range(self):
        with pytest.raises(ValueError):
            fiscalyear.FiscalMonth(2016, 0)

        with pytest.raises(ValueError):
            fiscalyear.FiscalMonth(2016, -12)
Exemple #4
0
 def test_prev_fiscal_year(self, a, b):
     assert a == b.prev_fiscal_month
     assert a.prev_fiscal_month == fiscalyear.FiscalMonth(2015, 12)
Exemple #5
0
 def test_current(self, mocker):
     mock_today = mocker.patch.object(fiscalyear.FiscalDate, "today")
     mock_today.return_value = fiscalyear.FiscalDate(2016, 10, 1)
     current = fiscalyear.FiscalMonth.current()
     assert current == fiscalyear.FiscalMonth(2017, 1)
Exemple #6
0
    def test_wrong_type(self):
        with pytest.raises(TypeError):
            fiscalyear.FiscalMonth(2016.5)

        with pytest.raises(TypeError):
            fiscalyear.FiscalMonth("hello world")
Exemple #7
0
 def e(self):
     return fiscalyear.FiscalMonth(2016, 12)
Exemple #8
0
 def c(self):
     return fiscalyear.FiscalMonth("2016", "2")
Exemple #9
0
 def b(self):
     return fiscalyear.FiscalMonth(2016, 2)
Exemple #10
0
 def test_next_fiscal_month(self, a):
     assert a.next_fiscal_month == fiscalyear.FiscalMonth(2017, 5)
Exemple #11
0
 def test_prev_fiscal_month(self, a):
     assert a.prev_fiscal_month == fiscalyear.FiscalMonth(2017, 3)