From 1a20c9b2b5640408891da729203c4d9882aa0b70 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 13 Dec 2019 10:03:18 +0100 Subject: [PATCH] clients/tests: add NMStubServer.findConnections() helper function Will be used to get all connection from the test stub server. (cherry picked from commit 0d24ac4996738815b050214281470eecf2b991be) --- clients/tests/test-client.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/clients/tests/test-client.py b/clients/tests/test-client.py index 03415cd031..b1b912a273 100755 --- a/clients/tests/test-client.py +++ b/clients/tests/test-client.py @@ -441,11 +441,8 @@ class NMStubServer: if kwargs: # for convenience, we allow the caller to specify arguments # as kwargs. In this case, we construct a a{sv} array as last argument. - kwargs2 = {} args = list(args) - args.append(kwargs2) - for k in kwargs.keys(): - kwargs2[k] = kwargs[k] + args.append(kwargs) return method(*args) def __getattr__(self, member): @@ -456,9 +453,16 @@ class NMStubServer: def addConnection(self, connection, do_verify_strict = True): return self.op_AddConnection(connection, do_verify_strict) + def findConnections(self, **kwargs): + if kwargs: + lst = self.op_FindConnections(**kwargs) + else: + lst = self.op_FindConnections( { } ) + return list([ (str(elem[0]), str(elem[1]), str(elem[2])) for elem in lst ]) + def findConnectionUuid(self, con_id, required = True): try: - u = Util.iter_single(self.op_FindConnections(con_id = con_id))[1] + u = Util.iter_single(self.findConnections(con_id = con_id))[1] assert u, ("Invalid uuid %s" % (u)) except Exception as e: if not required: