Commit af20c1bb authored by Olivier R-D's avatar Olivier R-D

add subscirption delete, create test

parent 509f82cc
...@@ -180,7 +180,8 @@ class InternalSession(object): ...@@ -180,7 +180,8 @@ class InternalSession(object):
def delete_subscriptions(self, ids): def delete_subscriptions(self, ids):
for i in ids: for i in ids:
self.subscriptions.remove(i) if i in self.subscriptions:
self.subscriptions.remove(i)
return self.submgr.delete_subscriptions(ids) return self.submgr.delete_subscriptions(ids)
def delete_monitored_items(self, params): def delete_monitored_items(self, params):
......
...@@ -83,9 +83,12 @@ class SubscriptionManager(Thread): ...@@ -83,9 +83,12 @@ class SubscriptionManager(Thread):
with self._lock: with self._lock:
res = [] res = []
for i in ids: for i in ids:
sub = self.subscriptions.pop(i) if not i in self.subscriptions:
sub.stop() res.append(ua.StatusCode(ua.StatusCodes.BadSubscriptionsIdInvalid))
res.append(ua.StatusCode()) else:
sub = self.subscriptions.pop(i)
sub.stop()
res.append(ua.StatusCode())
return res return res
def publish(self, acks): def publish(self, acks):
......
...@@ -203,7 +203,7 @@ class CommonTests(object): ...@@ -203,7 +203,7 @@ class CommonTests(object):
self.assertEqual(ua.QualifiedName('Objects', 0), objects.get_name()) self.assertEqual(ua.QualifiedName('Objects', 0), objects.get_name())
nid = ua.NodeId(85, 0) nid = ua.NodeId(85, 0)
self.assertEqual(nid, objects.nodeid) self.assertEqual(nid, objects.nodeid)
'''
def test_create_delete_subscription(self): def test_create_delete_subscription(self):
o = self.opc.get_objects_node() o = self.opc.get_objects_node()
v = o.add_variable(3, 'SubscriptionVariable', [1, 2, 3]) v = o.add_variable(3, 'SubscriptionVariable', [1, 2, 3])
...@@ -212,7 +212,7 @@ class CommonTests(object): ...@@ -212,7 +212,7 @@ class CommonTests(object):
time.sleep(0.1) time.sleep(0.1)
sub.unsubscribe(handle) sub.unsubscribe(handle)
sub.delete() sub.delete()
'''
#def test_subscribe_events(self): #def test_subscribe_events(self):
#sub = self.opc.create_subscription(100, sclt) #sub = self.opc.create_subscription(100, sclt)
#handle = sub.subscribe_events() #handle = sub.subscribe_events()
...@@ -498,7 +498,7 @@ class TestServer(unittest.TestCase, CommonTests): ...@@ -498,7 +498,7 @@ class TestServer(unittest.TestCase, CommonTests):
if __name__ == '__main__': if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.WARN)
globalserver = ServerProcess() #server process will be started by client tests globalserver = ServerProcess() #server process will be started by client tests
try: try:
sclt = SubHandler() sclt = SubHandler()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment