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
No related branches found
No related tags found
No related merge requests found
......@@ -4,12 +4,15 @@
import os
import sys
#import unittest
import subprocess
import pipes
import pytest
sys.path.append('../')
import _config
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():
......@@ -114,9 +117,13 @@ class TestTools():
def test_make_dir(self):
assert True
def test_put_file_to_ecserver(self):
assert True
#assert subprocess.call(['ssh', host, 'test -e ' + pipes.quote(path)]) == 0
def test_success_put_file_to_ecserver(self):
ecuid=os.environ['ECUID']#'km4a'
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):
with pytest.raises(SystemExit) as pytest_wrapped_e:
......@@ -125,7 +132,6 @@ class TestTools():
assert pytest_wrapped_e.value.code == '... ECACCESS-JOB-SUBMIT FAILED!'
def test_success_submit_job_to_ecserver(self):
result = submit_job_to_ecserver('ecgate', 'TestData/testfile.txt')
assert result == 0
......
......@@ -470,7 +470,7 @@ def put_file_to_ecserver(ecd, filename, target, ecuid, ecgid):
try:
subprocess.check_call(['ecaccess-file-put',
ecd + '../' + filename,
ecd + '/' + filename,
target + ':/home/ms/' +
ecgid + '/' + ecuid +
'/' + filename])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment