From cd2b844a467db569bd02074bc3b6b2e450f31506 Mon Sep 17 00:00:00 2001 From: Michael Abel Date: Wed, 2 Mar 2022 16:07:39 +0100 Subject: Update import path --- tests/PySys/tedge/tedge_software_update/run.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/PySys/tedge/tedge_software_update/run.py b/tests/PySys/tedge/tedge_software_update/run.py index 5c6cd0a4..ff709bd2 100644 --- a/tests/PySys/tedge/tedge_software_update/run.py +++ b/tests/PySys/tedge/tedge_software_update/run.py @@ -1,4 +1,5 @@ -from environments.environment_c8y import EnvironmentC8y +import os +from environment_c8y import EnvironmentC8y """ Validate command line option help -- cgit v1.2.3 From 5a2ceb1b8b048d8d07d98182c280d226f04e3bb8 Mon Sep 17 00:00:00 2001 From: Michael Abel Date: Wed, 2 Mar 2022 16:08:27 +0100 Subject: Add stdouterr so that we see where the test fails --- tests/PySys/tedge/tedge_software_update/run.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/PySys/tedge/tedge_software_update/run.py b/tests/PySys/tedge/tedge_software_update/run.py index ff709bd2..5385cdd9 100644 --- a/tests/PySys/tedge/tedge_software_update/run.py +++ b/tests/PySys/tedge/tedge_software_update/run.py @@ -61,13 +61,15 @@ class PySysTest(EnvironmentC8y): # make a new directory `TEDGE_DOWNLOAD_DIR` _ = self.startProcess( command=self.sudo, - arguments=["mkdir", TEDGE_DOWNLOAD_DIR] + arguments=["mkdir", "-p", TEDGE_DOWNLOAD_DIR], + stdouterr="mkdir" ) # give full permission to `TEDGE_DOWNLOAD_DIR` _ = self.startProcess( command=self.sudo, - arguments=["chmod", "a+rwx", TEDGE_DOWNLOAD_DIR] + arguments=["chmod", "a+rwx", TEDGE_DOWNLOAD_DIR], + stdouterr="chmod" ) # 1. save the current/pre-change setting in /Output @@ -108,7 +110,8 @@ class PySysTest(EnvironmentC8y): # removing tedge dir _ = self.startProcess( command=self.sudo, - arguments=["rmdir", TEDGE_DOWNLOAD_DIR] + arguments=["rmdir", TEDGE_DOWNLOAD_DIR], + stdouterr="rmdir" ) return super().cleanup() -- cgit v1.2.3 From e2e13395d5e40d09b8fd2c4f04306c447089515c Mon Sep 17 00:00:00 2001 From: Michael Abel Date: Wed, 2 Mar 2022 16:11:52 +0100 Subject: Use conventional string formatting ... ... json will confuse format() a lot, that is the easy way --- tests/PySys/tedge/tedge_software_update/run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/PySys/tedge/tedge_software_update/run.py b/tests/PySys/tedge/tedge_software_update/run.py index 5385cdd9..94ef9828 100644 --- a/tests/PySys/tedge/tedge_software_update/run.py +++ b/tests/PySys/tedge/tedge_software_update/run.py @@ -14,7 +14,7 @@ Then we find the string SUBCOMMANDS: in the output TEDGE_DOWNLOAD_DIR = "/tedge_download_dir" TEDGE_DOWNLOAD_PATH = "tmp.path" TOPIC = 'tedge/commands/req/software/update' -PAYLOAD = '{"id":"1234","updateList":[{"type":"apt","modules":[{"name":"rolldice","version":"::apt","url":"{}/inventory/binaries/11643549","action":"install"}]}]}' +PAYLOAD = '{"id":"1234","updateList":[{"type":"apt","modules":[{"name":"rolldice","version":"::apt","url":"%s/inventory/binaries/11643549","action":"install"}]}]}' class PySysTest(EnvironmentC8y): @@ -85,7 +85,7 @@ class PySysTest(EnvironmentC8y): # 4. trigger rolldice download _ = self.startProcess( command=self.sudo, - arguments=[self.tedge, "mqtt", "pub", TOPIC, PAYLOAD.format(self.project.c8yurl)], + arguments=[self.tedge, "mqtt", "pub", TOPIC, PAYLOAD%self.project.c8yurl ], stdouterr="rolldice_download", expectedExitStatus="==0", ) -- cgit v1.2.3 From 17046143968d786ba0382b3c9610502d9871d342 Mon Sep 17 00:00:00 2001 From: Michael Abel Date: Wed, 2 Mar 2022 16:15:37 +0100 Subject: Don't override cleanup of the base class --- tests/PySys/tedge/tedge_software_update/run.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/PySys/tedge/tedge_software_update/run.py b/tests/PySys/tedge/tedge_software_update/run.py index 94ef9828..588ffd29 100644 --- a/tests/PySys/tedge/tedge_software_update/run.py +++ b/tests/PySys/tedge/tedge_software_update/run.py @@ -93,9 +93,8 @@ class PySysTest(EnvironmentC8y): def validate(self): self.assertGrep("tedge_config_get_new_value.out", f'{TEDGE_DOWNLOAD_DIR}', contains=True) - def cleanup(self): - with open("Output/linux/tedge_config_get_original.out", "r") as handle: + def mycleanup(self): original_value = handle.read().strip() # reverting to original value @@ -114,4 +113,3 @@ class PySysTest(EnvironmentC8y): stdouterr="rmdir" ) - return super().cleanup() -- cgit v1.2.3 From 501eb9d5b79192ee472e1fb4c88af1f4c277380b Mon Sep 17 00:00:00 2001 From: Michael Abel Date: Wed, 2 Mar 2022 16:16:07 +0100 Subject: Make path also work from other locations --- tests/PySys/tedge/tedge_software_update/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/PySys/tedge/tedge_software_update/run.py b/tests/PySys/tedge/tedge_software_update/run.py index 588ffd29..86637196 100644 --- a/tests/PySys/tedge/tedge_software_update/run.py +++ b/tests/PySys/tedge/tedge_software_update/run.py @@ -93,8 +93,8 @@ class PySysTest(EnvironmentC8y): def validate(self): self.assertGrep("tedge_config_get_new_value.out", f'{TEDGE_DOWNLOAD_DIR}', contains=True) - with open("Output/linux/tedge_config_get_original.out", "r") as handle: def mycleanup(self): + with open(os.path.join(self.output, "tedge_config_get_original.out"), "r") as handle: original_value = handle.read().strip() # reverting to original value -- cgit v1.2.3