From 7d048f1a5bb1af6aa8f05ad4a40e84b4da647731 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 13 Dec 2019 10:02:27 +0100 Subject: [PATCH] clients/tests: support replacing UUIDs in command text We want to issue a nmcli command with the connection's UUID in the command line. As the command line is stored to disk and compared, we cannot use UUIDs that are randomly generated. Instead, we need to support replacing the text in the command line. --- clients/tests/test-client.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/clients/tests/test-client.py b/clients/tests/test-client.py index 37c3e74908..03415cd031 100755 --- a/clients/tests/test-client.py +++ b/clients/tests/test-client.py @@ -594,6 +594,7 @@ class TestNmcli(NmTestBase): expected_stderr = _DEFAULT_ARG, replace_stdout = None, replace_stderr = None, + replace_cmd = None, sort_lines_stdout = False, extra_env = None, sync_barrier = False): @@ -608,6 +609,7 @@ class TestNmcli(NmTestBase): expected_stderr, replace_stdout, replace_stderr, + replace_cmd, sort_lines_stdout, extra_env, sync_barrier, @@ -625,6 +627,7 @@ class TestNmcli(NmTestBase): expected_stderr = _DEFAULT_ARG, replace_stdout = None, replace_stderr = None, + replace_cmd = None, sort_lines_stdout = False, extra_env = None, sync_barrier = None): @@ -651,6 +654,7 @@ class TestNmcli(NmTestBase): expected_stderr, replace_stdout, replace_stderr, + replace_cmd, sort_lines_stdout, extra_env, sync_barrier, @@ -666,6 +670,7 @@ class TestNmcli(NmTestBase): expected_stderr, replace_stdout, replace_stderr, + replace_cmd, sort_lines_stdout, extra_env, sync_barrier, @@ -728,6 +733,8 @@ class TestNmcli(NmTestBase): replace_stdout = list(replace_stdout) if replace_stderr is not None: replace_stderr = list(replace_stderr) + if replace_cmd is not None: + replace_cmd = list(replace_cmd) if check_on_disk is _DEFAULT_ARG: check_on_disk = ( expected_returncode is _DEFAULT_ARG @@ -788,6 +795,7 @@ class TestNmcli(NmTestBase): if check_on_disk: cmd = '$NMCLI %s' % (' '.join([Util.quote(a) for a in args[1:]])) + cmd = Util.replace_text(cmd, replace_cmd) content = ('location: %s\n' % (calling_location)).encode('utf8') + \ ('cmd: %s\n' % (cmd)).encode('utf8') + \