def setUp (self): self.hholds = [] self.users = [] self.hmates = [] self.chores = [] self.assigns = [] self.invites = [] # Households self.hholds.append(Household.objects.create(name="100 Rolling Green", timezone_id=get_id_by_tz("US/Eastern"))) # Housemates/Users hmates_tuple = ( ("Jake", "Boxer", self.hholds[0], "jboxer",), ("Alicia", "Wood", self.hholds[0], "akwood01",), ("Evelyn", "Peppas", self.hholds[0], "epeppas01", False,), ("Trenton", "Bollinger", self.hholds[0], "tbolling01", False), ("Home", "Less", None, "homeless01",) ) for hmate in hmates_tuple: self.create_hmate(*hmate) # Chores chores_tuple = ( ("Kitchen", self.hholds[0], 1), ("Downstairs", self.hholds[0], 1), ("Vacuuming", self.hholds[0], 3), ("Bathrooms", self.hholds[0], 7), ) for chore in chores_tuple: self.create_chore(chore[0], chore[1], days=chore[2])
def test_get_hholds_by_local_hr (self): pacific = get_id_by_tz("US/Pacific") mountain = get_id_by_tz("US/Mountain") central = get_id_by_tz("US/Central") eastern = get_id_by_tz("US/Eastern") e = Household.objects.create(name="East", timezone_id=eastern) c = Household.objects.create(name="Cent", timezone_id=central) m = Household.objects.create(name="Moun", timezone_id=mountain) p = Household.objects.create(name="Paci", timezone_id=pacific) # assume this is in UTC: 12/21/2009 at 4:00AM dt = datetime(2009, 12, 21, 4, 0) # at this time, there should be no households that are midnight, since # it's out of the US hholds = get_hholds_by_local_hr(0, dt) self.failUnlessEqual(len(hholds), 0) # adding an hr should put us in EST, so we'll get the two EST hholds dt += timedelta(hours=1) hholds = get_hholds_by_local_hr(0, dt) self.failUnlessEqual(len(hholds), 2) self._check_tz_of_hholds(hholds, eastern) # adding an hr should put us in CST, so we'll get the CST hhold dt += timedelta(hours=1) hholds = get_hholds_by_local_hr(0, dt) self.failUnlessEqual(len(hholds), 1) self._check_tz_of_hholds(hholds, central) # adding an hr should put us in MST, so we'll get the MST hhold dt += timedelta(hours=1) hholds = get_hholds_by_local_hr(0, dt) self.failUnlessEqual(len(hholds), 1) self._check_tz_of_hholds(hholds, mountain) # adding an hr should put us in PST, so we'll get the PST hhold dt += timedelta(hours=1) hholds = get_hholds_by_local_hr(0, dt) self.failUnlessEqual(len(hholds), 1) self._check_tz_of_hholds(hholds, pacific)