def test_period_defined(self): extents = Extents(local_datetime(2014, 6, 18, 11, 11, 11), period="day") self.assert_extents(extents, (2014, 6, 18, 0, 0, 0), (2014, 6, 18, 23, 59, 59)) # period can be changed extents.set_period("month") self.assert_extents(extents, (2014, 6, 1), (2014, 6, 30, 23, 59, 59))
def test_extents_to_string(self): t = local_datetime(2014, 6, 18, 11, 11, 11) t_formatted = t.__repr__() extents = Extents(t) self.assertEquals(str(extents), "Extents for undefined period around %s" % t_formatted) extents.set_period("week") self.assertEquals(str(extents), "Extents for `week` around %s" % t_formatted)
def test_period_set_invalid(self): extents = Extents(local_datetime(2014, 6, 18)) self.assertRaises(ValueError, lambda: extents.set_period("lightyear"))