summaryrefslogtreecommitdiff
path: root/tests/test_stream_xep_0325.py
diff options
context:
space:
mode:
authorSangeeth Saravanaraj <sangeeth@riptideio.com>2015-04-28 16:53:40 +0530
committerSangeeth Saravanaraj <sangeeth@riptideio.com>2015-04-28 16:53:40 +0530
commit80b60fc0483b21c8d5829b61cabbf9b46aa2c2fb (patch)
treeecb5905d19a563b4e6fe864afd0122321bf7cea1 /tests/test_stream_xep_0325.py
parent904480712157d762d35de16ce55202d641a56b3c (diff)
parent842157a6cc25d9e85e6e31b3cf3349ba83ece101 (diff)
downloadslixmpp-80b60fc0483b21c8d5829b61cabbf9b46aa2c2fb.tar.gz
slixmpp-80b60fc0483b21c8d5829b61cabbf9b46aa2c2fb.tar.bz2
slixmpp-80b60fc0483b21c8d5829b61cabbf9b46aa2c2fb.tar.xz
slixmpp-80b60fc0483b21c8d5829b61cabbf9b46aa2c2fb.zip
Merge remote-tracking branch 'origin/develop' into xep_0332
Diffstat (limited to 'tests/test_stream_xep_0325.py')
-rw-r--r--tests/test_stream_xep_0325.py110
1 files changed, 55 insertions, 55 deletions
diff --git a/tests/test_stream_xep_0325.py b/tests/test_stream_xep_0325.py
index 4b3250fc..2ebdd121 100644
--- a/tests/test_stream_xep_0325.py
+++ b/tests/test_stream_xep_0325.py
@@ -28,7 +28,7 @@ class TestStreamControl(SleekTest):
pass
def _time_now(self):
- return datetime.datetime.now().replace(microsecond=0).isoformat();
+ return datetime.datetime.now().replace(microsecond=0).isoformat()
def tearDown(self):
self.stream_close()
@@ -38,10 +38,10 @@ class TestStreamControl(SleekTest):
plugins=['xep_0030',
'xep_0325'])
- myDevice = Device("Device22");
- myDevice._add_control_field(name="Temperature", typename="int", value="15");
+ myDevice = Device("Device22")
+ myDevice._add_control_field(name="Temperature", typename="int", value="15")
- self.xmpp['xep_0325'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5);
+ self.xmpp['xep_0325'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5)
self.recv("""
<iq type='set'
@@ -60,26 +60,26 @@ class TestStreamControl(SleekTest):
to='master@clayster.com/amr'
id='1'>
<setResponse xmlns='urn:xmpp:iot:control' responseCode="OK" />
- </iq>
+ </iq>
""")
- self.assertEqual(myDevice._get_field_value("Temperature"), "17");
+ self.assertEqual(myDevice._get_field_value("Temperature"), "17")
def testRequestSetMulti(self):
self.stream_start(mode='component',
plugins=['xep_0030',
'xep_0325'])
- myDevice = Device("Device22");
- myDevice._add_control_field(name="Temperature", typename="int", value="15");
- myDevice._add_control_field(name="Startup", typename="date", value="2013-01-03");
+ myDevice = Device("Device22")
+ myDevice._add_control_field(name="Temperature", typename="int", value="15")
+ myDevice._add_control_field(name="Startup", typename="date", value="2013-01-03")
- myDevice2 = Device("Device23");
- myDevice2._add_control_field(name="Temperature", typename="int", value="19");
- myDevice2._add_control_field(name="Startup", typename="date", value="2013-01-09");
+ myDevice2 = Device("Device23")
+ myDevice2._add_control_field(name="Temperature", typename="int", value="19")
+ myDevice2._add_control_field(name="Startup", typename="date", value="2013-01-09")
- self.xmpp['xep_0325'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5);
- self.xmpp['xep_0325'].register_node(nodeId="Device23", device=myDevice2, commTimeout=0.5);
+ self.xmpp['xep_0325'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5)
+ self.xmpp['xep_0325'].register_node(nodeId="Device23", device=myDevice2, commTimeout=0.5)
self.recv("""
<iq type='set'
@@ -99,11 +99,11 @@ class TestStreamControl(SleekTest):
to='master@clayster.com/amr'
id='1'>
<setResponse xmlns='urn:xmpp:iot:control' responseCode="OK" />
- </iq>
+ </iq>
""")
- self.assertEqual(myDevice._get_field_value("Temperature"), "17");
- self.assertEqual(myDevice2._get_field_value("Temperature"), "19");
+ self.assertEqual(myDevice._get_field_value("Temperature"), "17")
+ self.assertEqual(myDevice2._get_field_value("Temperature"), "19")
self.recv("""
<iq type='set'
@@ -125,23 +125,23 @@ class TestStreamControl(SleekTest):
to='master@clayster.com/amr'
id='2'>
<setResponse xmlns='urn:xmpp:iot:control' responseCode="OK" />
- </iq>
+ </iq>
""")
- self.assertEqual(myDevice._get_field_value("Temperature"), "20");
- self.assertEqual(myDevice2._get_field_value("Temperature"), "20");
- self.assertEqual(myDevice._get_field_value("Startup"), "2013-02-01");
- self.assertEqual(myDevice2._get_field_value("Startup"), "2013-02-01");
+ self.assertEqual(myDevice._get_field_value("Temperature"), "20")
+ self.assertEqual(myDevice2._get_field_value("Temperature"), "20")
+ self.assertEqual(myDevice._get_field_value("Startup"), "2013-02-01")
+ self.assertEqual(myDevice2._get_field_value("Startup"), "2013-02-01")
def testRequestSetFail(self):
self.stream_start(mode='component',
plugins=['xep_0030',
'xep_0325'])
- myDevice = Device("Device23");
- myDevice._add_control_field(name="Temperature", typename="int", value="15");
+ myDevice = Device("Device23")
+ myDevice._add_control_field(name="Temperature", typename="int", value="15")
- self.xmpp['xep_0325'].register_node(nodeId="Device23", device=myDevice, commTimeout=0.5);
+ self.xmpp['xep_0325'].register_node(nodeId="Device23", device=myDevice, commTimeout=0.5)
self.recv("""
<iq type='set'
@@ -163,24 +163,24 @@ class TestStreamControl(SleekTest):
<parameter name='Voltage' />
<error var='Output'>Invalid field Voltage</error>
</setResponse>
- </iq>
+ </iq>
""")
- self.assertEqual(myDevice._get_field_value("Temperature"), "15");
- self.assertFalse(myDevice.has_control_field("Voltage", "int"));
+ self.assertEqual(myDevice._get_field_value("Temperature"), "15")
+ self.assertFalse(myDevice.has_control_field("Voltage", "int"))
def testDirectSetOk(self):
self.stream_start(mode='component',
plugins=['xep_0030',
'xep_0325'])
- myDevice = Device("Device22");
- myDevice._add_control_field(name="Temperature", typename="int", value="15");
+ myDevice = Device("Device22")
+ myDevice._add_control_field(name="Temperature", typename="int", value="15")
- self.xmpp['xep_0325'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5);
+ self.xmpp['xep_0325'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5)
self.recv("""
- <message
+ <message
from='master@clayster.com/amr'
to='device@clayster.com'>
<set xmlns='urn:xmpp:iot:control'>
@@ -191,20 +191,20 @@ class TestStreamControl(SleekTest):
time.sleep(.5)
- self.assertEqual(myDevice._get_field_value("Temperature"), "17");
+ self.assertEqual(myDevice._get_field_value("Temperature"), "17")
def testDirectSetFail(self):
self.stream_start(mode='component',
plugins=['xep_0030',
'xep_0325'])
- myDevice = Device("Device22");
- myDevice._add_control_field(name="Temperature", typename="int", value="15");
+ myDevice = Device("Device22")
+ myDevice._add_control_field(name="Temperature", typename="int", value="15")
- self.xmpp['xep_0325'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5);
+ self.xmpp['xep_0325'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5)
self.recv("""
- <message
+ <message
from='master@clayster.com/amr'
to='device@clayster.com'>
<set xmlns='urn:xmpp:iot:control'>
@@ -215,8 +215,8 @@ class TestStreamControl(SleekTest):
time.sleep(.5)
- self.assertEqual(myDevice._get_field_value("Temperature"), "15");
- self.assertFalse(myDevice.has_control_field("Voltage", "int"));
+ self.assertEqual(myDevice._get_field_value("Temperature"), "15")
+ self.assertFalse(myDevice.has_control_field("Voltage", "int"))
def testRequestSetOkAPI(self):
@@ -225,16 +225,16 @@ class TestStreamControl(SleekTest):
plugins=['xep_0030',
'xep_0325'])
- results = [];
+ results = []
def my_callback(from_jid, result, nodeIds=None, fields=None, error_msg=None):
- results.append(result);
+ results.append(result)
fields = []
fields.append(("Temperature", "double", "20.5"))
fields.append(("TemperatureAlarmSetting", "string", "High"))
- self.xmpp['xep_0325'].set_request(from_jid="tester@localhost", to_jid="you@google.com", fields=fields, nodeIds=['Device33', 'Device22'], callback=my_callback);
+ self.xmpp['xep_0325'].set_request(from_jid="tester@localhost", to_jid="you@google.com", fields=fields, nodeIds=['Device33', 'Device22'], callback=my_callback)
self.send("""
<iq type='set'
@@ -256,12 +256,12 @@ class TestStreamControl(SleekTest):
to='tester@localhost'
id='1'>
<setResponse xmlns='urn:xmpp:iot:control' responseCode="OK" />
- </iq>
+ </iq>
""")
time.sleep(.5)
- self.assertEqual(results, ["OK"]);
+ self.assertEqual(results, ["OK"])
def testRequestSetErrorAPI(self):
@@ -269,16 +269,16 @@ class TestStreamControl(SleekTest):
plugins=['xep_0030',
'xep_0325'])
- results = [];
+ results = []
def my_callback(from_jid, result, nodeIds=None, fields=None, error_msg=None):
- results.append(result);
+ results.append(result)
fields = []
fields.append(("Temperature", "double", "20.5"))
fields.append(("TemperatureAlarmSetting", "string", "High"))
- self.xmpp['xep_0325'].set_request(from_jid="tester@localhost", to_jid="you@google.com", fields=fields, nodeIds=['Device33', 'Device22'], callback=my_callback);
+ self.xmpp['xep_0325'].set_request(from_jid="tester@localhost", to_jid="you@google.com", fields=fields, nodeIds=['Device33', 'Device22'], callback=my_callback)
self.send("""
<iq type='set'
@@ -302,17 +302,17 @@ class TestStreamControl(SleekTest):
<setResponse xmlns='urn:xmpp:iot:control' responseCode="OtherError" >
<error var='Temperature'>Sensor error</error>
</setResponse>
- </iq>
+ </iq>
""")
time.sleep(.5)
- self.assertEqual(results, ["OtherError"]);
+ self.assertEqual(results, ["OtherError"])
def testServiceDiscoveryClient(self):
self.stream_start(mode='client',
plugins=['xep_0030',
- 'xep_0325']);
+ 'xep_0325'])
self.recv("""
<iq type='get'
@@ -330,14 +330,14 @@ class TestStreamControl(SleekTest):
<query xmlns='http://jabber.org/protocol/disco#info'>
<identity category='client' type='bot'/>
<feature var='urn:xmpp:iot:control'/>
- </query>
- </iq>
+ </query>
+ </iq>
""")
def testServiceDiscoveryComponent(self):
self.stream_start(mode='component',
plugins=['xep_0030',
- 'xep_0325']);
+ 'xep_0325'])
self.recv("""
<iq type='get'
@@ -356,8 +356,8 @@ class TestStreamControl(SleekTest):
<query xmlns='http://jabber.org/protocol/disco#info'>
<identity category='component' type='generic'/>
<feature var='urn:xmpp:iot:control'/>
- </query>
- </iq>
+ </query>
+ </iq>
""")