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 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 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> """)
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> """)