diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_stanza_element.py | 4 | ||||
-rw-r--r-- | tests/test_stanza_xep_0004.py | 61 | ||||
-rw-r--r-- | tests/test_stanza_xep_0122.py | 189 | ||||
-rw-r--r-- | tests/test_stanza_xep_0323.py | 94 | ||||
-rw-r--r-- | tests/test_stanza_xep_0325.py | 75 | ||||
-rw-r--r-- | tests/test_stream_xep_0050.py | 11 | ||||
-rw-r--r-- | tests/test_stream_xep_0323.py | 237 | ||||
-rw-r--r-- | tests/test_stream_xep_0325.py | 80 |
8 files changed, 491 insertions, 260 deletions
diff --git a/tests/test_stanza_element.py b/tests/test_stanza_element.py index eb5791fc..0c49f201 100644 --- a/tests/test_stanza_element.py +++ b/tests/test_stanza_element.py @@ -385,7 +385,7 @@ class TestElementBase(SlixTest): interfaces = set(('bar', 'baz')) def setBar(self, value): - self._set_sub_text("path/to/only/bar", value); + self._set_sub_text("path/to/only/bar", value) def getBar(self): return self._get_sub_text("path/to/only/bar") @@ -394,7 +394,7 @@ class TestElementBase(SlixTest): self._del_sub("path/to/only/bar") def setBaz(self, value): - self._set_sub_text("path/to/just/baz", value); + self._set_sub_text("path/to/just/baz", value) def getBaz(self): return self._get_sub_text("path/to/just/baz") diff --git a/tests/test_stanza_xep_0004.py b/tests/test_stanza_xep_0004.py index b95b64ca..7b01b575 100644 --- a/tests/test_stanza_xep_0004.py +++ b/tests/test_stanza_xep_0004.py @@ -11,8 +11,8 @@ class TestDataForms(SlixTest): def setUp(self): register_stanza_plugin(Message, xep_0004.Form) - register_stanza_plugin(xep_0004.Form, xep_0004.FormField) - register_stanza_plugin(xep_0004.FormField, xep_0004.FieldOption) + register_stanza_plugin(xep_0004.Form, xep_0004.FormField, iterable=True) + register_stanza_plugin(xep_0004.FormField, xep_0004.FieldOption, iterable=True) def testMultipleInstructions(self): """Testing using multiple instructions elements in a data form.""" @@ -68,7 +68,7 @@ class TestDataForms(SlixTest): 'value': 'cool'}, {'label': 'Urgh!', 'value': 'urgh'}]} - form['fields'] = fields + form.set_fields(fields) self.check(msg, """ @@ -141,13 +141,13 @@ class TestDataForms(SlixTest): 'value': 'cool'}, {'label': 'Urgh!', 'value': 'urgh'}]} - form['fields'] = fields + form.set_fields(fields) form['type'] = 'submit' - form['values'] = {'f1': 'username', + form.set_values({'f1': 'username', 'f2': 'hunter2', 'f3': 'A long\nmultiline\nmessage', - 'f4': 'cool'} + 'f4': 'cool'}) self.check(form, """ <x xmlns="jabber:x:data" type="submit"> @@ -189,7 +189,7 @@ class TestDataForms(SlixTest): 'value': 'cool'}, {'label': 'Urgh!', 'value': 'urgh'}]} - form['fields'] = fields + form.set_fields(fields) form['type'] = 'cancel' @@ -197,5 +197,52 @@ class TestDataForms(SlixTest): <x xmlns="jabber:x:data" type="cancel" /> """) + def testReported(self): + msg = self.Message() + form = msg['form'] + form['type'] = 'result' + + form.add_reported(var='f1', ftype='text-single', label='Username') + + form.add_item({'f1': 'username@example.org'}) + + self.check(msg, """ + <message> + <x xmlns="jabber:x:data" type="result"> + <reported> + <field var="f1" type="text-single" label="Username" /> + </reported> + <item> + <field var="f1"> + <value>username@example.org</value> + </field> + </item> + </x> + </message> + """) + + def testSetReported(self): + msg = self.Message() + form = msg['form'] + form['type'] = 'result' + + reported = {'f1': { + 'var': 'f1', + 'type': 'text-single', + 'label': 'Username' + }} + + form.set_reported(reported) + + self.check(msg, """ + <message> + <x xmlns="jabber:x:data" type="result"> + <reported> + <field var="f1" type="text-single" label="Username" /> + </reported> + </x> + </message> + """) + suite = unittest.TestLoader().loadTestsFromTestCase(TestDataForms) diff --git a/tests/test_stanza_xep_0122.py b/tests/test_stanza_xep_0122.py new file mode 100644 index 00000000..0c032c05 --- /dev/null +++ b/tests/test_stanza_xep_0122.py @@ -0,0 +1,189 @@ +import unittest + +from slixmpp import Message +from slixmpp.test import SlixTest +import slixmpp.plugins.xep_0004 as xep_0004 +import slixmpp.plugins.xep_0122 as xep_0122 +from slixmpp.xmlstream import register_stanza_plugin + + +class TestDataForms(SlixTest): + + def setUp(self): + register_stanza_plugin(Message, xep_0004.Form) + register_stanza_plugin(xep_0004.Form, xep_0004.FormField, iterable=True) + register_stanza_plugin(xep_0004.FormField, xep_0004.FieldOption, iterable=True) + register_stanza_plugin(xep_0004.FormField, xep_0122.FormValidation) + + def test_basic_validation(self): + """Testing basic validation setting and getting.""" + msg = self.Message() + form = msg['form'] + field = form.add_field(var='f1', + ftype='text-single', + label='Text', + desc='A text field', + required=True, + value='Some text!') + + validation = field['validate'] + validation['datatype'] = 'xs:string' + validation.set_basic(True) + + self.check(msg, """ + <message> + <x xmlns="jabber:x:data" type="form"> + <field var="f1" type="text-single" label="Text"> + <desc>A text field</desc> + <required /> + <value>Some text!</value> + <validate xmlns="http://jabber.org/protocol/xdata-validate" datatype="xs:string"> + <basic/> + </validate> + </field> + </x> + </message> + """) + + self.assertTrue(validation.get_basic()) + self.assertFalse(validation.get_open()) + self.assertFalse(validation.get_range()) + self.assertFalse(validation.get_regex()) + + def test_open_validation(self): + """Testing open validation setting and getting.""" + msg = self.Message() + form = msg['form'] + field = form.add_field(var='f1', + ftype='text-single', + label='Text', + desc='A text field', + required=True, + value='Some text!') + + validation = field['validate'] + validation.set_open(True) + + self.check(msg, """ + <message> + <x xmlns="jabber:x:data" type="form"> + <field var="f1" type="text-single" label="Text"> + <desc>A text field</desc> + <required /> + <value>Some text!</value> + <validate xmlns="http://jabber.org/protocol/xdata-validate"> + <open /> + </validate> + </field> + </x> + </message> + """) + + self.assertFalse(validation.get_basic()) + self.assertTrue(validation.get_open()) + self.assertFalse(validation.get_range()) + self.assertFalse(validation.get_regex()) + + def test_regex_validation(self): + """Testing regex validation setting and getting.""" + msg = self.Message() + form = msg['form'] + field = form.add_field(var='f1', + ftype='text-single', + label='Text', + desc='A text field', + required=True, + value='Some text!') + + regex_value = '[0-9]+' + + validation = field['validate'] + validation.set_regex(regex_value) + + self.check(msg, """ + <message> + <x xmlns="jabber:x:data" type="form"> + <field var="f1" type="text-single" label="Text"> + <desc>A text field</desc> + <required /> + <value>Some text!</value> + <validate xmlns="http://jabber.org/protocol/xdata-validate"> + <regex>[0-9]+</regex> + </validate> + </field> + </x> + </message> + """) + + self.assertFalse(validation.get_basic()) + self.assertFalse(validation.get_open()) + self.assertFalse(validation.get_range()) + self.assertTrue(validation.get_regex()) + + self.assertEqual(regex_value, validation.get_regex()) + + def test_range_validation(self): + """Testing range validation setting and getting.""" + msg = self.Message() + form = msg['form'] + field = form.add_field(var='f1', + ftype='text-single', + label='Text', + desc='A text field', + required=True, + value='Some text!') + + validation = field['validate'] + validation.set_range(True, minimum=0, maximum=10) + + self.check(msg, """ + <message> + <x xmlns="jabber:x:data" type="form"> + <field var="f1" type="text-single" label="Text"> + <desc>A text field</desc> + <required /> + <value>Some text!</value> + <validate xmlns="http://jabber.org/protocol/xdata-validate"> + <range min="0" max="10" /> + </validate> + </field> + </x> + </message> + """) + + self.assertDictEqual(dict(minimum=str(0), maximum=str(10)), validation.get_range()) + + def test_reported_field_validation(self): + """ + Testing adding validation to the field when it's stored in the reported. + :return: + """ + msg = self.Message() + form = msg['form'] + field = form.add_reported(var='f1', ftype='text-single', label='Text') + validation = field['validate'] + validation.set_basic(True) + + form.add_item({'f1': 'Some text!'}) + + self.check(msg, """ + <message> + <x xmlns="jabber:x:data" type="form"> + <reported> + <field var="f1" type="text-single" label="Text"> + <validate xmlns="http://jabber.org/protocol/xdata-validate"> + <basic /> + </validate> + </field> + </reported> + <item> + <field var="f1"> + <value>Some text!</value> + </field> + </item> + </x> + </message> + """) + + +suite = unittest.TestLoader().loadTestsFromTestCase(TestDataForms) diff --git a/tests/test_stanza_xep_0323.py b/tests/test_stanza_xep_0323.py index 95fb138b..991481d7 100644 --- a/tests/test_stanza_xep_0323.py +++ b/tests/test_stanza_xep_0323.py @@ -7,7 +7,6 @@ namespace='sn' class TestSensorDataStanzas(SlixTest): - def setUp(self): pass #register_stanza_plugin(Iq, xep_0323.stanza.Request) @@ -59,8 +58,8 @@ class TestSensorDataStanzas(SlixTest): iq['req']['momentary'] = 'true' - iq['req'].add_node("Device02", "Source02", "CacheType"); - iq['req'].add_node("Device44"); + iq['req'].add_node("Device02", "Source02", "CacheType") + iq['req'].add_node("Device44") self.check(iq,""" <iq type='get' @@ -75,7 +74,7 @@ class TestSensorDataStanzas(SlixTest): """ ) - iq['req'].del_node("Device02"); + iq['req'].del_node("Device02") self.check(iq,""" <iq type='get' @@ -89,7 +88,7 @@ class TestSensorDataStanzas(SlixTest): """ ) - iq['req'].del_nodes(); + iq['req'].del_nodes() self.check(iq,""" <iq type='get' @@ -115,8 +114,8 @@ class TestSensorDataStanzas(SlixTest): iq['req']['momentary'] = 'true' - iq['req'].add_field("Top temperature"); - iq['req'].add_field("Bottom temperature"); + iq['req'].add_field("Top temperature") + iq['req'].add_field("Bottom temperature") self.check(iq,""" <iq type='get' @@ -237,12 +236,12 @@ class TestSensorDataStanzas(SlixTest): msg['to'] = 'master@clayster.com/amr' msg['fields']['seqnr'] = '1' - node = msg['fields'].add_node("Device02"); - ts = node.add_timestamp("2013-03-07T16:24:30"); + node = msg['fields'].add_node("Device02") + ts = node.add_timestamp("2013-03-07T16:24:30") - data = ts.add_data(typename="numeric", name="Temperature", value="-12.42", unit='K'); - data['momentary'] = 'true'; - data['automaticReadout'] = 'true'; + data = ts.add_data(typename="numeric", name="Temperature", value="-12.42", unit='K') + data['momentary'] = 'true' + data['automaticReadout'] = 'true' self.check(msg,""" <message from='device@clayster.com' @@ -258,10 +257,9 @@ class TestSensorDataStanzas(SlixTest): """ ) - node = msg['fields'].add_node("EmptyDevice"); - node = msg['fields'].add_node("Device04"); - ts = node.add_timestamp("EmptyTimestamp"); - + node = msg['fields'].add_node("EmptyDevice") + node = msg['fields'].add_node("Device04") + ts = node.add_timestamp("EmptyTimestamp") self.check(msg,""" <message from='device@clayster.com' @@ -281,32 +279,32 @@ class TestSensorDataStanzas(SlixTest): """ ) - node = msg['fields'].add_node("Device77"); - ts = node.add_timestamp("2013-05-03T12:00:01"); - data = ts.add_data(typename="numeric", name="Temperature", value="-12.42", unit='K'); - data['historicalDay'] = 'true'; - data = ts.add_data(typename="numeric", name="Speed", value="312.42", unit='km/h'); - data['historicalWeek'] = 'false'; - data = ts.add_data(typename="string", name="Temperature name", value="Bottom oil"); - data['historicalMonth'] = 'true'; - data = ts.add_data(typename="string", name="Speed name", value="Top speed"); - data['historicalQuarter'] = 'false'; - data = ts.add_data(typename="dateTime", name="T1", value="1979-01-01T00:00:00"); - data['historicalYear'] = 'true'; - data = ts.add_data(typename="dateTime", name="T2", value="2000-01-01T01:02:03"); - data['historicalOther'] = 'false'; - data = ts.add_data(typename="timeSpan", name="TS1", value="P5Y"); - data['missing'] = 'true'; - data = ts.add_data(typename="timeSpan", name="TS2", value="PT2M1S"); - data['manualEstimate'] = 'false'; - data = ts.add_data(typename="enum", name="top color", value="red", dataType="string"); - data['invoiced'] = 'true'; - data = ts.add_data(typename="enum", name="bottom color", value="black", dataType="string"); - data['powerFailure'] = 'false'; - data = ts.add_data(typename="boolean", name="Temperature real", value="false"); - data['historicalDay'] = 'true'; - data = ts.add_data(typename="boolean", name="Speed real", value="true"); - data['historicalWeek'] = 'false'; + node = msg['fields'].add_node("Device77") + ts = node.add_timestamp("2013-05-03T12:00:01") + data = ts.add_data(typename="numeric", name="Temperature", value="-12.42", unit='K') + data['historicalDay'] = 'true' + data = ts.add_data(typename="numeric", name="Speed", value="312.42", unit='km/h') + data['historicalWeek'] = 'false' + data = ts.add_data(typename="string", name="Temperature name", value="Bottom oil") + data['historicalMonth'] = 'true' + data = ts.add_data(typename="string", name="Speed name", value="Top speed") + data['historicalQuarter'] = 'false' + data = ts.add_data(typename="dateTime", name="T1", value="1979-01-01T00:00:00") + data['historicalYear'] = 'true' + data = ts.add_data(typename="dateTime", name="T2", value="2000-01-01T01:02:03") + data['historicalOther'] = 'false' + data = ts.add_data(typename="timeSpan", name="TS1", value="P5Y") + data['missing'] = 'true' + data = ts.add_data(typename="timeSpan", name="TS2", value="PT2M1S") + data['manualEstimate'] = 'false' + data = ts.add_data(typename="enum", name="top color", value="red", dataType="string") + data['invoiced'] = 'true' + data = ts.add_data(typename="enum", name="bottom color", value="black", dataType="string") + data['powerFailure'] = 'false' + data = ts.add_data(typename="boolean", name="Temperature real", value="false") + data['historicalDay'] = 'true' + data = ts.add_data(typename="boolean", name="Speed real", value="true") + data['historicalWeek'] = 'false' self.check(msg,""" <message from='device@clayster.com' @@ -344,19 +342,17 @@ class TestSensorDataStanzas(SlixTest): def testTimestamp(self): - msg = self.Message(); + msg = self.Message() msg['from'] = 'device@clayster.com' msg['to'] = 'master@clayster.com/amr' msg['fields']['seqnr'] = '1' - node = msg['fields'].add_node("Device02"); - node = msg['fields'].add_node("Device03"); - - ts = node.add_timestamp("2013-03-07T16:24:30"); - ts = node.add_timestamp("2013-03-07T16:24:31"); - + node = msg['fields'].add_node("Device02") + node = msg['fields'].add_node("Device03") + ts = node.add_timestamp("2013-03-07T16:24:30") + ts = node.add_timestamp("2013-03-07T16:24:31") self.check(msg,""" <message from='device@clayster.com' diff --git a/tests/test_stanza_xep_0325.py b/tests/test_stanza_xep_0325.py index 75a45907..3e388ac3 100644 --- a/tests/test_stanza_xep_0325.py +++ b/tests/test_stanza_xep_0325.py @@ -16,7 +16,6 @@ namespace='sn' class TestControlStanzas(SlixTest): - def setUp(self): pass @@ -29,8 +28,8 @@ class TestControlStanzas(SlixTest): iq['from'] = 'master@clayster.com/amr' iq['to'] = 'device@clayster.com' iq['id'] = '1' - iq['set'].add_node("Device02", "Source02", "MyCacheType"); - iq['set'].add_node("Device15"); + iq['set'].add_node("Device02", "Source02", "MyCacheType") + iq['set'].add_node("Device15") iq['set'].add_data("Tjohej", "boolean", "true") self.check(iq,""" @@ -47,7 +46,7 @@ class TestControlStanzas(SlixTest): """ ) - iq['set'].del_node("Device02"); + iq['set'].del_node("Device02") self.check(iq,""" <iq type='set' @@ -62,7 +61,7 @@ class TestControlStanzas(SlixTest): """ ) - iq['set'].del_nodes(); + iq['set'].del_nodes() self.check(iq,""" <iq type='set' @@ -84,8 +83,8 @@ class TestControlStanzas(SlixTest): msg = self.Message() msg['from'] = 'master@clayster.com/amr' msg['to'] = 'device@clayster.com' - msg['set'].add_node("Device02"); - msg['set'].add_node("Device15"); + msg['set'].add_node("Device02") + msg['set'].add_node("Device15") msg['set'].add_data("Tjohej", "boolean", "true") self.check(msg,""" @@ -111,7 +110,7 @@ class TestControlStanzas(SlixTest): iq['from'] = 'master@clayster.com/amr' iq['to'] = 'device@clayster.com' iq['id'] = '8' - iq['setResponse']['responseCode'] = "OK"; + iq['setResponse']['responseCode'] = "OK" self.check(iq,""" <iq type='result' @@ -128,10 +127,9 @@ class TestControlStanzas(SlixTest): iq['from'] = 'master@clayster.com/amr' iq['to'] = 'device@clayster.com' iq['id'] = '9' - iq['setResponse']['responseCode'] = "OtherError"; - iq['setResponse']['error']['var'] = "Output"; - iq['setResponse']['error']['text'] = "Test of other error.!"; - + iq['setResponse']['responseCode'] = "OtherError" + iq['setResponse']['error']['var'] = "Output" + iq['setResponse']['error']['text'] = "Test of other error.!" self.check(iq,""" <iq type='error' @@ -150,11 +148,10 @@ class TestControlStanzas(SlixTest): iq['from'] = 'master@clayster.com/amr' iq['to'] = 'device@clayster.com' iq['id'] = '9' - iq['setResponse']['responseCode'] = "NotFound"; - iq['setResponse'].add_node("Device17", "Source09"); - iq['setResponse'].add_node("Device18", "Source09"); - iq['setResponse'].add_data("Tjohopp"); - + iq['setResponse']['responseCode'] = "NotFound" + iq['setResponse'].add_node("Device17", "Source09") + iq['setResponse'].add_node("Device18", "Source09") + iq['setResponse'].add_data("Tjohopp") self.check(iq,""" <iq type='error' @@ -179,38 +176,38 @@ class TestControlStanzas(SlixTest): iq['from'] = 'master@clayster.com/amr' iq['to'] = 'device@clayster.com' iq['id'] = '1' - iq['set'].add_node("Device02", "Source02", "MyCacheType"); - iq['set'].add_node("Device15"); + iq['set'].add_node("Device02", "Source02", "MyCacheType") + iq['set'].add_node("Device15") - iq['set'].add_data("Tjohej", "boolean", "true"); - iq['set'].add_data("Tjohej2", "boolean", "false"); + iq['set'].add_data("Tjohej", "boolean", "true") + iq['set'].add_data("Tjohej2", "boolean", "false") - iq['set'].add_data("TjohejC", "color", "FF00FF"); - iq['set'].add_data("TjohejC2", "color", "00FF00"); + iq['set'].add_data("TjohejC", "color", "FF00FF") + iq['set'].add_data("TjohejC2", "color", "00FF00") - iq['set'].add_data("TjohejS", "string", "String1"); - iq['set'].add_data("TjohejS2", "string", "String2"); + iq['set'].add_data("TjohejS", "string", "String1") + iq['set'].add_data("TjohejS2", "string", "String2") - iq['set'].add_data("TjohejDate", "date", "2012-01-01"); - iq['set'].add_data("TjohejDate2", "date", "1900-12-03"); + iq['set'].add_data("TjohejDate", "date", "2012-01-01") + iq['set'].add_data("TjohejDate2", "date", "1900-12-03") - iq['set'].add_data("TjohejDateT4", "dateTime", "1900-12-03 12:30"); - iq['set'].add_data("TjohejDateT2", "dateTime", "1900-12-03 11:22"); + iq['set'].add_data("TjohejDateT4", "dateTime", "1900-12-03 12:30") + iq['set'].add_data("TjohejDateT2", "dateTime", "1900-12-03 11:22") - iq['set'].add_data("TjohejDouble2", "double", "200.22"); - iq['set'].add_data("TjohejDouble3", "double", "-12232131.3333"); + iq['set'].add_data("TjohejDouble2", "double", "200.22") + iq['set'].add_data("TjohejDouble3", "double", "-12232131.3333") - iq['set'].add_data("TjohejDur", "duration", "P5Y"); - iq['set'].add_data("TjohejDur2", "duration", "PT2M1S"); + iq['set'].add_data("TjohejDur", "duration", "P5Y") + iq['set'].add_data("TjohejDur2", "duration", "PT2M1S") - iq['set'].add_data("TjohejInt", "int", "1"); - iq['set'].add_data("TjohejInt2", "int", "-42"); + iq['set'].add_data("TjohejInt", "int", "1") + iq['set'].add_data("TjohejInt2", "int", "-42") - iq['set'].add_data("TjohejLong", "long", "123456789098"); - iq['set'].add_data("TjohejLong2", "long", "-90983243827489374"); + iq['set'].add_data("TjohejLong", "long", "123456789098") + iq['set'].add_data("TjohejLong2", "long", "-90983243827489374") - iq['set'].add_data("TjohejTime", "time", "23:59"); - iq['set'].add_data("TjohejTime2", "time", "12:00"); + iq['set'].add_data("TjohejTime", "time", "23:59") + iq['set'].add_data("TjohejTime2", "time", "12:00") self.check(iq,""" <iq type='set' diff --git a/tests/test_stream_xep_0050.py b/tests/test_stream_xep_0050.py index 530dba9f..6ebf88a9 100644 --- a/tests/test_stream_xep_0050.py +++ b/tests/test_stream_xep_0050.py @@ -119,7 +119,8 @@ class TestAdHocCommands(SlixTest): def handle_command(iq, session): def handle_form(form, session): - results.append(form['values']['foo']) + results.append(form.get_values()['foo']) + session['payload'] = None form = self.xmpp['xep_0004'].makeForm('form') form.addField(var='foo', ftype='text-single', label='Foo') @@ -191,10 +192,11 @@ class TestAdHocCommands(SlixTest): def handle_command(iq, session): def handle_step2(form, session): - results.append(form['values']['bar']) + results.append(form.get_values()['bar']) + session['payload'] = None def handle_step1(form, session): - results.append(form['values']['foo']) + results.append(form.get_values()['foo']) form = self.xmpp['xep_0004'].makeForm('form') form.addField(var='bar', ftype='text-single', label='Bar') @@ -426,7 +428,8 @@ class TestAdHocCommands(SlixTest): def handle_form(forms, session): for form in forms: - results.append(form['values']['FORM_TYPE']) + results.append(form.get_values()['FORM_TYPE']) + session['payload'] = None form1 = self.xmpp['xep_0004'].makeForm('form') form1.addField(var='FORM_TYPE', ftype='hidden', value='form_1') diff --git a/tests/test_stream_xep_0323.py b/tests/test_stream_xep_0323.py index f92c4553..42230e1f 100644 --- a/tests/test_stream_xep_0323.py +++ b/tests/test_stream_xep_0323.py @@ -19,7 +19,7 @@ class TestStreamSensorData(SlixTest): 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(SlixTest): 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(""" <iq type='get' @@ -73,7 +73,7 @@ class TestStreamSensorData(SlixTest): 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(""" <iq type='get' @@ -101,8 +101,8 @@ class TestStreamSensorData(SlixTest): 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("."), @@ -157,11 +157,11 @@ class TestStreamSensorData(SlixTest): 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("."), @@ -236,15 +236,15 @@ class TestStreamSensorData(SlixTest): 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("."), @@ -308,15 +308,15 @@ class TestStreamSensorData(SlixTest): 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("."), @@ -379,7 +379,7 @@ class TestStreamSensorData(SlixTest): 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(""" <iq type='get' @@ -390,7 +390,7 @@ class TestStreamSensorData(SlixTest): </iq> """) - 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(""" <iq type='get' @@ -404,7 +404,7 @@ class TestStreamSensorData(SlixTest): </iq> """) - 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(""" <iq type='get' @@ -424,13 +424,13 @@ class TestStreamSensorData(SlixTest): plugins=['xep_0030', 'xep_0323']) - results = []; + results = [] def my_callback(from_jid, result, nodeId=None, timestamp=None, fields=None, error_msg=None): if (result == "rejected") and (error_msg == "Invalid device Device22"): - results.append("rejected"); + results.append("rejected") - 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(""" <iq type='get' @@ -456,7 +456,7 @@ class TestStreamSensorData(SlixTest): """) self.failUnless(results == ["rejected"], - "Rejected callback was not properly executed"); + "Rejected callback was not properly executed") def testRequestAcceptedAPI(self): @@ -464,12 +464,12 @@ class TestStreamSensorData(SlixTest): 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(""" <iq type='get' @@ -493,7 +493,7 @@ class TestStreamSensorData(SlixTest): """) self.failUnless(results == ["accepted"], - "Accepted callback was not properly executed"); + "Accepted callback was not properly executed") def testRequestFieldsAPI(self): @@ -501,17 +501,17 @@ class TestStreamSensorData(SlixTest): 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 self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", @@ -560,24 +560,24 @@ class TestStreamSensorData(SlixTest): </message> """) - 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(""" <iq type='get' @@ -602,7 +602,7 @@ class TestStreamSensorData(SlixTest): def testServiceDiscoveryComponent(self): self.stream_start(mode='component', plugins=['xep_0030', - 'xep_0323']); + 'xep_0323']) self.recv(""" <iq type='get' @@ -631,21 +631,20 @@ class TestStreamSensorData(SlixTest): 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 self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback) - self.send(""" <iq type='get' from='tester@localhost' @@ -677,26 +676,26 @@ class TestStreamSensorData(SlixTest): 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) @@ -748,12 +747,12 @@ class TestStreamSensorData(SlixTest): 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) @@ -809,13 +808,13 @@ class TestStreamSensorData(SlixTest): 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("."), @@ -879,13 +878,13 @@ class TestStreamSensorData(SlixTest): 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("."), @@ -949,13 +948,13 @@ class TestStreamSensorData(SlixTest): 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("."), @@ -1005,17 +1004,17 @@ class TestStreamSensorData(SlixTest): 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 self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", @@ -1073,17 +1072,17 @@ class TestStreamSensorData(SlixTest): 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): @@ -1092,12 +1091,12 @@ class TestStreamSensorData(SlixTest): 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(""" <iq type='get' @@ -1119,7 +1118,7 @@ class TestStreamSensorData(SlixTest): </iq> """) - self.xmpp['xep_0323'].cancel_request(session=session); + self.xmpp['xep_0323'].cancel_request(session=session) self.send(""" <iq type='get' @@ -1139,19 +1138,19 @@ class TestStreamSensorData(SlixTest): </iq> """) - self.failUnlessEqual(results, ["accepted","cancelled"]); + self.failUnlessEqual(results, ["accepted","cancelled"]) def testDelayedRequestCancel(self): self.stream_start(mode='component', plugins=['xep_0030', 'xep_0323']) - myDevice = Device("Device22"); - myDevice._add_field(name="Temperature", typename="numeric", unit="°C"); + myDevice = 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) diff --git a/tests/test_stream_xep_0325.py b/tests/test_stream_xep_0325.py index d27ee5a7..600bfa64 100644 --- a/tests/test_stream_xep_0325.py +++ b/tests/test_stream_xep_0325.py @@ -28,7 +28,7 @@ class TestStreamControl(SlixTest): 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(SlixTest): 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' @@ -63,23 +63,23 @@ class TestStreamControl(SlixTest): </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' @@ -102,8 +102,8 @@ class TestStreamControl(SlixTest): </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' @@ -128,20 +128,20 @@ class TestStreamControl(SlixTest): </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' @@ -166,18 +166,18 @@ class TestStreamControl(SlixTest): </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 @@ -191,17 +191,17 @@ class TestStreamControl(SlixTest): time.sleep(0.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 @@ -223,16 +223,16 @@ class TestStreamControl(SlixTest): 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' @@ -265,16 +265,16 @@ class TestStreamControl(SlixTest): 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' @@ -301,12 +301,12 @@ class TestStreamControl(SlixTest): </iq> """) - 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' @@ -331,7 +331,7 @@ class TestStreamControl(SlixTest): def testServiceDiscoveryComponent(self): self.stream_start(mode='component', plugins=['xep_0030', - 'xep_0325']); + 'xep_0325']) self.recv(""" <iq type='get' |