Exemple #1
0
 def test_02_OneDevice0(self):
     """ Test that _create_module_refs is functional
     """
     l_xml = XmlConfigTools.find_xml_section(
         self.m_pyhouse_obj,
         'HouseDivision/EntertainmentSection/OnkyoSection')
     l_xml = l_xml.findall('Device')[0]
     l_device = EntertainmentDeviceInformation()
     # print(PrettyFormatAny.form(l_xml, 'C1-02-A - Onkyo XML'))
     l_ret = entertainmentXML().read_entertainment_device(l_xml, l_device)
     # print(PrettyFormatAny.form(l_ret, 'C1-02-B - Onkyo Device'))
     self.assertEqual(l_ret.Name, TESTING_ONKYO_DEVICE_NAME_0)
     self.assertEqual(str(l_ret.Active), TESTING_ONKYO_DEVICE_ACTIVE_0)
     self.assertEqual(str(l_ret.Key), TESTING_ONKYO_DEVICE_KEY_0)
     self.assertEqual(str(l_ret.UUID), TESTING_ONKYO_DEVICE_UUID_0)
     self.assertEqual(l_ret.Comment, TESTING_ONKYO_DEVICE_COMMENT_0)
     self.assertEqual(l_ret.CommandSet, TESTING_ONKYO_DEVICE_COMMAND_SET_0)
     self.assertEqual(l_ret.Host, TESTING_ONKYO_DEVICE_HOST_0)
     self.assertEqual(convert.long_to_str(l_ret.IPv4),
                      TESTING_ONKYO_DEVICE_IPV4_0)
     self.assertEqual(
         convert.long_to_str(l_ret.IPv6).lower(),
         TESTING_ONKYO_DEVICE_IPV6_0.lower())
     self.assertEqual(l_ret.Model, TESTING_ONKYO_DEVICE_MODEL_0)
     self.assertEqual(str(l_ret.Port), TESTING_ONKYO_DEVICE_PORT_0)
     self.assertEqual(l_ret.RoomName, TESTING_ONKYO_DEVICE_ROOM_NAME_0)
     self.assertEqual(l_ret.RoomUUID, TESTING_ONKYO_DEVICE_ROOM_UUID_0)
     self.assertEqual(l_ret.Type, TESTING_ONKYO_DEVICE_TYPE_0)
     self.assertEqual(str(l_ret.Volume), TESTING_ONKYO_DEVICE_VOLUME_0)
Exemple #2
0
 def test_02_OneDevice(self):
     """  Read the first Pandora device.
     """
     l_obj = pandoraXml._read_device(self.m_xml_pandora)
     # print(PrettyFormatAny.form(l_obj, 'C1-02-B - One Device'))
     self.assertEqual(l_obj.Name, TESTING_PANDORA_DEVICE_NAME_0)
     self.assertEqual(str(l_obj.Key), TESTING_PANDORA_DEVICE_KEY_0)
     self.assertEqual(str(l_obj.Active), TESTING_PANDORA_DEVICE_ACTIVE_0)
     # .
     self.assertEqual(convert.long_to_str(l_obj.Host), TESTING_PANDORA_DEVICE_HOST_0)
Exemple #3
0
 def test_03_Device1(self):
     """ Read the xml and fill in the first room's dict
     """
     l_obj = pioneerXml._read_device(self.m_xml.pioneer_sect[1])
     # print(PrettyFormatAny.form(l_obj, 'B1-03-A - One Device'))
     self.assertEqual(l_obj.Name, TESTING_PIONEER_DEVICE_NAME_1)
     self.assertEqual(str(l_obj.Key), TESTING_PIONEER_DEVICE_KEY_1)
     self.assertEqual(str(l_obj.Active), TESTING_PIONEER_DEVICE_ACTIVE_1)
     self.assertEqual(l_obj.UUID, TESTING_PIONEER_DEVICE_UUID_1)
     # .
     self.assertEqual(convert.long_to_str(l_obj.IPv4), TESTING_PIONEER_DEVICE_IPV4_1)
     self.assertEqual(str(l_obj.Port), TESTING_PIONEER_DEVICE_PORT_1)
Exemple #4
0
 def test_01_Device(self):
     """ Read the xml and fill in the first room's dict
     """
     l_obj = samsungXml._read_device(self.m_xml.samsung_sect.find('Device'))
     print(PrettyFormatAny.form(l_obj, 'C1-01-A - Device'))
     self.assertEqual(l_obj.Name, TESTING_SAMSUNG_DEVICE_NAME_0)
     self.assertEqual(str(l_obj.Key), TESTING_SAMSUNG_DEVICE_KEY_0)
     self.assertEqual(str(l_obj.Active), TESTING_SAMSUNG_DEVICE_ACTIVE_0)
     self.assertEqual(l_obj.UUID, TESTING_SAMSUNG_DEVICE_UUID_0)
     #
     self.assertEqual(convert.long_to_str(l_obj.IPv4),
                      TESTING_SAMSUNG_DEVICE_IPV4_0)
     self.assertEqual(str(l_obj.Port), TESTING_SAMSUNG_DEVICE_PORT_0)
     self.assertEqual(str(l_obj.CommandSet),
                      TESTING_SAMSUNG_DEVICE_COMMAND_SET_0)
Exemple #5
0
 def _build_uri(self, p_command=b'/config'):
     l_uri = b'http://'
     try:
         l_uri += self.m_bridge_obj.IPv4Address
     except TypeError:
         l_uri += long_to_str(self.m_bridge_obj.IPv4Address).encode("utf8")
     l_uri += b'/api/'
     try:
         l_uri += self.m_bridge_obj.ApiKey
     except TypeError:
         l_uri += self.m_bridge_obj.ApiKey.encode("utf8")
     try:
         l_uri += p_command.encode("utf8")
     except:
         l_uri += p_command
     LOG.info('URI: {}'.format(l_uri))
     return l_uri
Exemple #6
0
 def test_01_Build(self):
     """ Read one entire device entry and set up the PandoraDeviceData_obj correctly.
     """
     l_obj = pandoraXml._read_device(self.m_xml_pandora)
     print(PrettyFormatAny.form(l_obj, 'C1-01-B - Base Pandora device.'))
     # Base
     self.assertEqual(str(l_obj.Name), TESTING_PANDORA_DEVICE_NAME_0)
     self.assertEqual(str(l_obj.Key), TESTING_PANDORA_DEVICE_KEY_0)
     self.assertEqual(str(l_obj.Active), TESTING_PANDORA_DEVICE_ACTIVE_0)
     self.assertEqual(str(l_obj.Comment), TESTING_PANDORA_DEVICE_COMMENT_0)
     # OnkyoDeviceData
     self.assertEqual(convert.long_to_str(l_obj.Host), TESTING_PANDORA_DEVICE_HOST_0)
     self.assertEqual(str(l_obj.ConnectionFamily), TESTING_PANDORA_CONNECTION_DEVICE_FAMILY_0_0)
     self.assertEqual(str(l_obj.ConnectionName), TESTING_PANDORA_CONNECTION_DEVICE_NAME_0_0)
     self.assertEqual(str(l_obj.InputName), TESTING_PANDORA_CONNECTION_INPUT_NAME_0_0)
     self.assertEqual(str(l_obj.InputCode), TESTING_PANDORA_CONNECTION_INPUT_CODE_0_0)
     self.assertEqual(str(l_obj.MaxPlayTime), TESTING_PANDORA_DEVICE_MAX_PLAY_TIME_0)
     self.assertEqual(str(l_obj.Volume), TESTING_PANDORA_CONNECTION_DEFAULT_VOLUME_0_0)
Exemple #7
0
 def test_02_Device0(self):
     """ Read the xml and fill in the first room's dict
     """
     l_obj = pioneerXml._read_device(self.m_xml.pioneer_sect[0])
     # print(PrettyFormatAny.form(l_obj, 'B1-02-A - One Device'))
     self.assertEqual(l_obj.Name, TESTING_PIONEER_DEVICE_NAME_0)
     self.assertEqual(str(l_obj.Key), TESTING_PIONEER_DEVICE_KEY_0)
     self.assertEqual(str(l_obj.Active), TESTING_PIONEER_DEVICE_ACTIVE_0)
     self.assertEqual(str(l_obj.UUID), TESTING_PIONEER_DEVICE_UUID_0)
     self.assertEqual(str(l_obj.Comment), TESTING_PIONEER_DEVICE_COMMENT_0)
     self.assertEqual(str(l_obj.RoomName), TESTING_PIONEER_DEVICE_ROOM_NAME_0)
     self.assertEqual(l_obj.RoomUUID, TESTING_PIONEER_DEVICE_ROOM_UUID_0)
     # .
     self.assertEqual(convert.long_to_str(l_obj.IPv4), TESTING_PIONEER_DEVICE_IPV4_0)
     self.assertEqual(str(l_obj.Port), TESTING_PIONEER_DEVICE_PORT_0)
     self.assertEqual(str(l_obj.CommandSet), TESTING_PIONEER_DEVICE_COMMAND_SET_0)
     # self.assertEqual(str(l_obj.Status), TESTING_PIONEER_DEVICE_STATUS_0)
     self.assertEqual(str(l_obj.Type), TESTING_PIONEER_DEVICE_TYPE_0)
     self.assertEqual(str(l_obj.Volume), TESTING_PIONEER_DEVICE_VOLUME_0)
 def test_01_base(self):
     """ Read one entire device entry and set up the PanasonicDeviceData_obj correctly.
     """
     l_xml = self.m_xml.entertainment_sect.find('PanasonicSection').find('Device')
     # print(PrettyFormatAny.form(l_xml, 'C1-01-A - XML Base Panasonic device.'))
     l_obj = panasonicXML._read_device(l_xml)
     # print(PrettyFormatAny.form(l_obj, 'C1-01-B - Base Panasonic device.'))
     # BaseUUID
     self.assertEqual(str(l_obj.Name), TESTING_PANASONIC_DEVICE_NAME_0)
     self.assertEqual(str(l_obj.Key), TESTING_PANASONIC_DEVICE_KEY_0)
     self.assertEqual(str(l_obj.Active), TESTING_PANASONIC_DEVICE_ACTIVE_0)
     self.assertEqual(str(l_obj.UUID), TESTING_PANASONIC_DEVICE_UUID_0)
     self.assertEqual(str(l_obj.Comment), TESTING_PANASONIC_DEVICE_COMMENT_0)
     # PanasonicDeviceData
     self.assertEqual(convert.long_to_str(l_obj.IPv4), TESTING_PANASONIC_DEVICE_IPV4_0)
     self.assertEqual(str(l_obj.Port), TESTING_PANASONIC_DEVICE_PORT_0)
     self.assertEqual(str(l_obj.RoomName), TESTING_PANASONIC_DEVICE_ROOM_NAME_0)
     self.assertEqual(str(l_obj.RoomUUID), TESTING_PANASONIC_DEVICE_ROOM_UUID_0)
     self.assertEqual(str(l_obj.Type), TESTING_PANASONIC_DEVICE_TYPE_0)
     self.assertEqual(str(l_obj.Volume), TESTING_PANASONIC_DEVICE_VOLUME_0)
Exemple #9
0
 def _build_uri(self, p_command=b'/config'):
     """
     URI: b'http://192.168.1.131/api/MBFBC-agf6rq5bsWcxLngYZoClGr2pw2oKEMLZgs/config'
     """
     l_uri = b'http://'
     try:
         l_uri += self.m_bridge_obj.IPv4Address
     except TypeError:
         l_uri += long_to_str(self.m_bridge_obj.IPv4Address).encode("utf8")
     l_uri += b'/api/'
     try:
         l_uri += self.m_bridge_obj.ApiKey
     except TypeError:
         l_uri += self.m_bridge_obj.ApiKey.encode("utf8")
     try:
         l_uri += p_command.encode("utf8")
     except:
         l_uri += p_command
     LOG.info('URI: {}'.format(l_uri))
     return l_uri
Exemple #10
0
 def test_01_base(self):
     """ Read one entire device entry and set up the PanasonicDeviceData_obj correctly.
     """
     l_xml = self.m_xml.entertainment_sect.find('PanasonicSection').find('Device')
     # print(PrettyFormatAny.form(l_xml, 'C1-01-A - XML Base Panasonic device.'))
     l_obj = panasonicXML._read_device(l_xml)
     # print(PrettyFormatAny.form(l_obj, 'C1-01-B - Base Panasonic device.'))
     # BaseUUID
     self.assertEqual(str(l_obj.Name), TESTING_PANASONIC_DEVICE_NAME_0)
     self.assertEqual(str(l_obj.Key), TESTING_PANASONIC_DEVICE_KEY_0)
     self.assertEqual(str(l_obj.Active), TESTING_PANASONIC_DEVICE_ACTIVE_0)
     self.assertEqual(str(l_obj.UUID), TESTING_PANASONIC_DEVICE_UUID_0)
     self.assertEqual(str(l_obj.Comment), TESTING_PANASONIC_DEVICE_COMMENT_0)
     # PanasonicDeviceData
     self.assertEqual(convert.long_to_str(l_obj.IPv4), TESTING_PANASONIC_DEVICE_IPV4_0)
     self.assertEqual(str(l_obj.Port), TESTING_PANASONIC_DEVICE_PORT_0)
     self.assertEqual(str(l_obj.RoomName), TESTING_PANASONIC_DEVICE_ROOM_NAME_0)
     self.assertEqual(str(l_obj.RoomUUID), TESTING_PANASONIC_DEVICE_ROOM_UUID_0)
     self.assertEqual(str(l_obj.Type), TESTING_PANASONIC_DEVICE_TYPE_0)
     self.assertEqual(str(l_obj.Volume), TESTING_PANASONIC_DEVICE_VOLUME_0)
Exemple #11
0
 def test_04_Long2Str(self):
     l_str = LONG_IPV6
     l_long = convert.long_to_str(l_str)
     # print('C1-04-A - ', l_str, l_long)
     self.assertEqual(l_long, STR_IPV6)
Exemple #12
0
 def put_ip_element(p_parent_element, p_name, p_ip):
     l_ip = convert.long_to_str(p_ip)
     PutGetXML.put_text_element(p_parent_element, p_name, l_ip)
Exemple #13
0
 def put_ip_element(p_parent_element, p_name, p_ip):
     l_ip = convert.long_to_str(p_ip)
     PutGetXML.put_text_element(p_parent_element, p_name, l_ip)