def test_02_1_Day(self): """Date will be tomorrow """ self.m_schedule_obj.DOW = DOW_THURSDAY l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) self.assertEqual(l_days, 1) self.m_schedule_obj.DOW = 127 - DOW_WEDNESDAY l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) self.assertEqual(l_days, 1)
def test_01_0_Days(self): """Date is in DOW """ self.m_schedule_obj.DOW = 127 l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) self.assertEqual(l_days, 0) self.m_schedule_obj.DOW = DOW_WEDNESDAY l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) self.assertEqual(l_days, 0)
def test_02_1_Day(self): """Date will be tomorrow """ self.m_schedule_obj.DOW = DOW_THURSDAY l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) # print(PrettyFormatAny.form(l_days, 'B1-02-A - Days')) self.assertEqual(l_days, 1) self.m_schedule_obj.DOW = 127 - DOW_WEDNESDAY l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) self.assertEqual(l_days, 1)
def test_01_0_Days(self): """Date is in DOW """ self.m_schedule_obj.DOW = 127 # All 7 days in a bit mask l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) # print(PrettyFormatAny.form(l_days, 'B1-01-A - Days')) self.assertEqual(l_days, 0) self.m_schedule_obj.DOW = DOW_WEDNESDAY l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) self.assertEqual(l_days, 0)
def test_08_7_PlusDays(self): """Date will be Never """ self.m_schedule_obj.DOW = 0 l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) # print(PrettyFormatAny.form(l_days, 'B1-08-A - Days')) self.assertEqual(l_days, 10)
def test_07_6_Days(self): """Date will be in 6 days """ self.m_schedule_obj.DOW = DOW_TUESDAY l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) # print(PrettyFormatAny.form(l_days, 'B1-07-A - Days')) self.assertEqual(l_days, 6)
def test_03_ToGo(self): """ Test next day 45 mins from now """ self.m_schedule_obj.DOW = 1 + 2 + 4 + 8 + 16 + 32 + 64 l_riseset = Mock.RiseSet() self.m_schedule_obj.Time = '00:15' l_now = datetime.datetime(2015, 6, 6, 23, 30, 0) l_minutes = SchedTime.extract_time_to_go(self.m_pyhouse_obj, self.m_schedule_obj, l_now, l_riseset) self.assertEqual(l_minutes, 45 * 60)
def test_02_ToGo(self): """Date is """ self.m_schedule_obj.DOW = 1 + 2 + 4 + 8 + 16 + 32 + 64 l_riseset = Mock.RiseSet() self.m_schedule_obj.Time = '01:02' l_time = datetime.datetime(2015, 6, 6, 0, 2, 0) l_minutes = SchedTime.extract_time_to_go(self.m_pyhouse_obj, self.m_schedule_obj, l_time, l_riseset) self.assertEqual(l_minutes, 3600) # self.m_schedule_obj.Time = 'dawn' # 7:12:54 l_time = datetime.datetime(2015, 6, 6, 1, 2, 0) l_minutes = SchedTime.extract_time_to_go(self.m_pyhouse_obj, self.m_schedule_obj, l_time, l_riseset) self.assertEqual(l_minutes, (6 * 60 + 10) * 60) # self.m_schedule_obj.DOW = 1 + 2 + 4 + 8 + 16 + 0 + 64 # Not today l_riseset = Mock.RiseSet() self.m_schedule_obj.Time = '03:02' l_time = datetime.datetime(2015, 6, 6, 3, 2, 0) l_minutes = SchedTime.extract_time_to_go(self.m_pyhouse_obj, self.m_schedule_obj, l_time, l_riseset) self.assertEqual(l_minutes, (0 * 60) + 1440 * 60)
def test_01_BuildSched(self): """ Testing the build of a schedule list. We should end up with 2 schedules in the list. """ l_riseset = Mock.RiseSet() l_delay, l_list = scheduleUtility.find_next_scheduled_events(self.m_pyhouse_obj, T_NOW) l_now_sec = scheduleUtility.to_mins(T_NOW) * 60 l_obj = self.m_pyhouse_obj.House.Schedules[l_list[0]] l_sched_sec = SchedTime._extract_schedule_time(l_obj, l_riseset) * 60 # print('Delay: {}; List: {}; Now: {}; Sched: {}'.format(l_delay, l_list, l_now_sec, l_sched_sec)) self.assertEqual(len(l_list), 2) self.assertEqual(l_delay, l_sched_sec - l_now_sec) self.assertEqual(l_list[0], 0) self.assertEqual(l_list[1], 1)
def test_01_TillSched(self): """ Extract Minutes from Midnight to schedule time """ l_riseset = Mock.RiseSet() self.m_schedule_obj.Time = '01:02' l_minutes = SchedTime._extract_schedule_time(self.m_schedule_obj, l_riseset) self.assertEqual(l_minutes, 1 * 60 + 2) # self.m_schedule_obj.Time = 'dusk' l_minutes = SchedTime._extract_schedule_time(self.m_schedule_obj, l_riseset) self.assertEqual(l_minutes, 20 * 60 + 19) # self.m_schedule_obj.Time = 'sunrise' l_minutes = SchedTime._extract_schedule_time(self.m_schedule_obj, l_riseset) self.assertEqual(l_minutes, 7 * 60 + 12) # self.m_schedule_obj.Time = 'sunset + 0:10' l_minutes = SchedTime._extract_schedule_time(self.m_schedule_obj, l_riseset) self.assertEqual(l_minutes, 20 * 60 + 19 + 10) # self.m_schedule_obj.Time = 'sunset - 0:17' l_minutes = SchedTime._extract_schedule_time(self.m_schedule_obj, l_riseset) self.assertEqual(l_minutes, 20 * 60 + 19 - 17)
def test_08_7_PlusDays(self): """Date will be Never """ self.m_schedule_obj.DOW = 0 l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) self.assertEqual(l_days, 10)
def test_07_6_Days(self): """Date will be in 6 days """ self.m_schedule_obj.DOW = DOW_TUESDAY l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) self.assertEqual(l_days, 6)
def test_06_5_Days(self): """Date will be in 5 days """ self.m_schedule_obj.DOW = DOW_MONDAY l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) self.assertEqual(l_days, 5)
def test_04_3_Days(self): """Date will be in 3 days """ self.m_schedule_obj.DOW = DOW_SATURDAY l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) self.assertEqual(l_days, 3)
def test_03_2_Days(self): """Date will be in 2 days """ self.m_schedule_obj.DOW = DOW_FRIDAY l_days = SchedTime._extract_days(self.m_schedule_obj, T_WEDNESDAY) self.assertEqual(l_days, 2)