From 7265682a4d57d88956cb54f98f7a470465bbf417 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Mon, 18 Aug 2014 00:52:24 +0200 Subject: cleanup semicolons, whitespace and mutable default arguments --- tests/test_stream_xep_0323.py | 424 +++++++++++++++++++++--------------------- 1 file changed, 212 insertions(+), 212 deletions(-) (limited to 'tests/test_stream_xep_0323.py') diff --git a/tests/test_stream_xep_0323.py b/tests/test_stream_xep_0323.py index fd2ad225..94f1d638 100644 --- a/tests/test_stream_xep_0323.py +++ b/tests/test_stream_xep_0323.py @@ -19,7 +19,7 @@ class TestStreamSensorData(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() @@ -29,12 +29,12 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - myDevice = Device("Device22"); - myDevice._add_field(name="Temperature", typename="numeric", unit="°C"); + 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"}); + 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.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5) self.recv(""" @@ -60,11 +60,11 @@ class TestStreamSensorData(SleekTest): - + - + """) def testRequestRejectAuth(self): @@ -73,7 +73,7 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - self.xmpp['xep_0323']._set_authenticated("darth@deathstar.com"); + self.xmpp['xep_0323']._set_authenticated("darth@deathstar.com") self.recv(""" @@ -101,8 +101,8 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - myDevice = Device("Device44"); - self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5); + myDevice = Device("Device44") + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -118,7 +118,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -142,7 +142,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -157,11 +157,11 @@ class TestStreamSensorData(SleekTest): 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 = 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"}) - self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -177,7 +177,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -201,7 +201,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -215,11 +215,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -227,7 +227,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestMultiTimestampSingleField(self): @@ -236,15 +236,15 @@ class TestStreamSensorData(SleekTest): 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"}); + 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); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -260,7 +260,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -274,11 +274,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -287,11 +287,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -299,7 +299,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestMultiTimestampAllFields(self): @@ -308,15 +308,15 @@ class TestStreamSensorData(SleekTest): 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"}); + 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); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -330,7 +330,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -344,11 +344,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -357,12 +357,12 @@ class TestStreamSensorData(SleekTest): - - + + - + """) self.send(""" @@ -370,7 +370,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestAPI(self): @@ -379,7 +379,7 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", callback=None); + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", callback=None) self.send(""" """) - self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33', 'Device22'], callback=None); + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33', 'Device22'], callback=None) self.send(""" """) - self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", fields=['Temperature', 'Voltage'], callback=None); + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", fields=['Temperature', 'Voltage'], callback=None) self.send(""" Invalid device Device22 - + """) time.sleep(.1) - self.failUnless(results == ["rejected"], - "Rejected callback was not properly executed"); + self.failUnless(results == ["rejected"], + "Rejected callback was not properly executed") def testRequestAcceptedAPI(self): @@ -466,12 +466,12 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = []; + results = [] def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): - results.append(result); + results.append(result) - self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33', 'Device22'], callback=my_callback); + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33', 'Device22'], callback=my_callback) self.send(""" - + """) time.sleep(.1) - self.failUnless(results == ["accepted"], - "Accepted callback was not properly executed"); + self.failUnless(results == ["accepted"], + "Accepted callback was not properly executed") def testRequestFieldsAPI(self): @@ -505,25 +505,25 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = []; - callback_data = {}; + results = [] + callback_data = {} def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): - results.append(result); + results.append(result) if result == "fields": - callback_data["nodeId"] = nodeId; - callback_data["timestamp"] = timestamp; - callback_data["error_msg"] = error_msg; + callback_data["nodeId"] = nodeId + callback_data["timestamp"] = timestamp + callback_data["error_msg"] = error_msg for f in fields: - callback_data["field_" + f['name']] = f; + callback_data["field_" + f['name']] = f t1= threading.Thread(name="request_data", target=self.xmpp['xep_0323'].request_data, - kwargs={"from_jid": "tester@localhost", - "to_jid": "you@google.com", - "nodeIds": ['Device33'], - "callback": my_callback}); - t1.start(); + kwargs={"from_jid": "tester@localhost", + "to_jid": "you@google.com", + "nodeIds": ['Device33'], + "callback": my_callback}) + t1.start() #self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); self.send(""" @@ -538,12 +538,12 @@ class TestStreamSensorData(SleekTest): """) self.recv(""" - - + """) self.recv(""" @@ -552,42 +552,42 @@ class TestStreamSensorData(SleekTest): - - + + - + """) self.recv(""" - + """) - t1.join(); + t1.join() time.sleep(.5) - self.failUnlessEqual(results, ["accepted","fields","done"]); + self.failUnlessEqual(results, ["accepted","fields","done"]) # self.assertIn("nodeId", callback_data); self.assertTrue("nodeId" in callback_data) - self.failUnlessEqual(callback_data["nodeId"], "Device33"); + self.failUnlessEqual(callback_data["nodeId"], "Device33") # self.assertIn("timestamp", callback_data); - self.assertTrue("timestamp" in callback_data); - self.failUnlessEqual(callback_data["timestamp"], "2000-01-01T00:01:02"); + self.assertTrue("timestamp" in callback_data) + self.failUnlessEqual(callback_data["timestamp"], "2000-01-01T00:01:02") #self.assertIn("field_Voltage", callback_data); - self.assertTrue("field_Voltage" in callback_data); - self.failUnlessEqual(callback_data["field_Voltage"], {"name": "Voltage", "value": "230.4", "typename": "numeric", "unit": "V", "flags": {"invoiced": "true"}}); + self.assertTrue("field_Voltage" in callback_data) + self.failUnlessEqual(callback_data["field_Voltage"], {"name": "Voltage", "value": "230.4", "typename": "numeric", "unit": "V", "flags": {"invoiced": "true"}}) #self.assertIn("field_TestBool", callback_data); - self.assertTrue("field_TestBool" in callback_data); - self.failUnlessEqual(callback_data["field_TestBool"], {"name": "TestBool", "value": "true", "typename": "boolean" }); + self.assertTrue("field_TestBool" in callback_data) + self.failUnlessEqual(callback_data["field_TestBool"], {"name": "TestBool", "value": "true", "typename": "boolean" }) def testServiceDiscoveryClient(self): self.stream_start(mode='client', plugins=['xep_0030', - 'xep_0323']); + 'xep_0323']) self.recv(""" - - + + """) def testServiceDiscoveryComponent(self): self.stream_start(mode='component', plugins=['xep_0030', - 'xep_0323']); + 'xep_0323']) self.recv(""" - - + + """) def testRequestTimeout(self): @@ -641,23 +641,23 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = []; - callback_data = {}; + results = [] + callback_data = {} def my_callback(from_jid, result, nodeId=None, timestamp=None, error_msg=None): - results.append(result); + results.append(result) if result == "failure": - callback_data["nodeId"] = nodeId; - callback_data["timestamp"] = timestamp; - callback_data["error_msg"] = error_msg; + callback_data["nodeId"] = nodeId + callback_data["timestamp"] = timestamp + callback_data["error_msg"] = error_msg t1= threading.Thread(name="request_data", target=self.xmpp['xep_0323'].request_data, - kwargs={"from_jid": "tester@localhost", - "to_jid": "you@google.com", - "nodeIds": ['Device33'], - "callback": my_callback}); - t1.start(); + kwargs={"from_jid": "tester@localhost", + "to_jid": "you@google.com", + "nodeIds": ['Device33'], + "callback": my_callback}) + t1.start() self.send(""" - + """) self.recv(""" @@ -688,31 +688,31 @@ class TestStreamSensorData(SleekTest): """) - t1.join(); + t1.join() time.sleep(.5) - self.failUnlessEqual(results, ["accepted","failure"]); + self.failUnlessEqual(results, ["accepted","failure"]) # self.assertIn("nodeId", callback_data); - self.assertTrue("nodeId" in callback_data); - self.failUnlessEqual(callback_data["nodeId"], "Device33"); + self.assertTrue("nodeId" in callback_data) + self.failUnlessEqual(callback_data["nodeId"], "Device33") # self.assertIn("timestamp", callback_data); - self.assertTrue("timestamp" in callback_data); - self.failUnlessEqual(callback_data["timestamp"], "2013-03-07T17:13:30"); + self.assertTrue("timestamp" in callback_data) + self.failUnlessEqual(callback_data["timestamp"], "2013-03-07T17:13:30") # self.assertIn("error_msg", callback_data); - self.assertTrue("error_msg" in callback_data); - self.failUnlessEqual(callback_data["error_msg"], "Timeout."); + self.assertTrue("error_msg" in callback_data) + self.failUnlessEqual(callback_data["error_msg"], "Timeout.") 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 = 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"}); + 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.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5) dtnow = datetime.datetime.now() ts_2sec = datetime.timedelta(0,2) @@ -729,7 +729,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -743,7 +743,7 @@ class TestStreamSensorData(SleekTest): - + """) self.send(""" @@ -752,11 +752,11 @@ class TestStreamSensorData(SleekTest): - + - + """) def testDelayedRequestFail(self): @@ -764,12 +764,12 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - myDevice = Device("Device22"); - myDevice._add_field(name="Temperature", typename="numeric", unit="°C"); + 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"}); + 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.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5) dtnow = datetime.datetime.now() ts_2sec = datetime.timedelta(0,2) @@ -792,7 +792,7 @@ class TestStreamSensorData(SleekTest): xml_stanza['rejected']['error'] = error_text self._filtered_stanza_check(""" - @@ -825,13 +825,13 @@ class TestStreamSensorData(SleekTest): 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"}); + 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); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -847,7 +847,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -861,11 +861,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -874,11 +874,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -886,7 +886,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestFieldTo(self): @@ -895,13 +895,13 @@ class TestStreamSensorData(SleekTest): 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"}); + 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); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -917,7 +917,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -931,11 +931,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -944,11 +944,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -956,7 +956,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestFieldFromTo(self): @@ -965,13 +965,13 @@ class TestStreamSensorData(SleekTest): 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"}); + 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); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -987,7 +987,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -1001,11 +1001,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -1013,7 +1013,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testDelayedRequestClient(self): @@ -1021,25 +1021,25 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = []; - callback_data = {}; + results = [] + callback_data = {} def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): - results.append(result); + results.append(result) if result == "fields": - callback_data["nodeId"] = nodeId; - callback_data["timestamp"] = timestamp; - callback_data["error_msg"] = error_msg; + callback_data["nodeId"] = nodeId + callback_data["timestamp"] = timestamp + callback_data["error_msg"] = error_msg for f in fields: - callback_data["field_" + f['name']] = f; + callback_data["field_" + f['name']] = f t1= threading.Thread(name="request_data", target=self.xmpp['xep_0323'].request_data, - kwargs={"from_jid": "tester@localhost", - "to_jid": "you@google.com", - "nodeIds": ['Device33'], - "callback": my_callback}); - t1.start(); + kwargs={"from_jid": "tester@localhost", + "to_jid": "you@google.com", + "nodeIds": ['Device33'], + "callback": my_callback}) + t1.start() #self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); self.send(""" @@ -1054,20 +1054,20 @@ class TestStreamSensorData(SleekTest): """) self.recv(""" - - + """) self.recv(""" - - """) + + """) self.recv(""" - - + + - + """) self.recv(""" - + """) - t1.join(); + t1.join() time.sleep(.5) - self.failUnlessEqual(results, ["queued","started","fields","done"]); + self.failUnlessEqual(results, ["queued","started","fields","done"]) # self.assertIn("nodeId", callback_data); - self.assertTrue("nodeId" in callback_data); - self.failUnlessEqual(callback_data["nodeId"], "Device33"); + self.assertTrue("nodeId" in callback_data) + self.failUnlessEqual(callback_data["nodeId"], "Device33") # self.assertIn("timestamp", callback_data); - self.assertTrue("timestamp" in callback_data); - self.failUnlessEqual(callback_data["timestamp"], "2000-01-01T00:01:02"); + self.assertTrue("timestamp" in callback_data) + self.failUnlessEqual(callback_data["timestamp"], "2000-01-01T00:01:02") # self.assertIn("field_Voltage", callback_data); - self.assertTrue("field_Voltage" in callback_data); - self.failUnlessEqual(callback_data["field_Voltage"], {"name": "Voltage", "value": "230.4", "typename": "numeric", "unit": "V", "flags": {"invoiced": "true"}}); + self.assertTrue("field_Voltage" in callback_data) + self.failUnlessEqual(callback_data["field_Voltage"], {"name": "Voltage", "value": "230.4", "typename": "numeric", "unit": "V", "flags": {"invoiced": "true"}}) # self.assertIn("field_TestBool", callback_data); - self.assertTrue("field_TestBool" in callback_data); - self.failUnlessEqual(callback_data["field_TestBool"], {"name": "TestBool", "value": "true", "typename": "boolean" }); + self.assertTrue("field_TestBool" in callback_data) + self.failUnlessEqual(callback_data["field_TestBool"], {"name": "TestBool", "value": "true", "typename": "boolean" }) def testRequestFieldsCancelAPI(self): @@ -1114,12 +1114,12 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = []; + results = [] def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): - results.append(result); + results.append(result) - session = self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); + session = self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback) self.send(""" - + """) - self.xmpp['xep_0323'].cancel_request(session=session); + self.xmpp['xep_0323'].cancel_request(session=session) self.send(""" -- cgit v1.2.3 From 3dd379cdf12d885e26f8ec26c54879a95d5f0b84 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Mon, 18 Aug 2014 15:15:14 +0200 Subject: Revert "cleanup semicolons, whitespace and mutable default arguments" This reverts commit 7265682a4d57d88956cb54f98f7a470465bbf417. --- tests/test_stream_xep_0323.py | 424 +++++++++++++++++++++--------------------- 1 file changed, 212 insertions(+), 212 deletions(-) (limited to 'tests/test_stream_xep_0323.py') diff --git a/tests/test_stream_xep_0323.py b/tests/test_stream_xep_0323.py index 94f1d638..fd2ad225 100644 --- a/tests/test_stream_xep_0323.py +++ b/tests/test_stream_xep_0323.py @@ -19,7 +19,7 @@ class TestStreamSensorData(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() @@ -29,12 +29,12 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - myDevice = Device("Device22") - myDevice._add_field(name="Temperature", typename="numeric", unit="°C") + 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"}) + 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.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5); self.recv(""" @@ -60,11 +60,11 @@ class TestStreamSensorData(SleekTest): - + - + """) def testRequestRejectAuth(self): @@ -73,7 +73,7 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - self.xmpp['xep_0323']._set_authenticated("darth@deathstar.com") + self.xmpp['xep_0323']._set_authenticated("darth@deathstar.com"); self.recv(""" @@ -101,8 +101,8 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - myDevice = Device("Device44") - self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) + myDevice = Device("Device44"); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5); print("."), @@ -118,7 +118,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -142,7 +142,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -157,11 +157,11 @@ class TestStreamSensorData(SleekTest): 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 = 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"}); - self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5); print("."), @@ -177,7 +177,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -201,7 +201,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -215,11 +215,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -227,7 +227,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestMultiTimestampSingleField(self): @@ -236,15 +236,15 @@ class TestStreamSensorData(SleekTest): 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"}) + 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) + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5); print("."), @@ -260,7 +260,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -274,11 +274,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -287,11 +287,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -299,7 +299,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestMultiTimestampAllFields(self): @@ -308,15 +308,15 @@ class TestStreamSensorData(SleekTest): 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"}) + 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) + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5); print("."), @@ -330,7 +330,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -344,11 +344,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -357,12 +357,12 @@ class TestStreamSensorData(SleekTest): - - + + - + """) self.send(""" @@ -370,7 +370,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestAPI(self): @@ -379,7 +379,7 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", callback=None) + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", callback=None); self.send(""" """) - self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33', 'Device22'], callback=None) + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33', 'Device22'], callback=None); self.send(""" """) - self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", fields=['Temperature', 'Voltage'], callback=None) + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", fields=['Temperature', 'Voltage'], callback=None); self.send(""" Invalid device Device22 - + """) time.sleep(.1) - self.failUnless(results == ["rejected"], - "Rejected callback was not properly executed") + self.failUnless(results == ["rejected"], + "Rejected callback was not properly executed"); def testRequestAcceptedAPI(self): @@ -466,12 +466,12 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = [] + results = []; def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): - results.append(result) + results.append(result); - self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33', 'Device22'], callback=my_callback) + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33', 'Device22'], callback=my_callback); self.send(""" - + """) time.sleep(.1) - self.failUnless(results == ["accepted"], - "Accepted callback was not properly executed") + self.failUnless(results == ["accepted"], + "Accepted callback was not properly executed"); def testRequestFieldsAPI(self): @@ -505,25 +505,25 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = [] - callback_data = {} + results = []; + callback_data = {}; def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): - results.append(result) + results.append(result); if result == "fields": - callback_data["nodeId"] = nodeId - callback_data["timestamp"] = timestamp - callback_data["error_msg"] = error_msg + callback_data["nodeId"] = nodeId; + callback_data["timestamp"] = timestamp; + callback_data["error_msg"] = error_msg; for f in fields: - callback_data["field_" + f['name']] = f + callback_data["field_" + f['name']] = f; t1= threading.Thread(name="request_data", target=self.xmpp['xep_0323'].request_data, - kwargs={"from_jid": "tester@localhost", - "to_jid": "you@google.com", - "nodeIds": ['Device33'], - "callback": my_callback}) - t1.start() + kwargs={"from_jid": "tester@localhost", + "to_jid": "you@google.com", + "nodeIds": ['Device33'], + "callback": my_callback}); + t1.start(); #self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); self.send(""" @@ -538,12 +538,12 @@ class TestStreamSensorData(SleekTest): """) self.recv(""" - - + """) self.recv(""" @@ -552,42 +552,42 @@ class TestStreamSensorData(SleekTest): - - + + - + """) self.recv(""" - + """) - t1.join() + t1.join(); time.sleep(.5) - self.failUnlessEqual(results, ["accepted","fields","done"]) + self.failUnlessEqual(results, ["accepted","fields","done"]); # self.assertIn("nodeId", callback_data); self.assertTrue("nodeId" in callback_data) - self.failUnlessEqual(callback_data["nodeId"], "Device33") + self.failUnlessEqual(callback_data["nodeId"], "Device33"); # self.assertIn("timestamp", callback_data); - self.assertTrue("timestamp" in callback_data) - self.failUnlessEqual(callback_data["timestamp"], "2000-01-01T00:01:02") + self.assertTrue("timestamp" in callback_data); + self.failUnlessEqual(callback_data["timestamp"], "2000-01-01T00:01:02"); #self.assertIn("field_Voltage", callback_data); - self.assertTrue("field_Voltage" in callback_data) - self.failUnlessEqual(callback_data["field_Voltage"], {"name": "Voltage", "value": "230.4", "typename": "numeric", "unit": "V", "flags": {"invoiced": "true"}}) + self.assertTrue("field_Voltage" in callback_data); + self.failUnlessEqual(callback_data["field_Voltage"], {"name": "Voltage", "value": "230.4", "typename": "numeric", "unit": "V", "flags": {"invoiced": "true"}}); #self.assertIn("field_TestBool", callback_data); - self.assertTrue("field_TestBool" in callback_data) - self.failUnlessEqual(callback_data["field_TestBool"], {"name": "TestBool", "value": "true", "typename": "boolean" }) + self.assertTrue("field_TestBool" in callback_data); + self.failUnlessEqual(callback_data["field_TestBool"], {"name": "TestBool", "value": "true", "typename": "boolean" }); def testServiceDiscoveryClient(self): self.stream_start(mode='client', plugins=['xep_0030', - 'xep_0323']) + 'xep_0323']); self.recv(""" - - + + """) def testServiceDiscoveryComponent(self): self.stream_start(mode='component', plugins=['xep_0030', - 'xep_0323']) + 'xep_0323']); self.recv(""" - - + + """) def testRequestTimeout(self): @@ -641,23 +641,23 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = [] - callback_data = {} + results = []; + callback_data = {}; def my_callback(from_jid, result, nodeId=None, timestamp=None, error_msg=None): - results.append(result) + results.append(result); if result == "failure": - callback_data["nodeId"] = nodeId - callback_data["timestamp"] = timestamp - callback_data["error_msg"] = error_msg + callback_data["nodeId"] = nodeId; + callback_data["timestamp"] = timestamp; + callback_data["error_msg"] = error_msg; t1= threading.Thread(name="request_data", target=self.xmpp['xep_0323'].request_data, - kwargs={"from_jid": "tester@localhost", - "to_jid": "you@google.com", - "nodeIds": ['Device33'], - "callback": my_callback}) - t1.start() + kwargs={"from_jid": "tester@localhost", + "to_jid": "you@google.com", + "nodeIds": ['Device33'], + "callback": my_callback}); + t1.start(); self.send(""" - + """) self.recv(""" @@ -688,31 +688,31 @@ class TestStreamSensorData(SleekTest): """) - t1.join() + t1.join(); time.sleep(.5) - self.failUnlessEqual(results, ["accepted","failure"]) + self.failUnlessEqual(results, ["accepted","failure"]); # self.assertIn("nodeId", callback_data); - self.assertTrue("nodeId" in callback_data) - self.failUnlessEqual(callback_data["nodeId"], "Device33") + self.assertTrue("nodeId" in callback_data); + self.failUnlessEqual(callback_data["nodeId"], "Device33"); # self.assertIn("timestamp", callback_data); - self.assertTrue("timestamp" in callback_data) - self.failUnlessEqual(callback_data["timestamp"], "2013-03-07T17:13:30") + self.assertTrue("timestamp" in callback_data); + self.failUnlessEqual(callback_data["timestamp"], "2013-03-07T17:13:30"); # self.assertIn("error_msg", callback_data); - self.assertTrue("error_msg" in callback_data) - self.failUnlessEqual(callback_data["error_msg"], "Timeout.") + self.assertTrue("error_msg" in callback_data); + self.failUnlessEqual(callback_data["error_msg"], "Timeout."); 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 = 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"}) + 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.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5); dtnow = datetime.datetime.now() ts_2sec = datetime.timedelta(0,2) @@ -729,7 +729,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -743,7 +743,7 @@ class TestStreamSensorData(SleekTest): - + """) self.send(""" @@ -752,11 +752,11 @@ class TestStreamSensorData(SleekTest): - + - + """) def testDelayedRequestFail(self): @@ -764,12 +764,12 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - myDevice = Device("Device22") - myDevice._add_field(name="Temperature", typename="numeric", unit="°C") + 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"}) + 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.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5); dtnow = datetime.datetime.now() ts_2sec = datetime.timedelta(0,2) @@ -792,7 +792,7 @@ class TestStreamSensorData(SleekTest): xml_stanza['rejected']['error'] = error_text self._filtered_stanza_check(""" - @@ -825,13 +825,13 @@ class TestStreamSensorData(SleekTest): 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"}) + 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) + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5); print("."), @@ -847,7 +847,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -861,11 +861,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -874,11 +874,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -886,7 +886,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestFieldTo(self): @@ -895,13 +895,13 @@ class TestStreamSensorData(SleekTest): 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"}) + 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) + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5); print("."), @@ -917,7 +917,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -931,11 +931,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -944,11 +944,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -956,7 +956,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestFieldFromTo(self): @@ -965,13 +965,13 @@ class TestStreamSensorData(SleekTest): 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"}) + 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) + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5); print("."), @@ -987,7 +987,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -1001,11 +1001,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -1013,7 +1013,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testDelayedRequestClient(self): @@ -1021,25 +1021,25 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = [] - callback_data = {} + results = []; + callback_data = {}; def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): - results.append(result) + results.append(result); if result == "fields": - callback_data["nodeId"] = nodeId - callback_data["timestamp"] = timestamp - callback_data["error_msg"] = error_msg + callback_data["nodeId"] = nodeId; + callback_data["timestamp"] = timestamp; + callback_data["error_msg"] = error_msg; for f in fields: - callback_data["field_" + f['name']] = f + callback_data["field_" + f['name']] = f; t1= threading.Thread(name="request_data", target=self.xmpp['xep_0323'].request_data, - kwargs={"from_jid": "tester@localhost", - "to_jid": "you@google.com", - "nodeIds": ['Device33'], - "callback": my_callback}) - t1.start() + kwargs={"from_jid": "tester@localhost", + "to_jid": "you@google.com", + "nodeIds": ['Device33'], + "callback": my_callback}); + t1.start(); #self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); self.send(""" @@ -1054,20 +1054,20 @@ class TestStreamSensorData(SleekTest): """) self.recv(""" - - + """) self.recv(""" - - """) + + """) self.recv(""" - - + + - + """) self.recv(""" - + """) - t1.join() + t1.join(); time.sleep(.5) - self.failUnlessEqual(results, ["queued","started","fields","done"]) + self.failUnlessEqual(results, ["queued","started","fields","done"]); # self.assertIn("nodeId", callback_data); - self.assertTrue("nodeId" in callback_data) - self.failUnlessEqual(callback_data["nodeId"], "Device33") + self.assertTrue("nodeId" in callback_data); + self.failUnlessEqual(callback_data["nodeId"], "Device33"); # self.assertIn("timestamp", callback_data); - self.assertTrue("timestamp" in callback_data) - self.failUnlessEqual(callback_data["timestamp"], "2000-01-01T00:01:02") + self.assertTrue("timestamp" in callback_data); + self.failUnlessEqual(callback_data["timestamp"], "2000-01-01T00:01:02"); # self.assertIn("field_Voltage", callback_data); - self.assertTrue("field_Voltage" in callback_data) - self.failUnlessEqual(callback_data["field_Voltage"], {"name": "Voltage", "value": "230.4", "typename": "numeric", "unit": "V", "flags": {"invoiced": "true"}}) + self.assertTrue("field_Voltage" in callback_data); + self.failUnlessEqual(callback_data["field_Voltage"], {"name": "Voltage", "value": "230.4", "typename": "numeric", "unit": "V", "flags": {"invoiced": "true"}}); # self.assertIn("field_TestBool", callback_data); - self.assertTrue("field_TestBool" in callback_data) - self.failUnlessEqual(callback_data["field_TestBool"], {"name": "TestBool", "value": "true", "typename": "boolean" }) + self.assertTrue("field_TestBool" in callback_data); + self.failUnlessEqual(callback_data["field_TestBool"], {"name": "TestBool", "value": "true", "typename": "boolean" }); def testRequestFieldsCancelAPI(self): @@ -1114,12 +1114,12 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = [] + results = []; def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): - results.append(result) + results.append(result); - session = self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback) + session = self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); self.send(""" - + """) - self.xmpp['xep_0323'].cancel_request(session=session) + self.xmpp['xep_0323'].cancel_request(session=session); self.send(""" -- cgit v1.2.3 From afc939708ff71e168f9204f1eab8823b7dc9f875 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Mon, 18 Aug 2014 00:52:24 +0200 Subject: cleanup semicolons, whitespace and mutable default arguments --- tests/test_stream_xep_0323.py | 424 +++++++++++++++++++++--------------------- 1 file changed, 212 insertions(+), 212 deletions(-) (limited to 'tests/test_stream_xep_0323.py') diff --git a/tests/test_stream_xep_0323.py b/tests/test_stream_xep_0323.py index fd2ad225..94f1d638 100644 --- a/tests/test_stream_xep_0323.py +++ b/tests/test_stream_xep_0323.py @@ -19,7 +19,7 @@ class TestStreamSensorData(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() @@ -29,12 +29,12 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - myDevice = Device("Device22"); - myDevice._add_field(name="Temperature", typename="numeric", unit="°C"); + 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"}); + 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.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5) self.recv(""" @@ -60,11 +60,11 @@ class TestStreamSensorData(SleekTest): - + - + """) def testRequestRejectAuth(self): @@ -73,7 +73,7 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - self.xmpp['xep_0323']._set_authenticated("darth@deathstar.com"); + self.xmpp['xep_0323']._set_authenticated("darth@deathstar.com") self.recv(""" @@ -101,8 +101,8 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - myDevice = Device("Device44"); - self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5); + myDevice = Device("Device44") + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -118,7 +118,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -142,7 +142,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -157,11 +157,11 @@ class TestStreamSensorData(SleekTest): 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 = 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"}) - self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -177,7 +177,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -201,7 +201,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -215,11 +215,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -227,7 +227,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestMultiTimestampSingleField(self): @@ -236,15 +236,15 @@ class TestStreamSensorData(SleekTest): 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"}); + 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); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -260,7 +260,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -274,11 +274,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -287,11 +287,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -299,7 +299,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestMultiTimestampAllFields(self): @@ -308,15 +308,15 @@ class TestStreamSensorData(SleekTest): 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"}); + 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); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -330,7 +330,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -344,11 +344,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -357,12 +357,12 @@ class TestStreamSensorData(SleekTest): - - + + - + """) self.send(""" @@ -370,7 +370,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestAPI(self): @@ -379,7 +379,7 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", callback=None); + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", callback=None) self.send(""" """) - self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33', 'Device22'], callback=None); + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33', 'Device22'], callback=None) self.send(""" """) - self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", fields=['Temperature', 'Voltage'], callback=None); + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", fields=['Temperature', 'Voltage'], callback=None) self.send(""" Invalid device Device22 - + """) time.sleep(.1) - self.failUnless(results == ["rejected"], - "Rejected callback was not properly executed"); + self.failUnless(results == ["rejected"], + "Rejected callback was not properly executed") def testRequestAcceptedAPI(self): @@ -466,12 +466,12 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = []; + results = [] def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): - results.append(result); + results.append(result) - self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33', 'Device22'], callback=my_callback); + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33', 'Device22'], callback=my_callback) self.send(""" - + """) time.sleep(.1) - self.failUnless(results == ["accepted"], - "Accepted callback was not properly executed"); + self.failUnless(results == ["accepted"], + "Accepted callback was not properly executed") def testRequestFieldsAPI(self): @@ -505,25 +505,25 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = []; - callback_data = {}; + results = [] + callback_data = {} def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): - results.append(result); + results.append(result) if result == "fields": - callback_data["nodeId"] = nodeId; - callback_data["timestamp"] = timestamp; - callback_data["error_msg"] = error_msg; + callback_data["nodeId"] = nodeId + callback_data["timestamp"] = timestamp + callback_data["error_msg"] = error_msg for f in fields: - callback_data["field_" + f['name']] = f; + callback_data["field_" + f['name']] = f t1= threading.Thread(name="request_data", target=self.xmpp['xep_0323'].request_data, - kwargs={"from_jid": "tester@localhost", - "to_jid": "you@google.com", - "nodeIds": ['Device33'], - "callback": my_callback}); - t1.start(); + kwargs={"from_jid": "tester@localhost", + "to_jid": "you@google.com", + "nodeIds": ['Device33'], + "callback": my_callback}) + t1.start() #self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); self.send(""" @@ -538,12 +538,12 @@ class TestStreamSensorData(SleekTest): """) self.recv(""" - - + """) self.recv(""" @@ -552,42 +552,42 @@ class TestStreamSensorData(SleekTest): - - + + - + """) self.recv(""" - + """) - t1.join(); + t1.join() time.sleep(.5) - self.failUnlessEqual(results, ["accepted","fields","done"]); + self.failUnlessEqual(results, ["accepted","fields","done"]) # self.assertIn("nodeId", callback_data); self.assertTrue("nodeId" in callback_data) - self.failUnlessEqual(callback_data["nodeId"], "Device33"); + self.failUnlessEqual(callback_data["nodeId"], "Device33") # self.assertIn("timestamp", callback_data); - self.assertTrue("timestamp" in callback_data); - self.failUnlessEqual(callback_data["timestamp"], "2000-01-01T00:01:02"); + self.assertTrue("timestamp" in callback_data) + self.failUnlessEqual(callback_data["timestamp"], "2000-01-01T00:01:02") #self.assertIn("field_Voltage", callback_data); - self.assertTrue("field_Voltage" in callback_data); - self.failUnlessEqual(callback_data["field_Voltage"], {"name": "Voltage", "value": "230.4", "typename": "numeric", "unit": "V", "flags": {"invoiced": "true"}}); + self.assertTrue("field_Voltage" in callback_data) + self.failUnlessEqual(callback_data["field_Voltage"], {"name": "Voltage", "value": "230.4", "typename": "numeric", "unit": "V", "flags": {"invoiced": "true"}}) #self.assertIn("field_TestBool", callback_data); - self.assertTrue("field_TestBool" in callback_data); - self.failUnlessEqual(callback_data["field_TestBool"], {"name": "TestBool", "value": "true", "typename": "boolean" }); + self.assertTrue("field_TestBool" in callback_data) + self.failUnlessEqual(callback_data["field_TestBool"], {"name": "TestBool", "value": "true", "typename": "boolean" }) def testServiceDiscoveryClient(self): self.stream_start(mode='client', plugins=['xep_0030', - 'xep_0323']); + 'xep_0323']) self.recv(""" - - + + """) def testServiceDiscoveryComponent(self): self.stream_start(mode='component', plugins=['xep_0030', - 'xep_0323']); + 'xep_0323']) self.recv(""" - - + + """) def testRequestTimeout(self): @@ -641,23 +641,23 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = []; - callback_data = {}; + results = [] + callback_data = {} def my_callback(from_jid, result, nodeId=None, timestamp=None, error_msg=None): - results.append(result); + results.append(result) if result == "failure": - callback_data["nodeId"] = nodeId; - callback_data["timestamp"] = timestamp; - callback_data["error_msg"] = error_msg; + callback_data["nodeId"] = nodeId + callback_data["timestamp"] = timestamp + callback_data["error_msg"] = error_msg t1= threading.Thread(name="request_data", target=self.xmpp['xep_0323'].request_data, - kwargs={"from_jid": "tester@localhost", - "to_jid": "you@google.com", - "nodeIds": ['Device33'], - "callback": my_callback}); - t1.start(); + kwargs={"from_jid": "tester@localhost", + "to_jid": "you@google.com", + "nodeIds": ['Device33'], + "callback": my_callback}) + t1.start() self.send(""" - + """) self.recv(""" @@ -688,31 +688,31 @@ class TestStreamSensorData(SleekTest): """) - t1.join(); + t1.join() time.sleep(.5) - self.failUnlessEqual(results, ["accepted","failure"]); + self.failUnlessEqual(results, ["accepted","failure"]) # self.assertIn("nodeId", callback_data); - self.assertTrue("nodeId" in callback_data); - self.failUnlessEqual(callback_data["nodeId"], "Device33"); + self.assertTrue("nodeId" in callback_data) + self.failUnlessEqual(callback_data["nodeId"], "Device33") # self.assertIn("timestamp", callback_data); - self.assertTrue("timestamp" in callback_data); - self.failUnlessEqual(callback_data["timestamp"], "2013-03-07T17:13:30"); + self.assertTrue("timestamp" in callback_data) + self.failUnlessEqual(callback_data["timestamp"], "2013-03-07T17:13:30") # self.assertIn("error_msg", callback_data); - self.assertTrue("error_msg" in callback_data); - self.failUnlessEqual(callback_data["error_msg"], "Timeout."); + self.assertTrue("error_msg" in callback_data) + self.failUnlessEqual(callback_data["error_msg"], "Timeout.") 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 = 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"}); + 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.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5) dtnow = datetime.datetime.now() ts_2sec = datetime.timedelta(0,2) @@ -729,7 +729,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -743,7 +743,7 @@ class TestStreamSensorData(SleekTest): - + """) self.send(""" @@ -752,11 +752,11 @@ class TestStreamSensorData(SleekTest): - + - + """) def testDelayedRequestFail(self): @@ -764,12 +764,12 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - myDevice = Device("Device22"); - myDevice._add_field(name="Temperature", typename="numeric", unit="°C"); + 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"}); + 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.xmpp['xep_0323'].register_node(nodeId="Device22", device=myDevice, commTimeout=0.5) dtnow = datetime.datetime.now() ts_2sec = datetime.timedelta(0,2) @@ -792,7 +792,7 @@ class TestStreamSensorData(SleekTest): xml_stanza['rejected']['error'] = error_text self._filtered_stanza_check(""" - @@ -825,13 +825,13 @@ class TestStreamSensorData(SleekTest): 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"}); + 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); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -847,7 +847,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -861,11 +861,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -874,11 +874,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -886,7 +886,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestFieldTo(self): @@ -895,13 +895,13 @@ class TestStreamSensorData(SleekTest): 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"}); + 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); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -917,7 +917,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -931,11 +931,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -944,11 +944,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -956,7 +956,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testRequestFieldFromTo(self): @@ -965,13 +965,13 @@ class TestStreamSensorData(SleekTest): 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"}); + 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); + self.xmpp['xep_0323'].register_node('Device44', myDevice, commTimeout=0.5) print("."), @@ -987,7 +987,7 @@ class TestStreamSensorData(SleekTest): """) self.send(""" - @@ -1001,11 +1001,11 @@ class TestStreamSensorData(SleekTest): - + - + """) self.send(""" @@ -1013,7 +1013,7 @@ class TestStreamSensorData(SleekTest): to='master@clayster.com/amr'> - + """) def testDelayedRequestClient(self): @@ -1021,25 +1021,25 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = []; - callback_data = {}; + results = [] + callback_data = {} def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): - results.append(result); + results.append(result) if result == "fields": - callback_data["nodeId"] = nodeId; - callback_data["timestamp"] = timestamp; - callback_data["error_msg"] = error_msg; + callback_data["nodeId"] = nodeId + callback_data["timestamp"] = timestamp + callback_data["error_msg"] = error_msg for f in fields: - callback_data["field_" + f['name']] = f; + callback_data["field_" + f['name']] = f t1= threading.Thread(name="request_data", target=self.xmpp['xep_0323'].request_data, - kwargs={"from_jid": "tester@localhost", - "to_jid": "you@google.com", - "nodeIds": ['Device33'], - "callback": my_callback}); - t1.start(); + kwargs={"from_jid": "tester@localhost", + "to_jid": "you@google.com", + "nodeIds": ['Device33'], + "callback": my_callback}) + t1.start() #self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); self.send(""" @@ -1054,20 +1054,20 @@ class TestStreamSensorData(SleekTest): """) self.recv(""" - - + """) self.recv(""" - - """) + + """) self.recv(""" - - + + - + """) self.recv(""" - + """) - t1.join(); + t1.join() time.sleep(.5) - self.failUnlessEqual(results, ["queued","started","fields","done"]); + self.failUnlessEqual(results, ["queued","started","fields","done"]) # self.assertIn("nodeId", callback_data); - self.assertTrue("nodeId" in callback_data); - self.failUnlessEqual(callback_data["nodeId"], "Device33"); + self.assertTrue("nodeId" in callback_data) + self.failUnlessEqual(callback_data["nodeId"], "Device33") # self.assertIn("timestamp", callback_data); - self.assertTrue("timestamp" in callback_data); - self.failUnlessEqual(callback_data["timestamp"], "2000-01-01T00:01:02"); + self.assertTrue("timestamp" in callback_data) + self.failUnlessEqual(callback_data["timestamp"], "2000-01-01T00:01:02") # self.assertIn("field_Voltage", callback_data); - self.assertTrue("field_Voltage" in callback_data); - self.failUnlessEqual(callback_data["field_Voltage"], {"name": "Voltage", "value": "230.4", "typename": "numeric", "unit": "V", "flags": {"invoiced": "true"}}); + self.assertTrue("field_Voltage" in callback_data) + self.failUnlessEqual(callback_data["field_Voltage"], {"name": "Voltage", "value": "230.4", "typename": "numeric", "unit": "V", "flags": {"invoiced": "true"}}) # self.assertIn("field_TestBool", callback_data); - self.assertTrue("field_TestBool" in callback_data); - self.failUnlessEqual(callback_data["field_TestBool"], {"name": "TestBool", "value": "true", "typename": "boolean" }); + self.assertTrue("field_TestBool" in callback_data) + self.failUnlessEqual(callback_data["field_TestBool"], {"name": "TestBool", "value": "true", "typename": "boolean" }) def testRequestFieldsCancelAPI(self): @@ -1114,12 +1114,12 @@ class TestStreamSensorData(SleekTest): plugins=['xep_0030', 'xep_0323']) - results = []; + results = [] def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): - results.append(result); + results.append(result) - session = self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); + session = self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback) self.send(""" - + """) - self.xmpp['xep_0323'].cancel_request(session=session); + self.xmpp['xep_0323'].cancel_request(session=session) self.send(""" -- cgit v1.2.3