From 3d525e02cae9d86a33489568d1316650a87b6182 Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Fri, 16 Feb 2024 01:10:46 -0600 Subject: [PATCH] Fix another test --- test/conftest.py | 10 +++++----- test/test_remote.py | 22 ++-------------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index 7128eb66d..4868c8d4f 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -35,15 +35,15 @@ def get_config(text_or_dict): @pytest.fixture def script_factory(): - filename = tempfile.NamedTemporaryFile(suffix='.sos', delete=False).name + default_filename = tempfile.NamedTemporaryFile(suffix='.sos', delete=False).name - def get_script(text): - with open(filename, 'w') as conf: + def get_script(text, filename=None): + with open(filename or default_filename, 'w') as conf: conf.write(textwrap.dedent(text)) - return filename + return filename or default_filename yield get_script - os.remove(filename) + os.remove(default_filename) @pytest.fixture diff --git a/test/test_remote.py b/test/test_remote.py index f0b8ef79c..b5adc33ec 100644 --- a/test/test_remote.py +++ b/test/test_remote.py @@ -62,7 +62,7 @@ def test_worker_procs_with_task(): @pytest.mark.skipif(not has_docker, reason="Docker container not usable") def test_remote_execute(clear_now_and_after, script_factory): - clear_now_and_after("result_remote.txt", "result_remote1.txt", "local.txt") + clear_now_and_after("result_remote.txt", "result_remote1.txt", "local.txt", "remote_exec.sos") test_remote_sos = script_factory(""" [10] @@ -73,40 +73,22 @@ def test_remote_execute(clear_now_and_after, script_factory): run: cp local.txt result_remote.txt echo 'adf' >> 'result_remote.txt' - """) + """, filename='remote_exec.sos') with open("local.txt", "w") as w: w.write("something") - assert 0 == subprocess.call("sos remote push docker --files local.txt -c ~/docker.yml", shell=True) - assert 0 == subprocess.call( f"sos run {test_remote_sos} -c ~/docker.yml -r docker -s force", shell=True, ) - assert not file_target("result_remote.txt").target_exists() - - # self.assertEqual(subprocess.call('sos preview result_remote.txt -c ~/docker.yml -r docker', shell=True), 0) - # self.assertNotEqual(subprocess.call('sos preview result_remote.txt', shell=True), 0) - assert 0 == subprocess.call("sos remote pull docker --files result_remote.txt -c ~/docker.yml", shell=True) - assert file_target("result_remote.txt").target_exists() - # self.assertEqual(subprocess.call('sos preview result_remote.txt', shell=True), 0) with open("result_remote.txt") as w: content = w.read() assert "something" in content assert "adf" in content - # test sos remote run - assert 0 == subprocess.call( - "sos remote run docker -c ~/docker.yml --cmd cp result_remote.txt result_remote1.txt ", - shell=True, - ) - assert 0 == subprocess.call("sos remote pull docker --files result_remote1.txt -c ~/docker.yml", shell=True) - - assert file_target("result_remote1.txt").target_exists() - @pytest.mark.skipif(not has_docker, reason="Docker container not usable") def test_remote_workflow_remote_queue(script_factory):