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

added fail and success test for the submit_job_to_ecserver function

parent 2ad8ea53
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ import pytest ...@@ -9,7 +9,7 @@ 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) get_cmdline_arguments, submit_job_to_ecserver)
class TestTools(): class TestTools():
...@@ -76,7 +76,7 @@ class TestTools(): ...@@ -76,7 +76,7 @@ class TestTools():
for par in pars: for par in pars:
assert par in [130, 134, 142, 146] assert par in [130, 134, 142, 146]
def test_error_notifcation(self): def test_my_error(self):
''' '''
''' '''
with pytest.raises(SystemExit) as pytest_wrapped_e: with pytest.raises(SystemExit) as pytest_wrapped_e:
...@@ -108,7 +108,6 @@ class TestTools(): ...@@ -108,7 +108,6 @@ class TestTools():
def test_silent_remove(self): def test_silent_remove(self):
assert True assert True
def test_get_list_as_string(self): def test_get_list_as_string(self):
assert True assert True
...@@ -117,9 +116,21 @@ class TestTools(): ...@@ -117,9 +116,21 @@ class TestTools():
def test_put_file_to_ecserver(self): def test_put_file_to_ecserver(self):
assert True assert True
#assert subprocess.call(['ssh', host, 'test -e ' + pipes.quote(path)]) == 0
def test_fail_submit_job_to_ecserver(self):
with pytest.raises(SystemExit) as pytest_wrapped_e:
submit_job_to_ecserver('${HOME}', 'ecgate', 'job.ksh')
assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == '... ECACCESS-JOB-SUBMIT FAILED!'
def test_success_submit_job_to_ecserver(self):
result = submit_job_to_ecserver('TestData/testfile.txt',
'ecgate', 'TestData/testfile.txt')
assert result == 0
def submit_job_to_ecserver(self):
assert True
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
...@@ -499,15 +499,16 @@ def submit_job_to_ecserver(ecd, target, jobname): ...@@ -499,15 +499,16 @@ def submit_job_to_ecserver(ecd, target, jobname):
The name of the jobfile to be submitted to the ECMWF server. The name of the jobfile to be submitted to the ECMWF server.
@Return: @Return:
<nothing> rcode: integer
Resulting code of subprocess.check_call.
''' '''
try: try:
subprocess.check_call(['ecaccess-job-submit', rcode = subprocess.check_call(['ecaccess-job-submit',
'-queueName', target, '-queueName', target,
jobname]) jobname])
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print '... ERROR CODE: ', e.returncode print '... ERROR CODE: ', e.returncode
sys.exit('... ECACCESS-JOB-SUBMIT FAILED!') sys.exit('... ECACCESS-JOB-SUBMIT FAILED!')
return return rcode
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment