Esempio n. 1
0
    def test_get_message(self):
        c = Cube('127.0.0.1', 62910)
        self.assertFalse(c.get_message(F_RESPONSE))

        c = Cube('127.0.0.1', 62910)
        c.parse_message(F_RESPONSE, b"ntp.homematic.com,ntp.homematic.com")
        msg = FResponse(b"ntp.homematic.com,ntp.homematic.com")
        self.assertEqual(c.get_message(F_RESPONSE), msg)
Esempio n. 2
0
File: cube.py Progetto: ercpe/pymax
	def test_get_message(self):
		c = Cube('127.0.0.1', 62910)
		self.assertFalse(c.get_message(F_RESPONSE))

		c = Cube('127.0.0.1', 62910)
		c.parse_message(F_RESPONSE, b"ntp.homematic.com,ntp.homematic.com")
		msg = FResponse(b"ntp.homematic.com,ntp.homematic.com")
		self.assertEqual(c.get_message(F_RESPONSE), msg)
Esempio n. 3
0
File: cube.py Progetto: ercpe/pymax
	def test_parse_message(self):

		for message_type, message_bytes, message_class in [
			(HELLO_RESPONSE, HelloResponseBytes, HelloResponse),
			(M_RESPONSE, MResponseBytes, MResponse),
			(CONFIGURATION_RESPONSE, CubeConfigurationBytes, ConfigurationResponse),
			(L_RESPONSE, bytearray(b"CxIrZfcSGWQ8AOsA"), LResponse),
			(F_RESPONSE, bytearray(b"ntp.homematic.com,ntp.homematic.com"), FResponse),
			(SET_RESPONSE, bytearray(b"00,0,31"), SetResponse),
		]:
			#conn = Connection((None, None), message_handler=lambda x: x)
			conn = Cube((None, None))

			conn.parse_message(message_type, message_bytes)

			self.assertEqual(len(conn.received_messages), 1)
			self.assertTrue(message_type in conn.received_messages.keys(), "Message of type %s not found in .received_messages" % message_type)
			self.assertIsInstance(conn.received_messages[message_type], message_class)
Esempio n. 4
0
    def test_parse_message(self):

        for message_type, message_bytes, message_class in [
            (HELLO_RESPONSE, HelloResponseBytes, HelloResponse),
            (M_RESPONSE, MResponseBytes, MResponse),
            (CONFIGURATION_RESPONSE, CubeConfigurationBytes,
             ConfigurationResponse),
            (L_RESPONSE, bytearray(b"CxIrZfcSGWQ8AOsA"), LResponse),
            (F_RESPONSE, bytearray(b"ntp.homematic.com,ntp.homematic.com"),
             FResponse),
            (SET_RESPONSE, bytearray(b"00,0,31"), SetResponse),
        ]:
            #conn = Connection((None, None), message_handler=lambda x: x)
            conn = Cube((None, None))

            conn.parse_message(message_type, message_bytes)

            self.assertEqual(len(conn.received_messages), 1)
            self.assertTrue(
                message_type in conn.received_messages.keys(),
                "Message of type %s not found in .received_messages" %
                message_type)
            self.assertIsInstance(conn.received_messages[message_type],
                                  message_class)