diff options
author | Michael Abel <75477722+abelikt@users.noreply.github.com> | 2022-03-04 12:16:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-04 12:16:52 +0100 |
commit | 43143cee9a79dec58326bda8f64b2c2578efbfcc (patch) | |
tree | 01c92f992c44b69410fe40e47f2f0c4086624792 /tests | |
parent | 40c7602e7ebb4831c975f4be419094fec42cf644 (diff) | |
parent | 501eb9d5b79192ee472e1fb4c88af1f4c277380b (diff) |
Merge pull request #970 from abelikt/bugs/fix_test_tedge_software_update
Bugs/fix test tedge software update
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PySys/tedge/tedge_software_update/run.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/PySys/tedge/tedge_software_update/run.py b/tests/PySys/tedge/tedge_software_update/run.py index 583d23d0..12864253 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 """ Test if alternate download path setting works @@ -12,7 +13,7 @@ Then we find the string of the new location in the output of tedge config 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): @@ -59,13 +60,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 @@ -81,7 +84,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", ) @@ -89,9 +92,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): + with open(os.path.join(self.output, "tedge_config_get_original.out"), "r") as handle: original_value = handle.read().strip() # reverting to original value @@ -106,7 +108,7 @@ 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() |