Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flex Extract
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Flexpart
Flex Extract
Commits
451bb197
Commit
451bb197
authored
6 years ago
by
Anne Philipp
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/pythontest/TestTools.py
+16
-5
16 additions, 5 deletions
python/pythontest/TestTools.py
python/tools.py
+6
-5
6 additions, 5 deletions
python/tools.py
with
22 additions
and
10 deletions
python/pythontest/TestTools.py
+
16
−
5
View file @
451bb197
...
@@ -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
()
This diff is collapsed.
Click to expand it.
python/tools.py
+
6
−
5
View file @
451bb197
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment