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
2f4cc733
Commit
2f4cc733
authored
6 years ago
by
Anne Philipp
Browse files
Options
Downloads
Patches
Plain Diff
changed testing from unittest to pytest and adapted existing testcases
parent
dda0e9de
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/pythontest/TestTools.py
+43
-13
43 additions, 13 deletions
python/pythontest/TestTools.py
with
43 additions
and
13 deletions
python/pythontest/TestTools.py
+
43
−
13
View file @
2f4cc733
#!/usr/bin/env python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
unittest
import
sys
import
os
import
os
sys
.
path
.
append
(
'
../python
'
)
import
sys
#import unittest
import
pytest
sys
.
path
.
append
(
'
../
'
)
import
_config
from
tools
import
init128
,
to_param_id
,
my_error
,
read_ecenv
from
tools
import
init128
,
to_param_id
,
my_error
,
read_ecenv
class
TestTools
(
unittest
.
TestCase
):
class
TestTools
():
'''
'''
'''
'''
def
setUp
(
self
):
def
setUp
(
self
):
pass
pass
def
test_get_cmdline_arguments
(
self
):
assert
True
def
test_init128
(
self
):
def
test_init128
(
self
):
'''
'''
'''
'''
table128
=
init128
(
'
../grib_templates/ecmwf_grib1_table_128
'
)
table128
=
init128
(
_config
.
PATH_GRIBTABLE
)
expected
=
{
'
078
'
:
'
TCLW
'
,
'
130
'
:
'
T
'
,
'
034
'
:
'
SST
'
}
expected
=
{
'
078
'
:
'
TCLW
'
,
'
130
'
:
'
T
'
,
'
034
'
:
'
SST
'
}
# check a sample of parameters which must have been read in
# check a sample of parameters which must have been read in
result
=
all
((
k
in
table128
and
table128
[
k
]
==
v
)
for
k
,
v
in
expected
.
iteritems
())
result
=
all
((
k
in
table128
and
table128
[
k
]
==
v
)
for
k
,
v
in
expected
.
iteritems
())
self
.
assert
Equal
(
result
,
True
)
assert
result
==
True
def
test_to_param_id
(
self
):
def
test_to_param_id
(
self
):
'''
'''
'''
'''
table128
=
init128
(
'
../grib_templates/ecmwf_grib1_table_128
'
)
table128
=
init128
(
_config
.
PATH_GRIBTABLE
)
pars
=
to_param_id
(
"
T/SP/LSP/SSHF
"
,
table128
)
pars
=
to_param_id
(
"
T/SP/LSP/SSHF
"
,
table128
)
for
par
in
pars
:
for
par
in
pars
:
self
.
assert
In
(
par
,
[
130
,
134
,
142
,
146
]
)
assert
par
in
[
130
,
134
,
142
,
146
]
def
test_error_notifcation
(
self
):
def
test_error_notifcation
(
self
):
'''
'''
'''
'''
with
self
.
assertR
aises
(
SystemExit
)
as
r
e
:
with
pytest
.
r
aises
(
SystemExit
)
as
pytest_wrapped_
e
:
my_error
([
'
${USER}
'
,
'
anne.philipp@univie.ac.at
'
],
'
Failed!
'
)
my_error
([
'
${USER}
'
,
'
anne.philipp@univie.ac.at
'
],
'
Failed!
'
)
self
.
assertEqual
(
re
.
exception
.
code
,
1
)
assert
pytest_wrapped_e
.
type
==
SystemExit
assert
pytest_wrapped_e
.
value
.
code
==
1
def
test_read_ecenv
(
self
):
def
test_read_ecenv
(
self
):
'''
'''
envs_ref
=
{
'
ECUID
'
:
'
km4a
'
,
envs_ref
=
{
'
ECUID
'
:
'
km4a
'
,
'
ECGID
'
:
'
at
'
,
'
ECGID
'
:
'
at
'
,
'
GATEWAY
'
:
'
srvx8.img.univie.ac.at
'
,
'
GATEWAY
'
:
'
srvx8.img.univie.ac.at
'
,
...
@@ -49,11 +57,33 @@ class TestTools(unittest.TestCase):
...
@@ -49,11 +57,33 @@ class TestTools(unittest.TestCase):
}
}
envs
=
read_ecenv
(
os
.
getcwd
()
+
'
/TestData/ECMWF_ENV
'
)
envs
=
read_ecenv
(
os
.
getcwd
()
+
'
/TestData/ECMWF_ENV
'
)
self
.
assertDictEqual
(
envs_ref
,
envs
)
assert
envs_ref
==
envs
def
test_clean_up
(
self
):
assert
True
def
test_normal_exit
(
self
):
assert
True
def
test_product
(
self
):
assert
True
def
test_silent_remove
(
self
):
assert
True
def
test_get_list_as_string
(
self
):
assert
True
def
test_make_dir
(
self
):
assert
True
def
test_put_file_to_ecserver
(
self
):
assert
True
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.
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