Example #1
0
    def test_group_membership(self):
        msg_data = b'\x01\x01\x00\x04\x124\x10\x00'
        r = responses.R8062(msg_data, 255)
        self.zigate.interpret_response(r)
        self.assertDictEqual(self.zigate.groups,
                             {})

        msg_data = b'\x01\x01\x00\x04\x124\x10\x01\x98v'
        r = responses.R8062(msg_data, 255)
        self.zigate.interpret_response(r)
        self.assertDictEqual(self.zigate.groups,
                             {'9876': {('1234', 1)}})

        msg_data = b'\x01\x01\x00\x04\x124\x10\x02\x98v4V'
        r = responses.R8062(msg_data, 255)
        self.zigate.interpret_response(r)
        self.assertDictEqual(self.zigate.groups,
                             {'9876': {('1234', 1)},
                              '3456': {('1234', 1)}})

        msg_data = b'\x01\x01\x00\x04\x124\x10\x014V'
        r = responses.R8062(msg_data, 255)
        self.zigate.interpret_response(r)
        self.assertDictEqual(self.zigate.groups,
                             {'3456': {('1234', 1)}})
Example #2
0
    def test_groups(self):
        self.zigate.add_group('1234', 1, '4567')
        self.assertDictEqual(self.zigate.groups, {
            '4567': {('1234', 1)},
        })
        msg_data = b'\x01\x01\x00\x04\x124\x10\x02\x98v4V'
        r = responses.R8062(msg_data, 255)
        self.zigate.interpret_response(r)
        self.assertDictEqual(self.zigate.groups, {
            '9876': {('1234', 1)},
            '3456': {('1234', 1)}
        })
        self.zigate.add_group('1234', 1, '4567')
        self.zigate.add_group('0123', 1, '4567')
        self.assertDictEqual(
            self.zigate.groups, {
                '9876': {('1234', 1)},
                '3456': {('1234', 1)},
                '4567': {('1234', 1), ('0123', 1)},
            })
        self.zigate.remove_group('1234', 1, '9876')
        self.assertDictEqual(self.zigate.groups, {
            '3456': {('1234', 1)},
            '4567': {('1234', 1), ('0123', 1)},
        })
        self.zigate.remove_group('1234', 1)
        self.assertDictEqual(self.zigate.groups, {
            '4567': {('0123', 1)},
        })

        self.assertDictEqual(self.zigate.get_group_for_addr('0123'),
                             {1: ['4567']})
Example #3
0
    def test_response_8062(self):
        msg_data = b'\x01\x01\x00\x04\x124\x10\x01\x98v'
        r = responses.R8062(msg_data, 255)
        self.assertDictEqual(
            r.cleaned_data(),
            OrderedDict([('groups', ['9876']), ('sequence', 1),
                         ('endpoint', 1), ('cluster', 4), ('addr', '1234'),
                         ('capacity', 16), ('group_count', 1), ('rssi', 255)]))

        msg_data = b'\x01\x01\x00\x04\x124\x10\x00'
        r = responses.R8062(msg_data, 255)
        self.assertDictEqual(
            r.cleaned_data(),
            OrderedDict([('groups', []), ('sequence', 1), ('endpoint', 1),
                         ('cluster', 4), ('addr', '1234'), ('capacity', 16),
                         ('group_count', 0), ('rssi', 255)]))
Example #4
0
    def test_response_8062(self):
        msg_data = unhexlify(b'01010004123410019876')
        r = responses.R8062(msg_data, 255)
        self.assertDictEqual(
            r.cleaned_data(),
            OrderedDict([
                ('sequence', 1),
                ('endpoint', 1),
                ('cluster', 4),
                ('capacity', 16),
                ('group_count', 1),
                ('lqi', 255),
                ('groups', ['9876']),
                ('addr', '1234'),
            ]))

        msg_data = unhexlify(b'0101000412341000')
        r = responses.R8062(msg_data, 255)
        self.assertDictEqual(
            r.cleaned_data(),
            OrderedDict([
                ('sequence', 1),
                ('endpoint', 1),
                ('cluster', 4),
                ('capacity', 16),
                ('group_count', 0),
                ('lqi', 255),
                ('groups', []),
                ('addr', '1234'),
            ]))

        msg_data = unhexlify(b'0101000412341002abcd9876')
        r = responses.R8062(msg_data, 255)
        self.assertDictEqual(
            r.cleaned_data(),
            OrderedDict([
                ('sequence', 1),
                ('endpoint', 1),
                ('cluster', 4),
                ('capacity', 16),
                ('group_count', 2),
                ('lqi', 255),
                ('groups', ['abcd', '9876']),
                ('addr', '1234'),
            ]))