cdp-client 2.1.1__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. cdp_client-2.2.0/PKG-INFO +472 -0
  2. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client/cdp.py +10 -10
  3. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client/tests/fake_data.py +0 -1
  4. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client/tests/test_client.py +2 -2
  5. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client/tests/test_node.py +15 -15
  6. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client/tests/test_nodetree.py +6 -6
  7. cdp_client-2.2.0/cdp_client.egg-info/PKG-INFO +472 -0
  8. cdp_client-2.2.0/cdp_client.egg-info/requires.txt +4 -0
  9. {cdp-client-2.1.1 → cdp_client-2.2.0}/setup.py +10 -6
  10. cdp-client-2.1.1/PKG-INFO +0 -464
  11. cdp-client-2.1.1/cdp_client.egg-info/PKG-INFO +0 -464
  12. cdp-client-2.1.1/cdp_client.egg-info/requires.txt +0 -4
  13. {cdp-client-2.1.1 → cdp_client-2.2.0}/LICENSE.txt +0 -0
  14. {cdp-client-2.1.1 → cdp_client-2.2.0}/MANIFEST.in +0 -0
  15. {cdp-client-2.1.1 → cdp_client-2.2.0}/README.rst +0 -0
  16. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client/__init__.py +0 -0
  17. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client/cdp_pb2.py +0 -0
  18. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client/tests/__init__.py +0 -0
  19. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client/tests/test_connection.py +0 -0
  20. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client/tests/test_main.py +0 -0
  21. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client/tests/test_requests.py +0 -0
  22. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client.egg-info/SOURCES.txt +0 -0
  23. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client.egg-info/dependency_links.txt +0 -0
  24. {cdp-client-2.1.1 → cdp_client-2.2.0}/cdp_client.egg-info/top_level.txt +0 -0
  25. {cdp-client-2.1.1 → cdp_client-2.2.0}/setup.cfg +0 -0
@@ -0,0 +1,472 @@
1
+ Metadata-Version: 2.1
2
+ Name: cdp-client
3
+ Version: 2.2.0
4
+ Summary: Provides an API that allows to interact with CDP applications
5
+ Home-page: https://github.com/CDPTechnologies/PythonCDPClient
6
+ Author: CDP Technologies AS
7
+ Author-email: info@cdptech.com
8
+ License: MIT
9
+ Keywords: cdp cdpstudio studio client cdp-client cdp_client
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Topic :: Software Development
16
+ Classifier: Programming Language :: Python :: 2.7
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.3
19
+ Classifier: Programming Language :: Python :: 3.4
20
+ Classifier: Programming Language :: Python :: 3.5
21
+ Classifier: Programming Language :: Python :: 3.6
22
+ Classifier: Programming Language :: Python :: 3.7
23
+ Classifier: Programming Language :: Python :: 3.8
24
+ Classifier: Programming Language :: Python :: 3.9
25
+ Classifier: Programming Language :: Python :: 3.10
26
+ License-File: LICENSE.txt
27
+ Requires-Dist: promise
28
+ Requires-Dist: websocket-client
29
+ Requires-Dist: protobuf
30
+ Requires-Dist: mock
31
+
32
+ CDP-Client
33
+ ==========
34
+
35
+ A simple python interface for the CDP Studio development platform that allows Python scripts to interact with CDP Applications - retrieve CDP Application structures and read-write object values. For more information about CDP Studio see https://cdpstudio.com/
36
+
37
+ The API makes heavy use of promise library for asynchronous operations. For more information see https://pypi.python.org/pypi/promise
38
+
39
+ Installation
40
+ ------------
41
+
42
+ ::
43
+
44
+ $ pip install cdp-client
45
+
46
+ Usage
47
+ -----
48
+
49
+ The example below shows how you subscribe to CDP signal value changes.
50
+
51
+ .. code:: python
52
+
53
+ from cdp_client import cdp
54
+
55
+ def on_value_changed(value, timestamp):
56
+ print(value)
57
+
58
+ def subscribe_to_value_changes(node):
59
+ node.subscribe_to_value_changes(on_value_changed)
60
+
61
+ client = cdp.Client(host='127.0.0.1')
62
+ client.find_node('AppName.ComponentName.SignalName').then(subscribe_to_value_changes)
63
+ client.run_event_loop()
64
+
65
+ API
66
+ ---
67
+
68
+ Before all examples, you need:
69
+
70
+ .. code:: python
71
+
72
+ from cdp_client import cdp
73
+
74
+ Global API
75
+ ~~~~~~~~~~
76
+
77
+ Client(host, port, auto_reconnect, notification_listener, encryption_parameters)
78
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79
+
80
+ - Arguments
81
+
82
+ host - String for hosts ip address
83
+
84
+ port - Optional port number to connect to. If not specified default port 7689 is used.
85
+
86
+ auto_reconnect - Optional argument to enable/disable automatic reconnect when connection is lost. Defaults to True if not specified.
87
+
88
+ notification_listener - NotificationListener object whose methods are called on different connection events (e.g. when server requires credentials)
89
+
90
+ encryption_parameters - Optional argument to set encryption and its parameters, TLS certificates verification etc. Parameter is compatible with python websocket client 'sslopt' parameter. For more information see https://pypi.org/project/websocket_client
91
+
92
+ - Returns
93
+
94
+ The connected client object.
95
+
96
+ - Usage example
97
+
98
+ .. code:: python
99
+
100
+ client = cdp.Client(host='127.0.0.1')
101
+
102
+ - Usage example with password authentication
103
+
104
+ .. code:: python
105
+
106
+ class MyListener(cdp.NotificationListener):
107
+ def credentials_requested(self, request):
108
+ if request.user_auth_result().code() == cdp.AuthResultCode.CREDENTIALS_REQUIRED:
109
+ # Do something to gather username and password variables (either sync or async way) and then call:
110
+ request.accept({'Username': 'test', 'Password': '12345678'});
111
+
112
+ client = cdp.Client(host='127.0.0.1', notification_listener=MyListener())
113
+
114
+ - Usage example with password authentication and encryption in use, without server certificate verification
115
+
116
+ .. code:: python
117
+
118
+ import ssl
119
+
120
+ class MyListener(cdp.NotificationListener):
121
+ def credentials_requested(self, request):
122
+ if request.user_auth_result().code() == cdp.AuthResultCode.CREDENTIALS_REQUIRED:
123
+ # Do something to gather username and password variables (either sync or async way) and then call:
124
+ request.accept({'Username': 'test', 'Password': '12345678'});
125
+
126
+ client = cdp.Client(host='127.0.0.1', notification_listener=MyListener(),
127
+ encryption_parameters={'use_encryption': True, 'cert_reqs': ssl.CERT_NONE})
128
+
129
+
130
+ - Usage example with password authentication and encryption in use, with server certificate verification
131
+
132
+ .. code:: python
133
+
134
+ import ssl
135
+
136
+ class MyListener(cdp.NotificationListener):
137
+ def credentials_requested(self, request):
138
+ if request.user_auth_result().code() == cdp.AuthResultCode.CREDENTIALS_REQUIRED:
139
+ # Do something to gather username and password variables (either sync or async way) and then call:
140
+ request.accept({'Username': 'test', 'Password': '12345678'});
141
+
142
+ client = cdp.Client(host='127.0.0.1', notification_listener=MyListener(),
143
+ encryption_parameters={'use_encryption': True,
144
+ 'cert_reqs': ssl.CERT_REQUIRED,
145
+ 'ca_certs': 'StudioAPI.crt',
146
+ 'check_hostname': False},
147
+
148
+ Instance Methods / Client
149
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
150
+
151
+ client.root_node()
152
+ ^^^^^^^^^^^^^^^^^^
153
+
154
+ Gets the application Node object of the connected application.
155
+
156
+ - Returns
157
+
158
+ Promise containing root Node object when fulfilled.
159
+
160
+ - Usage
161
+
162
+ .. code:: python
163
+
164
+ client.root_node().then(on_success).catch(on_error)
165
+
166
+ client.find_node(path)
167
+ ^^^^^^^^^^^^^^^^^^^^^^
168
+
169
+ Searches for the node specified by full dot separated path. **The requested node must reside in the application client was connected to. Root node is not considered part of the path.**
170
+
171
+ - Arguments
172
+
173
+ path - Dot separated string to target node
174
+
175
+ - Returns
176
+
177
+ Promise containing requested Node object when fulfilled. Otherwise NotFoundError when rejected.
178
+
179
+ - Usage
180
+
181
+ .. code:: python
182
+
183
+ client.find_node('AppName.ComponentName.SignalName').then(on_success).catch(on_error)
184
+
185
+ client.run_event_loop()
186
+ ^^^^^^^^^^^^^^^^^^^^^^^
187
+
188
+ Runs the event loop that serves network communication layer for incoming/outgoing data. **This is a blocking call that must be run for any communication to happen.** The method can be cancelled by calling disconnect.
189
+
190
+ client.disconnect()
191
+ ^^^^^^^^^^^^^^^^^^^
192
+
193
+ Stops the event loop and closes the connection to connected application. This method also releases the blocking run_event_loop call.
194
+
195
+ Instance Methods / Node
196
+ ~~~~~~~~~~~~~~~~~~~~~~~
197
+
198
+ node.name()
199
+ ^^^^^^^^^^^
200
+
201
+ - Returns
202
+
203
+ The name of the Node object. Names in a parent node are all unique.
204
+
205
+ node.path()
206
+ ^^^^^^^^^^^
207
+
208
+ - Returns
209
+
210
+ A dot separated path of the Node object starting with application name.
211
+
212
+ node.parent()
213
+ ^^^^^^^^^^^^^
214
+
215
+ - Returns
216
+
217
+ The parent Node object.
218
+
219
+ node.type()
220
+ ^^^^^^^^^^^
221
+
222
+ - Returns
223
+
224
+ The type of the Node object returned as one of the cdp.NodeType values.
225
+
226
+ node.class_name()
227
+ ^^^^^^^^^^^^^^^^^
228
+
229
+ - Returns
230
+
231
+ CDP class name as a string.
232
+
233
+ node.last_value()
234
+ ^^^^^^^^^^^^^^^^^
235
+
236
+ - Returns
237
+
238
+ The last known value received by the Node object.
239
+
240
+ node.set_value(value, timestamp)
241
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
242
+
243
+ Sets a new value for the Node object. Timestamp will be ignored in current implementation.
244
+
245
+ - Arguments
246
+
247
+ value - New value
248
+
249
+ timestamp - UTC time in nanoseconds since Epoch
250
+
251
+ node.is_read_only()
252
+ ^^^^^^^^^^^^^^^^^^^
253
+
254
+ - Returns
255
+
256
+ False if nodes value cannot be set, otherwise True.
257
+
258
+ node.is_leaf()
259
+ ^^^^^^^^^^^^^^
260
+
261
+ - Returns
262
+
263
+ True if node doesn't have any children, otherwise False.
264
+
265
+ node.child(name)
266
+ ^^^^^^^^^^^^^^^^
267
+
268
+ - Arguments
269
+
270
+ name - Child nodes name to search for
271
+
272
+ - Returns
273
+
274
+ Promise containing requested Node object when fulfilled.
275
+
276
+ - Usage
277
+
278
+ .. code:: python
279
+
280
+ node.child('NodeName').then(on_success).catch(on_error)
281
+
282
+ node.children()
283
+ ^^^^^^^^^^^^^^^
284
+
285
+ - Returns
286
+
287
+ Promise containing all children of this Node object when fulfilled.
288
+
289
+ - Usage
290
+
291
+ .. code:: python
292
+
293
+ node.children().then(on_success).catch(on_error)
294
+
295
+ node.for_each_child(callback)
296
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
297
+
298
+ Loops through all children and calls callback function for each of them
299
+
300
+ - Arguments
301
+
302
+ callback - Function(node)
303
+
304
+ - Returns
305
+
306
+ Promise containing all children of this Node object when fulfilled.
307
+
308
+ - Usage
309
+
310
+ .. code:: python
311
+
312
+ def on_callback(child):
313
+ do something
314
+
315
+ node.for_each_child(on_callback)
316
+
317
+ node.subscribe_to_structure_changes(callback)
318
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
319
+
320
+ Starts listening structure changes and passes the changes to provided callback funtion
321
+
322
+ - Arguments
323
+
324
+ callback - Function(added_nodes, removed_nodes) where added_nodes and removed_nodes is a list
325
+
326
+ - Usage
327
+
328
+ .. code:: python
329
+
330
+ def on_change(added_nodes, removed_nodes):
331
+ do something
332
+
333
+ node.subscribe_to_structure_changes(on_change)
334
+
335
+ node.subscribe_to_value_changes(callback, fs=5, sample_rate=0)
336
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
337
+
338
+ Starts listening value changes and passes the changes to provided callback function
339
+
340
+ - Arguments
341
+
342
+ callback - Function(value, timestamp)
343
+
344
+ fs - Maximum frequency that value updates are expected (controls how many changes are sent in a single packet). Defaults to 5 hz.
345
+
346
+ sample_rate - Maximum amount of value updates sent per second (controls the amount of data transferred). Zero means all samples must be provided. Defaults to 0.
347
+
348
+ - Usage
349
+
350
+ .. code:: python
351
+
352
+ def on_change(value, timestamp):
353
+ do something
354
+
355
+ node.subscribe_to_value_changes(on_change)
356
+
357
+
358
+ node.unsubscribe_from_structure_changes(callback)
359
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
360
+
361
+ Stops listening previously subscribed structure changes
362
+
363
+ - Arguments
364
+
365
+ callback - Function(added_nodes, removed_nodes) where added_nodes and removed_nodes is a list
366
+
367
+ - Usage
368
+
369
+ .. code:: python
370
+
371
+ def on_change(added_nodes, removed_nodes):
372
+ do something
373
+
374
+ node.unsubscribe_from_structure_changes(on_change)
375
+
376
+ node.unsubscribe_from_value_changes(callback)
377
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
378
+
379
+ Stops listening previously subscribed value changes
380
+
381
+ - Arguments
382
+
383
+ callback - Function(value, timestamp)
384
+
385
+ - Usage
386
+
387
+ .. code:: python
388
+
389
+ def on_change(value, timestamp):
390
+ do something
391
+
392
+ node.unsubscribe_from_value_changes(on_change)
393
+
394
+ Notification Listener
395
+ ~~~~~~~~~~~~~~~~~~~~~
396
+
397
+ To handle different connection events (like prompt user to accept a system use notification message or request user to enter credentials for authentication or idle lockout re-authentication) a notification_listener parameter must be provided to the Client.
398
+ The notification_listener parameter must be a object of type class cdp.NotificationListener.
399
+
400
+ class NotificationListener
401
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
402
+
403
+ .. code:: python
404
+
405
+ class NotificationListener:
406
+ def application_acceptance_requested(self, request=AuthRequest()):
407
+ request.accept()
408
+
409
+ def credentials_requested(self, request=AuthRequest()):
410
+ raise NotImplementedError("NotificationListener credentials_requested() not implemented!")
411
+
412
+ NotificationListener.application_acceptance_requested(self, request=AuthRequest())
413
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
414
+
415
+ Called by Client when new application TLS or plain TCP connection is established.
416
+ Can be used to prompt the user a System Use Notification (a message that can be configured in CDP Studio Security settings).
417
+
418
+ - Arguments
419
+
420
+ request - a object that has method accept() that should be called to accept the connection and a reject() to reject the connection.
421
+
422
+ - Usage
423
+
424
+ .. code:: python
425
+
426
+ class MyListener(cdp.NotificationListener):
427
+ def application_acceptance_requested(self, request):
428
+ if request.system_use_notification():
429
+ # Pop up a System Use Notification message and ask for confirmation to continue,
430
+ # then based on the user answer call either request.accept() or request.reject()
431
+ else:
432
+ request.accept()
433
+
434
+ client = cdp.Client(host='127.0.0.1', port=7689, notification_listener=MyListener())
435
+
436
+ NotificationListener.credentials_requested(self, request=AuthRequest())
437
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
438
+ Called by Client when server is requesting credentials (authentication or idle lockout re-authentication).
439
+
440
+ - Arguments
441
+
442
+ request - a object that has method accept(data=dict()) that should be called (with credentials) for authentication try, and also a method reject() to reject the connection.
443
+
444
+ - Usage
445
+
446
+ .. code:: python
447
+
448
+ class MyListener(cdp.NotificationListener):
449
+ def credentials_requested(self, request):
450
+ if request.user_auth_result().code() == cdp.AuthResultCode.CREDENTIALS_REQUIRED:
451
+ # Do something to gather username and password variables (either sync or async way) and then call:
452
+ request.accept({'Username': 'test', 'Password': '12345678'});
453
+ if request.user_auth_result().code() == cdp.AuthResultCode.REAUTHENTICATION_REQUIRED:
454
+ # Pop user a message that idle lockout was happened and server requires new authentication to continue:
455
+ request.accept({'Username': 'test', 'Password': '12345678'});
456
+
457
+ client = cdp.Client(host='127.0.0.1', port=7689, notification_listener=MyListener())
458
+
459
+ Tests
460
+ -----
461
+
462
+ To run the test suite execute the following command in package root folder:
463
+
464
+ .. code:: sh
465
+
466
+ $ python setup.py test
467
+
468
+ License
469
+ -------
470
+
471
+ `MIT
472
+ License <https://github.com/CDPTechnologies/PythonCDPClient/blob/master/LICENSE.txt>`__
@@ -372,25 +372,25 @@ class Node:
372
372
  if type == proto.eDOUBLE:
373
373
  variant.d_value = value
374
374
  elif type == proto.eUINT64:
375
- variant.f_value = value
375
+ variant.f_value = int(value)
376
376
  elif type == proto.eINT64:
377
- variant.ui64_value = value
377
+ variant.ui64_value = int(value)
378
378
  elif type == proto.eFLOAT:
379
379
  variant.i64_value = value
380
380
  elif type == proto.eUINT:
381
- variant.ui_value = value
381
+ variant.ui_value = int(value)
382
382
  elif type == proto.eINT:
383
- variant.i_value = value
383
+ variant.i_value = int(value)
384
384
  elif type == proto.eUSHORT:
385
- variant.us_value = value
385
+ variant.us_value = int(value)
386
386
  elif type == proto.eSHORT:
387
- variant.s_value = value
387
+ variant.s_value = int(value)
388
388
  elif type == proto.eUCHAR:
389
- variant.uc_value = value
389
+ variant.uc_value = int(value)
390
390
  elif type == proto.eCHAR:
391
- variant.c_value = value
391
+ variant.c_value = int(value)
392
392
  elif type == proto.eBOOL:
393
- variant.b_value = value
393
+ variant.b_value = bool(value)
394
394
  elif type == proto.eSTRING:
395
395
  variant.str_value = str(value)
396
396
  return variant
@@ -701,7 +701,7 @@ class Connection:
701
701
  value = proto.ValueRequest()
702
702
  value.node_id = node_id
703
703
  value.fs = fs
704
- if sample_rate is not 0:
704
+ if sample_rate != 0:
705
705
  value.sample_rate = sample_rate
706
706
  if stop:
707
707
  value.stop = stop
@@ -118,7 +118,6 @@ def create_value_unrequest(node_id):
118
118
  value = proto.ValueRequest()
119
119
  value.node_id = node_id
120
120
  value.fs = 1
121
- value.sample_rate = 0
122
121
  value.stop = True
123
122
  request.getter_request.extend([value])
124
123
  return request
@@ -23,7 +23,7 @@ class ClientTester(unittest.TestCase):
23
23
  mock_root_node.return_value = Promise(lambda resolve, reject: resolve(cdp.Node(None, self._client._connection, fake_data.system_node)))
24
24
  self._client.root_node().then(lambda node: nodes.append(node))
25
25
  mock_root_node.assert_called_once_with()
26
- self.assertEquals(nodes[0]._id(), fake_data.system_node.info.node_id)
26
+ self.assertEqual(nodes[0]._id(), fake_data.system_node.info.node_id)
27
27
 
28
28
  @mock.patch.object(cdp.NodeTree, 'root_node')
29
29
  @mock.patch.object(cdp.Node, 'child')
@@ -38,7 +38,7 @@ class ClientTester(unittest.TestCase):
38
38
  Promise(lambda resolve, reject: resolve(cdp.Node(None, self._client._connection, fake_data.value1_node)))]
39
39
  path = '.'.join([app_node.info.name, comp_node.info.name, fake_data.value1_node.info.name])
40
40
  self._client.find_node(path).then(lambda node: nodes.append(node))
41
- self.assertEquals(nodes[0]._id(), fake_data.value1_node.info.node_id)
41
+ self.assertEqual(nodes[0]._id(), fake_data.value1_node.info.node_id)
42
42
 
43
43
  @mock.patch.object(cdp.Connection, 'run_event_loop')
44
44
  def test_run_event_loop(self, mock_run_event_loop):
@@ -35,7 +35,7 @@ class NodeTester(unittest.TestCase):
35
35
  def test_value(self):
36
36
  node = cdp.Node(None, self._connection, data.value1_node)
37
37
  node._update_value(data.value1)
38
- self.assertEquals(node.last_value(), data.value1.d_value)
38
+ self.assertEqual(node.last_value(), data.value1.d_value)
39
39
 
40
40
  @mock.patch.object(cdp.Connection, 'send_value')
41
41
  def test_value_setter(self, mock_send_value):
@@ -79,7 +79,7 @@ class NodeTester(unittest.TestCase):
79
79
  mock_send_structure_request.return_value = Promise(lambda resolve, reject: resolve(data.app2_node))
80
80
  node.children().then(lambda n: children.extend(n))
81
81
  mock_send_structure_request.assert_called_once_with(data.app2_node.info.node_id, node.path() + '.' + data.app2_node.info.name)
82
- self.assertEquals(len(children), len(self._root_node.node))
82
+ self.assertEqual(len(children), len(self._root_node.node))
83
83
 
84
84
  @mock.patch.object(cdp.Connection, 'send_structure_request')
85
85
  def test_children_iterator(self, mock_send_structure_request):
@@ -88,7 +88,7 @@ class NodeTester(unittest.TestCase):
88
88
  mock_send_structure_request.return_value = Promise(lambda resolve, reject: resolve(data.app2_node))
89
89
  node.for_each_child(lambda n: children.append(n))
90
90
  mock_send_structure_request.assert_called_once_with(data.app2_node.info.node_id, node.path() + '.' + data.app2_node.info.name)
91
- self.assertEquals(len(children), len(self._root_node.node))
91
+ self.assertEqual(len(children), len(self._root_node.node))
92
92
 
93
93
  @mock.patch.object(cdp.Connection, 'send_structure_request')
94
94
  def test_structure_subscription(self, mock_send_structure_request):
@@ -105,7 +105,7 @@ class NodeTester(unittest.TestCase):
105
105
  mock_send_structure_request.return_value = Promise(lambda resolve, reject: resolve(data.app2_node))
106
106
  node.children().then(lambda n: old_children.extend(n))
107
107
 
108
- #change the structure - remove and add a node
108
+ # change the structure - remove and add a node
109
109
  node_to_remove = self._root_node.node[0]
110
110
  node_to_add = data.app3_node
111
111
  self._root_node.node.remove(node_to_remove)
@@ -113,14 +113,14 @@ class NodeTester(unittest.TestCase):
113
113
  mock_send_structure_request.return_value = Promise(lambda resolve, reject: resolve(self._root_node))
114
114
  node._update()
115
115
 
116
- #verify
116
+ # verify
117
117
  mock_send_structure_request.return_value = Promise(lambda resolve, reject: resolve(node_to_add))
118
118
  node.children().then(lambda n: new_children.extend(n))
119
- self.assertEquals(len(old_children), len(new_children))
119
+ self.assertEqual(len(old_children), len(new_children))
120
120
  found = False
121
121
  for child in new_children:
122
- self.assertFalse(child.name() == nodes_removed[0])
123
- if child.name() == nodes_added[0]:
122
+ self.assertFalse(child.name() == nodes_removed[0].name())
123
+ if child.name() == nodes_added[0].name():
124
124
  found = True
125
125
  self.assertTrue(found)
126
126
 
@@ -141,8 +141,8 @@ class NodeTester(unittest.TestCase):
141
141
  node._update_structure(self._root_node)
142
142
 
143
143
  # verify
144
- self.assertEquals(nodes_added, [])
145
- self.assertEquals(nodes_removed, [])
144
+ self.assertEqual(nodes_added, [])
145
+ self.assertEqual(nodes_removed, [])
146
146
 
147
147
  @mock.patch.object(cdp.Connection, 'send_value_request')
148
148
  def test_value_subscription(self, mock_send_value_request):
@@ -159,11 +159,11 @@ class NodeTester(unittest.TestCase):
159
159
  for value in expected_values:
160
160
  node._update_value(value)
161
161
 
162
- self.assertEquals(len(actual_values), len(expected_values))
163
- self.assertEquals(len(timestamps), len(expected_values))
162
+ self.assertEqual(len(actual_values), len(expected_values))
163
+ self.assertEqual(len(timestamps), len(expected_values))
164
164
  for index, value in enumerate(expected_values):
165
- self.assertEquals(actual_values[index], value.d_value)
166
- self.assertEquals(timestamps[index], value.timestamp)
165
+ self.assertEqual(actual_values[index], value.d_value)
166
+ self.assertEqual(timestamps[index], value.timestamp)
167
167
 
168
168
  @mock.patch.object(cdp.Connection, 'send_value_request')
169
169
  def test_value_subscription_max_fs(self, mock_send_value_request):
@@ -214,7 +214,7 @@ class NodeTester(unittest.TestCase):
214
214
  node.unsubscribe_from_value_changes(on_change)
215
215
  mock_send_value_unrequest.assert_called_once_with(node._id())
216
216
  node._update_value(data.value1)
217
- self.assertEquals(len(values), 0)
217
+ self.assertEqual(len(values), 0)
218
218
 
219
219
  @mock.patch.object(cdp.Connection, 'send_value_request')
220
220
  def test_value_unsubscription_max_fs(self, mock_send_value_request):
@@ -27,8 +27,8 @@ class NodeTreeTester(unittest.TestCase):
27
27
  mock_send_structure_request.side_effect = [Promise(lambda resolve, reject: resolve(system_node)),
28
28
  Promise(lambda resolve, reject: resolve(app_node))]
29
29
  self._node_tree.root_node().then(lambda n: nodes.append(n))
30
- self.assertEquals(len(nodes), 1)
31
- self.assertEquals(nodes[0]._id(), app_node.info.node_id)
30
+ self.assertEqual(len(nodes), 1)
31
+ self.assertEqual(nodes[0]._id(), app_node.info.node_id)
32
32
 
33
33
  @mock.patch.object(cdp.Connection, 'send_structure_request')
34
34
  def test_fetching_root_node_when_root_node_existing(self, mock_send_structure_request):
@@ -37,8 +37,8 @@ class NodeTreeTester(unittest.TestCase):
37
37
  self._node_tree._root_node = root_node
38
38
  self._node_tree.root_node().then(lambda n: nodes.append(n))
39
39
  mock_send_structure_request.assert_not_called()
40
- self.assertEquals(len(nodes), 1)
41
- self.assertEquals(nodes[0]._id(), root_node._id())
40
+ self.assertEqual(len(nodes), 1)
41
+ self.assertEqual(nodes[0]._id(), root_node._id())
42
42
 
43
43
  def test_find_node_by_id(self):
44
44
  system_node = copy(fake_data.system_node)
@@ -48,7 +48,7 @@ class NodeTreeTester(unittest.TestCase):
48
48
  root_node = cdp.Node(None, self._node_tree._connection, system_node)
49
49
  self._node_tree._root_node = root_node
50
50
  node = self._node_tree.find_by_id(fake_data.value1_node.info.node_id)
51
- self.assertEquals(node._id(), fake_data.value1_node.info.node_id)
51
+ self.assertEqual(node._id(), fake_data.value1_node.info.node_id)
52
52
 
53
53
  def test_find_node_by_path(self):
54
54
  system_node = copy(fake_data.system_node)
@@ -59,4 +59,4 @@ class NodeTreeTester(unittest.TestCase):
59
59
  self._node_tree._root_node = root_node
60
60
  path = '.'.join([system_node.info.name, app_node.info.name, fake_data.value1_node.info.name])
61
61
  node = self._node_tree.find_by_path(path)
62
- self.assertEquals(node._id(), fake_data.value1_node.info.node_id)
62
+ self.assertEqual(node._id(), fake_data.value1_node.info.node_id)