class CurrentTimeParserTestCase(unittest.TestCase): def setUp(self): self.browser = CurrentTimeBrowser() self.parser = CurrentTimeParser() def test_that_we_get_current_month_on_login(self): current_date = self.parser.current_month(self.browser.current_page) now = datetime.datetime.now() expected_date = datetime.date(now.year, now.month, 1) self.assertEquals(expected_date, current_date) def test_that_current_date_is_previous_month_after_navigation(self): self.browser.goto_prev_month() current_date = self.parser.current_month(self.browser.current_page) now = datetime.datetime.now() expected_year = now.year expected_month = now.month - 1 if expected_month < 1: expected_month = 12 expected_year = expected_year - 1 expected_date = datetime.date(expected_year, expected_month, 1) self.assertEquals(expected_date, current_date) def test_that_current_date_is_previous_year_after_navigation(self): self.browser.goto_prev_year() current_date = self.parser.current_month(self.browser.current_page) now = datetime.datetime.now() expected_date = datetime.date(now.year - 1, now.month, 1) self.assertEquals(expected_date, current_date)