Skip to content
Snippets Groups Projects
Commit 70a0becc authored by Anne Philipp's avatar Anne Philipp
Browse files

added test for put_file_to_ecserver and corrected a potential bug; test is not...

added test for put_file_to_ecserver and corrected a potential bug; test is not perfect since it needs user password. TODO: CHANGE
parent b1d07c92
Branches
Tags
No related merge requests found
...@@ -4,12 +4,15 @@ ...@@ -4,12 +4,15 @@
import os import os
import sys import sys
#import unittest #import unittest
import subprocess
import pipes
import pytest import pytest
sys.path.append('../') sys.path.append('../')
import _config import _config
from tools import (init128, to_param_id, my_error, read_ecenv, from tools import (init128, to_param_id, my_error, read_ecenv,
get_cmdline_arguments, submit_job_to_ecserver) get_cmdline_arguments, submit_job_to_ecserver,
put_file_to_ecserver)
class TestTools(): class TestTools():
...@@ -114,9 +117,13 @@ class TestTools(): ...@@ -114,9 +117,13 @@ class TestTools():
def test_make_dir(self): def test_make_dir(self):
assert True assert True
def test_put_file_to_ecserver(self): def test_success_put_file_to_ecserver(self):
assert True ecuid=os.environ['ECUID']#'km4a'
#assert subprocess.call(['ssh', host, 'test -e ' + pipes.quote(path)]) == 0 ecgid=os.environ['ECGID']#'at'
put_file_to_ecserver('TestData/', 'testfile.txt', 'ecgate', ecuid, ecgid)
assert subprocess.call(['ssh', 'km4a@ecaccess.ecmwf.int' ,
'test -e ' +
pipes.quote('/home/ms/'+ecgid+'/'+ecuid)]) == 0
def test_fail_submit_job_to_ecserver(self): def test_fail_submit_job_to_ecserver(self):
with pytest.raises(SystemExit) as pytest_wrapped_e: with pytest.raises(SystemExit) as pytest_wrapped_e:
...@@ -125,7 +132,6 @@ class TestTools(): ...@@ -125,7 +132,6 @@ class TestTools():
assert pytest_wrapped_e.value.code == '... ECACCESS-JOB-SUBMIT FAILED!' assert pytest_wrapped_e.value.code == '... ECACCESS-JOB-SUBMIT FAILED!'
def test_success_submit_job_to_ecserver(self): def test_success_submit_job_to_ecserver(self):
result = submit_job_to_ecserver('ecgate', 'TestData/testfile.txt') result = submit_job_to_ecserver('ecgate', 'TestData/testfile.txt')
assert result == 0 assert result == 0
......
...@@ -470,7 +470,7 @@ def put_file_to_ecserver(ecd, filename, target, ecuid, ecgid): ...@@ -470,7 +470,7 @@ def put_file_to_ecserver(ecd, filename, target, ecuid, ecgid):
try: try:
subprocess.check_call(['ecaccess-file-put', subprocess.check_call(['ecaccess-file-put',
ecd + '../' + filename, ecd + '/' + filename,
target + ':/home/ms/' + target + ':/home/ms/' +
ecgid + '/' + ecuid + ecgid + '/' + ecuid +
'/' + filename]) '/' + filename])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment