def test_2_OneLight(self): l_schedule = scheduleXml._read_one_schedule(self.m_xml.schedule) l_xml = scheduleXml._write_one_base_schedule(l_schedule) scheduleXml._write_one_light_schedule(l_schedule, l_xml) # print(PrettyFormatAny.form(l_xml, 'B2-2-A - One Light')) self.assertEqual(l_xml.attrib['Name'], TESTING_SCHEDULE_NAME_0) self.assertEqual(l_xml.attrib['Key'], TESTING_SCHEDULE_KEY_0) self.assertEqual(l_xml.attrib['Active'], TESTING_SCHEDULE_ACTIVE_0) self.assertEqual(l_xml.find('UUID').text, TESTING_SCHEDULE_UUID_0) self.assertEqual(l_xml.find('DayOfWeek').text, TESTING_SCHEDULE_DOW_0) self.assertEqual( l_xml.find('ScheduleMode').text, TESTING_SCHEDULE_MODE_0) self.assertEqual( l_xml.find('ScheduleType').text, TESTING_SCHEDULE_TYPE_0) self.assertEqual(l_xml.find('Time').text, TESTING_SCHEDULE_TIME_0) self.assertEqual(l_xml.find('Level').text, TESTING_SCHEDULE_LEVEL_0) self.assertEqual( l_xml.find('LightName').text, TESTING_SCHEDULE_LIGHT_NAME_0) self.assertEqual( l_xml.find('LightUUID').text, TESTING_SCHEDULE_LIGHT_UUID_0) self.assertEqual(l_xml.find('Rate').text, TESTING_SCHEDULE_RATE_0) self.assertEqual( l_xml.find('RoomName').text, TESTING_SCHEDULE_ROOM_NAME_0) self.assertEqual( l_xml.find('RoomUUID').text, TESTING_SCHEDULE_ROOM_UUID_0)
def test_4_AllSchedules(self): l_schedules = scheduleXml.read_schedules_xml(self.m_pyhouse_obj) l_xml, l_count = scheduleXml.write_schedules_xml(l_schedules) # print(PrettyFormatAny.form(l_xml, 'B2-4-A - All Interfaces')) self.assertEqual(l_count, len(l_schedules)) self.assertEqual(l_xml[0].attrib['Name'], TESTING_SCHEDULE_NAME_0) self.assertEqual(l_xml[0][1].text, TESTING_SCHEDULE_DOW_0) self.assertEqual(l_xml[1].attrib['Name'], TESTING_SCHEDULE_NAME_1) self.assertEqual(l_xml[1][1].text, TESTING_SCHEDULE_DOW_1) self.assertEqual(l_xml[2].attrib['Name'], TESTING_SCHEDULE_NAME_2) self.assertEqual(l_xml[2][1].text, TESTING_SCHEDULE_DOW_2) self.assertEqual(l_xml[3].attrib['Name'], TESTING_SCHEDULE_NAME_3) self.assertEqual(l_xml[3][1].text, TESTING_SCHEDULE_DOW_3)
def test_1_OneBase(self): l_schedule = scheduleXml._read_one_schedule(self.m_xml.schedule) l_xml = scheduleXml._write_one_base_schedule(l_schedule) # print(PrettyFormatAny.form(l_xml, 'B2-1-A - One Interface')) self.assertEqual(l_xml.attrib['Name'], TESTING_SCHEDULE_NAME_0) self.assertEqual(l_xml.attrib['Key'], TESTING_SCHEDULE_KEY_0) self.assertEqual(l_xml.attrib['Active'], TESTING_SCHEDULE_ACTIVE_0) self.assertEqual(l_xml.find('UUID').text, TESTING_SCHEDULE_UUID_0) self.assertEqual(l_xml.find('DayOfWeek').text, TESTING_SCHEDULE_DOW_0) self.assertEqual( l_xml.find('ScheduleMode').text, TESTING_SCHEDULE_MODE_0) self.assertEqual( l_xml.find('ScheduleType').text, TESTING_SCHEDULE_TYPE_0) self.assertEqual(l_xml.find('Time').text, TESTING_SCHEDULE_TIME_0)
def LoadXml(self, p_pyhouse_obj): """ Load the Schedule xml info. """ l_schedules = scheduleXml.read_schedules_xml(p_pyhouse_obj) p_pyhouse_obj.House.Schedules = l_schedules LOG.info('Loaded {} Schedules XML'.format(len(l_schedules))) return l_schedules # for testing
def LoadXml(self, p_pyhouse_obj): """ Load the Schedule xml info. """ l_schedules = scheduleXml.read_schedules_xml(p_pyhouse_obj) self.m_pyhouse_obj.House.Schedules = l_schedules LOG.info('Loaded {} Schedules XML'.format(len(l_schedules))) return l_schedules # for testing
def test_4_AllSchedules(self): l_schedules = scheduleXml.read_schedules_xml(self.m_pyhouse_obj) # print(PrettyFormatAny.form(l_schedules, 'B1-4-A - Schedules')) # print(PrettyFormatAny.form(l_schedules[0], 'Schedules')) # print(PrettyFormatAny.form(l_schedules[1], 'Schedules')) # print(PrettyFormatAny.form(l_schedules[2], 'Schedules')) # print(PrettyFormatAny.form(l_schedules[3], 'Schedules')) self.assertEqual(len(l_schedules), 4)
def test_01_OneBase(self): """ Read in the xml file and fill in x """ l_schedule_obj = scheduleXml._read_one_base_schedule(self.m_xml.schedule) self.assertEqual(l_schedule_obj.Name, 'Evening 1') self.assertEqual(l_schedule_obj.Key, 0, 'No Key') self.assertEqual(l_schedule_obj.Mode, 0, 'No Mode') self.assertEqual(l_schedule_obj.Mode, 0, 'No Mode')
def setUp(self, p_root): self.m_pyhouse_obj = SetupPyHouseObj().BuildPyHouseObj(p_root) self.m_pyhouse_obj.House.Location.RiseSet = Mock.RiseSet() self.m_xml = SetupPyHouseObj().BuildXml(p_root) self.m_api = scheduleAPI(self.m_pyhouse_obj) self.m_schedules = scheduleXml.read_schedules_xml(self.m_pyhouse_obj) self.m_pyhouse_obj.House.Schedule = self.m_schedules self.m_schedule_obj = self.m_schedules[0] twisted.internet.base.DelayedCall.debug = True self.m_pyhouse_obj.House.FamilyData = familyAPI(self.m_pyhouse_obj).LoadFamilyTesting()
def test_2_OneLight(self): l_obj = scheduleXml._read_one_lighting_schedule(self.m_xml.schedule) # print(PrettyFormatAny.form(l_obj, 'B1-2-A - One Light')) self.assertEqual(l_obj.Name, TESTING_SCHEDULE_NAME_0) self.assertEqual(str(l_obj.Key), TESTING_SCHEDULE_KEY_0) self.assertEqual(str(l_obj.Active), TESTING_SCHEDULE_ACTIVE_0) self.assertEqual(l_obj.UUID, TESTING_SCHEDULE_UUID_0) # self.assertEqual(str(l_obj.Level), TESTING_SCHEDULE_LEVEL_0) self.assertEqual(l_obj.LightName, TESTING_SCHEDULE_LIGHT_NAME_0) self.assertEqual(l_obj.LightUUID, TESTING_SCHEDULE_LIGHT_UUID_0) self.assertEqual(str(l_obj.Rate), TESTING_SCHEDULE_RATE_0) self.assertEqual(l_obj.RoomName, TESTING_SCHEDULE_ROOM_NAME_0) self.assertEqual(l_obj.RoomUUID, TESTING_SCHEDULE_ROOM_UUID_0)
def test_1_OneBase(self): """ Read in the xml file and fill in x """ l_obj = scheduleXml._read_one_base_schedule(self.m_xml.schedule) # print(PrettyFormatAny.form(l_obj, 'B1-1-A - OneBase')) self.assertEqual(l_obj.Name, TESTING_SCHEDULE_NAME_0) self.assertEqual(str(l_obj.Key), TESTING_SCHEDULE_KEY_0) self.assertEqual(str(l_obj.Active), TESTING_SCHEDULE_ACTIVE_0) self.assertEqual(l_obj.UUID, TESTING_SCHEDULE_UUID_0) # self.assertEqual(str(l_obj.DOW), TESTING_SCHEDULE_DOW_0) self.assertEqual(l_obj.ScheduleType, TESTING_SCHEDULE_TYPE_0) self.assertEqual(l_obj.ScheduleMode, TESTING_SCHEDULE_MODE_0) self.assertEqual(l_obj.Time, TESTING_SCHEDULE_TIME_0)
def setUp(self): SetupMixin.setUp(self, ET.fromstring(XML_LONG)) self.m_pyhouse_obj.House.Schedules = scheduleXml.read_schedules_xml(self.m_pyhouse_obj) self.m_pyhouse_obj.APIs.Computer.MqttAPI = mqttAPI(self.m_pyhouse_obj)
def test_02_OneLight(self): l_schedule = scheduleXml._read_one_schedule(self.m_xml.schedule) l_xml = scheduleXml._write_one_base_schedule(l_schedule) scheduleXml._write_one_light_schedule(l_schedule, l_xml)
def test_3_OneSchedule(self): l_schedule = scheduleXml._read_one_schedule(self.m_xml.schedule) l_xml = scheduleXml._write_one_schedule(l_schedule) # print(PrettyFormatAny.form(l_xml, 'B2-3-A - One Schedule')) self.assertEqual(l_xml.attrib['Name'], TESTING_SCHEDULE_NAME_0)
def test_03_OneSchedule(self): l_schedule = scheduleXml._read_one_schedule(self.m_xml.schedule) l_xml = scheduleXml._write_one_schedule(l_schedule)
def test_04_AllSchedules(self): l_schedules = scheduleXml.read_schedules_xml(self.m_pyhouse_obj) l_xml = scheduleXml.write_schedules_xml(l_schedules)
def test_02_OneLight(self): # l_schedule_obj = scheduleXml._read_one_base_schedule(self.m_xml.schedule) l_light = scheduleXml._read_one_lighting_schedule(self.m_xml.schedule) self.assertEqual(l_light.LightName, 'lr_cans') self.assertEqual(l_light.Rate, 0) self.assertEqual(l_light.RoomName, 'Living Room')
def test_01_OneBase(self): l_schedule = scheduleXml._read_one_schedule(self.m_xml.schedule) l_xml = scheduleXml._write_one_base_schedule(l_schedule)
def SaveXml(self, p_xml): l_xml, l_count = scheduleXml.write_schedules_xml(self.m_pyhouse_obj.House.Schedules) p_xml.append(l_xml) LOG.info('Saved {} Schedules XML.'.format(l_count)) return l_xml # for testing
def SaveXml(self, p_xml): l_xml, l_count = scheduleXml.write_schedules_xml( self.m_pyhouse_obj.House.Schedules) p_xml.append(l_xml) LOG.info('Saved {} Schedules XML.'.format(l_count)) return l_xml # for testing
def test_03_OneSchedule(self): l_sched = scheduleXml._read_one_schedule(self.m_xml.schedule) self.assertEqual(l_sched.Name, 'Evening 1') self.assertEqual(l_sched.LightName, 'lr_cans') self.assertEqual(l_sched.RoomName, 'Living Room')
def setUp(self): SetupMixin.setUp(self, ET.fromstring(XML_LONG)) self.m_pyhouse_obj.House.Schedules = scheduleXml.read_schedules_xml(self.m_pyhouse_obj) self.m_pyhouse_obj.APIs.Computer.MqttAPI = mqttAPI(self.m_pyhouse_obj) twisted.internet.base.DelayedCall.debug = True
def test_3_OneSchedule(self): l_sched = scheduleXml._read_one_schedule(self.m_xml.schedule) # print(PrettyFormatAny.form(l_sched, 'B1-3-A - One Schedule')) self.assertEqual(l_sched.Name, 'Evening 1') self.assertEqual(l_sched.LightName, TESTING_LIGHT_NAME_0) self.assertEqual(l_sched.RoomName, TESTING_SCHEDULE_ROOM_NAME_0)
def test_04_AllSchedules(self): l_schedules = scheduleXml.read_schedules_xml(self.m_pyhouse_obj) self.assertEqual(len(l_schedules), 4)