Skip to content

Commit

Permalink
Fix another test
Browse files Browse the repository at this point in the history
  • Loading branch information
BoPeng committed Feb 16, 2024
1 parent 5785258 commit 3d525e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
10 changes: 5 additions & 5 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 2 additions & 20 deletions test/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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):
Expand Down

0 comments on commit 3d525e0

Please sign in to comment.