Example #1
0
    def testDelayedRequest(self):
        self.stream_start(mode='component', plugins=['xep_0030', 'xep_0323'])

        myDevice = Device("Device22")
        myDevice._add_field(name="Temperature", typename="numeric", unit="°C")
        myDevice._set_momentary_timestamp("2013-03-07T16:24:30")
        myDevice._add_field_momentary_data("Temperature",
                                           "23.4",
                                           flags={"automaticReadout": "true"})

        self.xmpp['xep_0323'].register_node(nodeId="Device22",
                                            device=myDevice,
                                            commTimeout=0.5)

        dtnow = datetime.datetime.now()
        ts_2sec = datetime.timedelta(0, 2)
        dtnow_plus_2sec = dtnow + ts_2sec
        when_flag = dtnow_plus_2sec.replace(microsecond=0).isoformat()

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='1'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='1' momentary='true' when='"""
                  + when_flag + """'/>
            </iq>
        """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='1'>
                <accepted xmlns='urn:xmpp:iot:sensordata' seqnr='1' queued='true' />
            </iq>
            """)

        time.sleep(1)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <started xmlns='urn:xmpp:iot:sensordata' seqnr='1' />
            </message>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='1' done='true'>
                    <node nodeId='Device22'>
                        <timestamp value='2013-03-07T16:24:30'>
                            <numeric name='Temperature' momentary='true' automaticReadout='true' value='23.4' unit='°C'/>
                        </timestamp>
                    </node>
                </fields>
            </message>
            """)
    def testRequestFieldFromTo(self):

        self.stream_start(mode='component',
                          plugins=['xep_0030',
                                   'xep_0323'])

        myDevice = Device("Device44")
        myDevice._add_field(name='Voltage', typename="numeric", unit="V")
        myDevice._add_field_timestamp_data(name="Voltage", value="230.1", timestamp="2000-01-01T00:01:02", flags={"invoiced": "true"})
        myDevice._add_field_timestamp_data(name="Voltage", value="230.2", timestamp="2000-02-01T00:01:02", flags={"invoiced": "true"})
        myDevice._add_field_timestamp_data(name="Voltage", value="230.3", timestamp="2000-03-01T00:01:02", flags={"invoiced": "true"})

        self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5)

        print("."),

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='6'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='6' from='2000-01-01T00:01:03' to='2000-02-02T00:00:01'>
                    <field name='Voltage'/>
                </req>
            </iq>
        """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='6'>
                <accepted xmlns='urn:xmpp:iot:sensordata' seqnr='6'/>
            </iq>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='6'>
                    <node nodeId='Device44'>
                        <timestamp value='2000-02-01T00:01:02'>
                            <numeric name='Voltage' invoiced='true' value='230.2' unit='V'/>
                        </timestamp>
                    </node>
                </fields>
            </message>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='6' done='true'>
                </fields>
            </message>
            """)
Example #3
0
    def testRequestNode(self):

        self.stream_start(mode='component', plugins=['xep_0030', 'xep_0323'])

        myDevice = Device("Device44")
        self.xmpp['xep_0323'].register_node('Device44',
                                            myDevice,
                                            commTimeout=0.5)

        print("."),

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='77'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='66' momentary='true'>
                    <node nodeId='Device33'/>
                </req>
            </iq>
        """)

        self.send("""
            <iq type='error'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='77'>
                <rejected xmlns='urn:xmpp:iot:sensordata' seqnr='66'>
                    <error>Invalid nodeId Device33</error>
                </rejected>
            </iq>
            """)

        print("."),

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='8'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='7' momentary='true'>
                    <node nodeId='Device44'/>
                </req>
            </iq>
        """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='8'>
                <accepted xmlns='urn:xmpp:iot:sensordata' seqnr='7'/>
            </iq>
            """)
    def testRequestFieldFromTo(self):

        self.stream_start(mode='component',
                          plugins=['xep_0030',
                                   'xep_0323'])

        myDevice = Device("Device44");
        myDevice._add_field(name='Voltage', typename="numeric", unit="V");
        myDevice._add_field_timestamp_data(name="Voltage", value="230.1", timestamp="2000-01-01T00:01:02", flags={"invoiced": "true"});
        myDevice._add_field_timestamp_data(name="Voltage", value="230.2", timestamp="2000-02-01T00:01:02", flags={"invoiced": "true"});
        myDevice._add_field_timestamp_data(name="Voltage", value="230.3", timestamp="2000-03-01T00:01:02", flags={"invoiced": "true"});

        self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5);

        print("."),

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='6'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='6' from='2000-01-01T00:01:03' to='2000-02-02T00:00:01'>
                    <field name='Voltage'/>
                </req>
            </iq>
        """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='6'>
                <accepted xmlns='urn:xmpp:iot:sensordata' seqnr='6'/>
            </iq>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='6'>
                    <node nodeId='Device44'>
                        <timestamp value='2000-02-01T00:01:02'>
                            <numeric name='Voltage' invoiced='true' value='230.2' unit='V'/>
                        </timestamp>
                    </node>
                </fields>
            </message>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='6' done='true'>
                </fields>
            </message>
            """)
    def testDelayedRequest(self):
        self.stream_start(mode='component',
                          plugins=['xep_0030',
                                   'xep_0323'])

        myDevice = Device("Device22");
        myDevice._add_field(name="Temperature", typename="numeric", unit="°C");
        myDevice._set_momentary_timestamp("2013-03-07T16:24:30")
        myDevice._add_field_momentary_data("Temperature", "23.4", flags={"automaticReadout": "true"});

        self.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5);

        dtnow = datetime.datetime.now()
        ts_2sec = datetime.timedelta(0,2)
        dtnow_plus_2sec = dtnow + ts_2sec
        when_flag = dtnow_plus_2sec.replace(microsecond=0).isoformat()

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='1'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='1' momentary='true' when='""" + when_flag + """'/>
            </iq>
        """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='1'>
                <accepted xmlns='urn:xmpp:iot:sensordata' seqnr='1' queued='true' />
            </iq>
            """)

        time.sleep(1)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <started xmlns='urn:xmpp:iot:sensordata' seqnr='1' />
            </message>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='1' done='true'>
                    <node nodeId='Device22'>
                        <timestamp value='2013-03-07T16:24:30'>
                            <numeric name='Temperature' momentary='true' automaticReadout='true' value='23.4' unit='°C'/>
                        </timestamp>
                    </node>
                </fields>
            </message>
            """)
Example #6
0
    def testDelayedRequestFail(self):
        self.stream_start(mode='component', plugins=['xep_0030', 'xep_0323'])

        myDevice = Device("Device22")
        myDevice._add_field(name="Temperature", typename="numeric", unit="°C")
        myDevice._set_momentary_timestamp("2013-03-07T16:24:30")
        myDevice._add_field_momentary_data("Temperature",
                                           "23.4",
                                           flags={"automaticReadout": "true"})

        self.xmpp['xep_0323'].register_node(nodeId="Device22",
                                            device=myDevice,
                                            commTimeout=0.5)

        dtnow = datetime.datetime.now()
        ts_2sec = datetime.timedelta(0, 2)
        dtnow_minus_2sec = dtnow - ts_2sec
        when_flag = dtnow_minus_2sec.replace(microsecond=0).isoformat()

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='1'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='1' momentary='true' when='"""
                  + when_flag + """'/>
            </iq>
        """)

        # Remove the returned datetime to allow predictable test
        xml_stanza = self._filtered_stanza_prepare()
        error_text = xml_stanza['rejected']['error']  #['text']
        error_text = re.sub(
            r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-]\d{2}:\d{2})?',
            '…', error_text)
        xml_stanza['rejected']['error'] = error_text

        self._filtered_stanza_check(
            """
            <iq type='error'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='1'>
                <rejected xmlns='urn:xmpp:iot:sensordata' seqnr='1'>
                    <error>Invalid datetime in 'when' flag, cannot set a time in the past (…). Current time: …</error>
                </rejected>
            </iq>
            """, xml_stanza)
Example #7
0
    def testRequestAccept(self):
        self.stream_start(mode='component', plugins=['xep_0030', 'xep_0323'])

        myDevice = Device("Device22")
        myDevice._add_field(name="Temperature", typename="numeric", unit="°C")
        myDevice._set_momentary_timestamp("2013-03-07T16:24:30")
        myDevice._add_field_momentary_data("Temperature",
                                           "23.4",
                                           flags={"automaticReadout": "true"})

        self.xmpp['xep_0323'].register_node(nodeId="Device22",
                                            device=myDevice,
                                            commTimeout=0.5)

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='1'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='1' momentary='true'/>
            </iq>
        """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='1'>
                <accepted xmlns='urn:xmpp:iot:sensordata' seqnr='1'/>
            </iq>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='1' done='true'>
                    <node nodeId='Device22'>
                        <timestamp value='2013-03-07T16:24:30'>
                            <numeric name='Temperature' momentary='true' automaticReadout='true' value='23.4' unit='°C'/>
                        </timestamp>
                    </node>
                </fields>
            </message>
            """)
    def testDelayedRequestFail(self):
        self.stream_start(mode='component',
                          plugins=['xep_0030',
                                   'xep_0323'])

        myDevice = Device("Device22");
        myDevice._add_field(name="Temperature", typename="numeric", unit="°C");
        myDevice._set_momentary_timestamp("2013-03-07T16:24:30")
        myDevice._add_field_momentary_data("Temperature", "23.4", flags={"automaticReadout": "true"});

        self.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5);

        dtnow = datetime.datetime.now()
        ts_2sec = datetime.timedelta(0,2)
        dtnow_minus_2sec = dtnow - ts_2sec
        when_flag = dtnow_minus_2sec.replace(microsecond=0).isoformat()

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='1'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='1' momentary='true' when='""" + when_flag + """'/>
            </iq>
        """)

        # Remove the returned datetime to allow predictable test
        xml_stanza = self._filtered_stanza_prepare()
        error_text = xml_stanza['rejected']['error'] #['text']
        error_text = error_text[:error_text.find(':')]
        xml_stanza['rejected']['error'] = error_text

        self._filtered_stanza_check("""
            <iq type='error'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='1'>
                <rejected xmlns='urn:xmpp:iot:sensordata' seqnr='1'>
                    <error>Invalid datetime in 'when' flag, cannot set a time in the past. Current time</error>
                </rejected>
            </iq>
            """, xml_stanza)
    def testRequestAccept(self):
        self.stream_start(mode='component',
                          plugins=['xep_0030',
                                   'xep_0323'])

        myDevice = Device("Device22");
        myDevice._add_field(name="Temperature", typename="numeric", unit="°C");
        myDevice._set_momentary_timestamp("2013-03-07T16:24:30")
        myDevice._add_field_momentary_data("Temperature", "23.4", flags={"automaticReadout": "true"});

        self.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5);

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='1'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='1' momentary='true'/>
            </iq>
        """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='1'>
                <accepted xmlns='urn:xmpp:iot:sensordata' seqnr='1'/>
            </iq>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='1' done='true'>
                    <node nodeId='Device22'>
                        <timestamp value='2013-03-07T16:24:30'>
                            <numeric name='Temperature' momentary='true' automaticReadout='true' value='23.4' unit='°C'/>
                        </timestamp>
                    </node>
                </fields>
            </message>
            """)
Example #10
0
    def testRequestMultiTimestampAllFields(self):

        self.stream_start(mode='component', plugins=['xep_0030', 'xep_0323'])

        myDevice = Device("Device44")
        myDevice._add_field(name='Voltage', typename="numeric", unit="V")
        myDevice._add_field_timestamp_data(name="Voltage",
                                           value="230.4",
                                           timestamp="2000-01-01T00:01:02",
                                           flags={"invoiced": "true"})
        myDevice._add_field(name='Current', typename="numeric", unit="A")
        myDevice._add_field(name='Height', typename="string")
        myDevice._add_field_timestamp_data(name="Voltage",
                                           value="230.6",
                                           timestamp="2000-01-01T01:01:02")
        myDevice._add_field_timestamp_data(name="Height",
                                           value="115 m",
                                           timestamp="2000-01-01T01:01:02",
                                           flags={"invoiced": "true"})

        self.xmpp['xep_0323'].register_node('Device44',
                                            myDevice,
                                            commTimeout=0.5)

        print("."),

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='8'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='7'/>
            </iq>
        """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='8'>
                <accepted xmlns='urn:xmpp:iot:sensordata' seqnr='7'/>
            </iq>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='7'>
                    <node nodeId='Device44'>
                        <timestamp value='2000-01-01T00:01:02'>
                            <numeric name='Voltage' invoiced='true' value='230.4' unit='V'/>
                        </timestamp>
                    </node>
                </fields>
            </message>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='7'>
                    <node nodeId='Device44'>
                        <timestamp value='2000-01-01T01:01:02'>
                            <numeric name='Voltage' value='230.6' unit='V'/>
                            <string name='Height' invoiced='true' value='115 m'/>
                        </timestamp>
                    </node>
                </fields>
            </message>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='7' done='true'>
                </fields>
            </message>
            """)
Example #11
0
    def testDelayedRequestCancel(self):
        self.stream_start(mode='component', plugins=['xep_0030', 'xep_0323'])

        myDevice = Device("Device22")
        myDevice._add_field(name="Temperature", typename="numeric", unit="°C")
        myDevice._set_momentary_timestamp("2013-03-07T16:24:30")
        myDevice._add_field_momentary_data("Temperature",
                                           "23.4",
                                           flags={"automaticReadout": "true"})

        self.xmpp['xep_0323'].register_node(nodeId="Device22",
                                            device=myDevice,
                                            commTimeout=0.5)

        dtnow = datetime.datetime.now()
        ts_2sec = datetime.timedelta(0, 2)
        dtnow_plus_2sec = dtnow + ts_2sec
        when_flag = dtnow_plus_2sec.replace(microsecond=0).isoformat()

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='1'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='1' momentary='true' when='"""
                  + when_flag + """'/>
            </iq>
        """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='1'>
                <accepted xmlns='urn:xmpp:iot:sensordata' seqnr='1' queued='true' />
            </iq>
            """)

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='1'>
                <cancel xmlns='urn:xmpp:iot:sensordata' seqnr='1' />
            </iq>
            """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='1'>
                <cancelled xmlns='urn:xmpp:iot:sensordata' seqnr='1' />
            </iq>
            """)

        # Test cancel of non-existing request
        self.recv("""
            <iq type='get'
                from='tester@localhost'
                to='*****@*****.**'
                id='1'>
                <cancel xmlns='urn:xmpp:iot:sensordata' seqnr='1' />
            </iq>
            """)

        self.send("""
            <iq type='error'
                from='*****@*****.**'
                to='tester@localhost'
                id='1'>
                <rejected xmlns='urn:xmpp:iot:sensordata' seqnr='1'>
                    <error>Cancel request received, no matching request is active.</error>
                </rejected>
            </iq>
            """)

        # Ensure we don't get anything after cancellation
        self.send(None)
Example #12
0
 def __init__(self,nodeId):
     Device.__init__(self,nodeId)
     self.counter=0
Example #13
0
    def testRequestMultiTimestampAllFields(self):

        self.stream_start(mode='component',
                          plugins=['xep_0030',
                                   'xep_0323'])

        myDevice = Device("Device44");
        myDevice._add_field(name='Voltage', typename="numeric", unit="V");
        myDevice._add_field_timestamp_data(name="Voltage", value="230.4", timestamp="2000-01-01T00:01:02", flags={"invoiced": "true"});
        myDevice._add_field(name='Current', typename="numeric", unit="A");
        myDevice._add_field(name='Height', typename="string");
        myDevice._add_field_timestamp_data(name="Voltage", value="230.6", timestamp="2000-01-01T01:01:02");
        myDevice._add_field_timestamp_data(name="Height", value="115 m", timestamp="2000-01-01T01:01:02", flags={"invoiced": "true"});

        self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5);

        print("."),

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='8'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='7'/>
            </iq>
        """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='8'>
                <accepted xmlns='urn:xmpp:iot:sensordata' seqnr='7'/>
            </iq>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='7'>
                    <node nodeId='Device44'>
                        <timestamp value='2000-01-01T00:01:02'>
                            <numeric name='Voltage' invoiced='true' value='230.4' unit='V'/>
                        </timestamp>
                    </node>
                </fields>
            </message>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='7'>
                    <node nodeId='Device44'>
                        <timestamp value='2000-01-01T01:01:02'>
                            <numeric name='Voltage' value='230.6' unit='V'/>
                            <string name='Height' invoiced='true' value='115 m'/>
                        </timestamp>
                    </node>
                </fields>
            </message>
            """)

        self.send("""
            <message from='*****@*****.**'
                     to='[email protected]/amr'>
                <fields xmlns='urn:xmpp:iot:sensordata' seqnr='7' done='true'>
                </fields>
            </message>
            """)
Example #14
0
    def testDelayedRequestCancel(self):
        self.stream_start(mode='component',
                          plugins=['xep_0030',
                                   'xep_0323'])

        myDevice = Device("Device22");
        myDevice._add_field(name="Temperature", typename="numeric", unit="°C");
        myDevice._set_momentary_timestamp("2013-03-07T16:24:30")
        myDevice._add_field_momentary_data("Temperature", "23.4", flags={"automaticReadout": "true"});

        self.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5);

        dtnow = datetime.datetime.now()
        ts_2sec = datetime.timedelta(0,2)
        dtnow_plus_2sec = dtnow + ts_2sec
        when_flag = dtnow_plus_2sec.replace(microsecond=0).isoformat()

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='1'>
                <req xmlns='urn:xmpp:iot:sensordata' seqnr='1' momentary='true' when='""" + when_flag + """'/>
            </iq>
        """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='1'>
                <accepted xmlns='urn:xmpp:iot:sensordata' seqnr='1' queued='true' />
            </iq>
            """)

        self.recv("""
            <iq type='get'
                from='[email protected]/amr'
                to='*****@*****.**'
                id='1'>
                <cancel xmlns='urn:xmpp:iot:sensordata' seqnr='1' />
            </iq>
            """)

        self.send("""
            <iq type='result'
                from='*****@*****.**'
                to='[email protected]/amr'
                id='1'>
                <cancelled xmlns='urn:xmpp:iot:sensordata' seqnr='1' />
            </iq>
            """)

        # Test cancel of non-existing request
        self.recv("""
            <iq type='get'
                from='tester@localhost'
                to='*****@*****.**'
                id='1'>
                <cancel xmlns='urn:xmpp:iot:sensordata' seqnr='1' />
            </iq>
            """)

        self.send("""
            <iq type='error'
                from='*****@*****.**'
                to='tester@localhost'
                id='1'>
                <rejected xmlns='urn:xmpp:iot:sensordata' seqnr='1'>
                    <error>Cancel request received, no matching request is active.</error>
                </rejected>
            </iq>
            """)

        # Ensure we don't get anything after cancellation
        self.send(None)
Example #15
0
 def __init__(self, nodeId):
     Device.__init__(self, nodeId)
     self.counter = 0