Ejemplo n.º 1
0
    def test_out_of_range(self):
        with pytest.raises(ValueError):
            fiscalyear.FiscalQuarter(2017, 0)

        with pytest.raises(ValueError):
            fiscalyear.FiscalQuarter(2017, 5)

        with pytest.raises(ValueError):
            fiscalyear.FiscalQuarter(0, 2)
Ejemplo n.º 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
Ejemplo n.º 3
0
 def d(self):
     return fiscalyear.FiscalQuarter(2016, 1)
Ejemplo n.º 4
0
    def test_wrong_type(self):
        with pytest.raises(TypeError):
            fiscalyear.FiscalQuarter(2017.5, 1.2)

        with pytest.raises(TypeError):
            fiscalyear.FiscalQuarter("hello", "world")
Ejemplo n.º 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.FiscalQuarter.current()
     assert current == fiscalyear.FiscalQuarter(2017, 1)
Ejemplo n.º 6
0
 def g(self):
     return fiscalyear.FiscalQuarter("2018", "1")
Ejemplo n.º 7
0
 def e(self):
     return fiscalyear.FiscalQuarter(2017, 4)
Ejemplo n.º 8
0
 def test_prev_fiscal_quarter(self, a, c):
     assert a.prev_fiscal_quarter == fiscalyear.FiscalQuarter(2017, 1)
     assert c.prev_fiscal_quarter == fiscalyear.FiscalQuarter(2017, 4)
Ejemplo n.º 9
0
 def a(self):
     return fiscalyear.FiscalQuarter(2016, 4)
Ejemplo n.º 10
0
 def test_q4(self, a):
     assert a.q4 == fiscalyear.FiscalQuarter(2016, 4)
Ejemplo n.º 11
0
 def test_q3(self, a):
     assert a.q3 == fiscalyear.FiscalQuarter(2016, 3)
Ejemplo n.º 12
0
 def test_q2(self, a):
     assert a.q2 == fiscalyear.FiscalQuarter(2016, 2)
Ejemplo n.º 13
0
 def test_q1(self, a):
     assert a.q1 == fiscalyear.FiscalQuarter(2016, 1)
Ejemplo n.º 14
0
    def test_corner_cases(self):
        # start_day does not exist in all months
        with fiscalyear.fiscal_calendar(start_month=5, start_day=31):
            # Non-leap year
            assert fiscalyear.FiscalQuarter(2019, 1).start.day == 31
            assert fiscalyear.FiscalQuarter(2019, 1).end.day == 30

            assert fiscalyear.FiscalQuarter(2019, 2).start.day == 31
            assert fiscalyear.FiscalQuarter(2019, 2).end.day == 29

            assert fiscalyear.FiscalQuarter(2019, 3).start.day == 30
            assert fiscalyear.FiscalQuarter(2019, 3).end.day == 27

            assert fiscalyear.FiscalQuarter(2019, 4).start.day == 28
            assert fiscalyear.FiscalQuarter(2019, 4).end.day == 30

            # Leap year
            assert fiscalyear.FiscalQuarter(2020, 1).start.day == 31
            assert fiscalyear.FiscalQuarter(2020, 1).end.day == 30

            assert fiscalyear.FiscalQuarter(2020, 2).start.day == 31
            assert fiscalyear.FiscalQuarter(2020, 2).end.day == 29

            assert fiscalyear.FiscalQuarter(2020, 3).start.day == 30
            assert fiscalyear.FiscalQuarter(2020, 3).end.day == 28

            assert fiscalyear.FiscalQuarter(2020, 4).start.day == 29
            assert fiscalyear.FiscalQuarter(2020, 4).end.day == 30
Ejemplo n.º 15
0
 def test_next_fiscal_quarter(self, a, c):
     assert a.next_fiscal_quarter == fiscalyear.FiscalQuarter(2017, 3)
     assert c.next_fiscal_quarter == fiscalyear.FiscalQuarter(2018, 2)
Ejemplo n.º 16
0
 def f(self):
     return fiscalyear.FiscalQuarter(2017, 1)
Ejemplo n.º 17
0
 def c(self):
     return fiscalyear.FiscalQuarter(2017, 2)
Ejemplo n.º 18
0
 def g(self):
     return fiscalyear.FiscalQuarter('2018', '1')