Add unittest for function first_of_month.
[chrisu/seepark.git] / web / seepark_web_tests.py
1 import datetime
2 import unittest
3 import seepark_web
4
5
6 class SeeparkWebTestCase(unittest.TestCase):
7     def test_first_of_month(self):
8         for d in [1, 8, 25, 28]:
9             date_a = datetime.date(2019, 2, d)
10             date_b = seepark_web.first_of_month(date_a, 1)
11             self.assertEqual(date_b, datetime.date(2019, 3, 1))
12
13             date_b = seepark_web.first_of_month(date_a, -1)
14             self.assertEqual(date_b, datetime.date(2019, 1, 1))
15
16             date_b = seepark_web.first_of_month(date_a, 0)
17             self.assertEqual(date_b, datetime.date(2019, 2, 1))