FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ews-coordinator
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gilligan Lab for Epidemiology and Modelling
Wheat rusts
ews-coordinator
Commits
b9cb5f9f
Commit
b9cb5f9f
authored
2 years ago
by
L. Bower
Browse files
Options
Downloads
Patches
Plain Diff
adding asserts for the epi test
parent
9ebf6ff9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/integration/integration_test_utils.py
+25
-1
25 additions, 1 deletion
tests/integration/integration_test_utils.py
tests/integration/test_epi.py
+63
-16
63 additions, 16 deletions
tests/integration/test_epi.py
with
88 additions
and
17 deletions
tests/integration/integration_test_utils.py
+
25
−
1
View file @
b9cb5f9f
...
...
@@ -2,6 +2,7 @@ import glob
import
json
import
os
from
datetime
import
datetime
from
typing
import
List
from
zipfile
import
ZipFile
...
...
@@ -46,9 +47,32 @@ class IntegrationTestUtils:
@staticmethod
def
check_file_not_empty
(
file_path
:
str
):
def
check_file_not_empty
(
file_path
:
str
)
->
bool
:
return
os
.
stat
(
file_path
).
st_size
!=
0
@staticmethod
def
check_file_exists
(
file_path
:
str
)
->
bool
:
return
os
.
path
.
isfile
(
file_path
)
@staticmethod
def
check_wildcard_exists_and_not_empty
(
wildcard
:
str
)
->
bool
:
"""
requires at least one file matching the wildcard to exist and not be empty
"""
result
=
False
files
:
List
[
str
]
=
glob
.
glob
(
wildcard
)
for
file
in
files
:
result
=
IntegrationTestUtils
.
check_file_not_empty
(
file
)
if
result
is
False
:
break
return
result
@staticmethod
def
check_file_exists_and_not_empty
(
file_path
:
str
)
->
bool
:
file_exists
=
IntegrationTestUtils
.
check_file_exists
(
file_path
)
file_not_empty
=
IntegrationTestUtils
.
check_file_not_empty
(
file_path
)
return
file_exists
and
file_not_empty
@staticmethod
def
run_pipeline
(
component
:
str
,
...
...
This diff is collapsed.
Click to expand it.
tests/integration/test_epi.py
+
63
−
16
View file @
b9cb5f9f
...
...
@@ -9,19 +9,20 @@ class TestEpi(unittest.TestCase):
TEST_OUT_PATH
:
str
=
"
not_set
"
TEST_START_DATE
:
str
=
'
20221001
'
TEST_JOB_DIR
:
str
=
"
SUMMARY
_
"
+
TEST_START_DATE
TEST_JOB_DIR
:
str
=
"
EPI
_
"
+
TEST_START_DATE
@classmethod
def
setUpClass
(
cls
)
->
None
:
TestEpi
.
write_temp_run_config_files
()
TestEpi
.
unpack_dependencies
()
TestEpi
.
run_
advisory
_pipeline
()
#
TestEpi.unpack_dependencies()
#
TestEpi.run_
epi
_pipeline()
@staticmethod
def
write_temp_run_config_files
():
nowstring
:
str
=
IntegrationTestUtils
.
get_now_string
()
prefix
:
str
=
"
temp_epi_
"
+
nowstring
# prefix: str = "temp_epi_" + nowstring
prefix
:
str
=
"
temp_epi_2022-11-23_164339
"
# prefix: str = ""
default_config
=
IntegrationTestUtils
.
DEFAULT_CONFIG_FILE_PATH
...
...
@@ -43,7 +44,7 @@ class TestEpi(unittest.TestCase):
@staticmethod
def
run_
advisory
_pipeline
():
def
run_
epi
_pipeline
():
component
=
'
Epidemiology
'
IntegrationTestUtils
.
run_pipeline
(
component
,
TestEpi
.
TEST_START_DATE
)
...
...
@@ -53,19 +54,65 @@ class TestEpi(unittest.TestCase):
success_file_exists
:
bool
=
os
.
path
.
isfile
(
status_file_path
)
self
.
assertTrue
(
success_file_exists
)
def
test_standard_run_input_all_
doc
s_produced
(
self
):
def
test_standard_run_input_all_
stem_rust_file
s_produced
(
self
):
east_africa_image_path
=
os
.
path
.
join
(
TestEpi
.
TEST_OUT_PATH
,
TestEpi
.
TEST_JOB_DIR
,
"
tight-layout
"
,
"
wheat_rust_advisory_template_EastAfrica_20221001.docx
"
)
ethiopia_image_path
=
os
.
path
.
join
(
TestEpi
.
TEST_OUT_PATH
,
TestEpi
.
TEST_JOB_DIR
,
"
tight-layout
"
,
"
wheat_rust_advisory_template_Ethiopia_20221001.docx
"
)
alpha_beta_gamma_root
=
os
.
path
.
join
(
TestEpi
.
TEST_OUT_PATH
,
TestEpi
.
TEST_JOB_DIR
,
"
EastAfrica
"
,
"
StemRust
"
,
"
*psbeta0.004gamma0.00025alpha1.0
"
)
ea_file_exists
:
bool
=
os
.
path
.
isfile
(
east_africa_image_path
)
eth_file_exists
:
bool
=
os
.
path
.
isfile
(
ethiopia_image_path
)
self
.
assertTrue
(
ea_file_exists
)
self
.
assertTrue
(
eth_file_exists
)
self
.
check_wildcard_exists_and_not_empty
(
alpha_beta_gamma_root
,
"
.csv
"
)
self
.
check_wildcard_exists_and_not_empty
(
alpha_beta_gamma_root
,
"
*comparison.png
"
)
self
.
check_wildcard_exists_and_not_empty
(
alpha_beta_gamma_root
,
"
*progression.csv
"
)
self
.
check_wildcard_exists_and_not_empty
(
alpha_beta_gamma_root
,
"
.png
"
)
self
.
check_wildcard_exists_and_not_empty
(
alpha_beta_gamma_root
,
"
.tif
"
)
env_root
=
os
.
path
.
join
(
TestEpi
.
TEST_OUT_PATH
,
TestEpi
.
TEST_JOB_DIR
,
"
EastAfrica
"
,
"
StemRust
"
,
"
infections_temp_config_Epidemiology
"
)
self
.
check_wildcard_exists_and_not_empty
(
env_root
,
"
*env.csv
"
)
self
.
check_wildcard_exists_and_not_empty
(
env_root
,
"
*env.png
"
)
self
.
check_wildcard_exists_and_not_empty
(
env_root
,
"
*env.tif
"
)
data_input_root
=
os
.
path
.
join
(
TestEpi
.
TEST_OUT_PATH
,
TestEpi
.
TEST_JOB_DIR
,
"
EastAfrica
"
,
"
StemRust
"
,
"
input_data
"
,
"
data_input*
"
)
self
.
check_wildcard_exists_and_not_empty
(
data_input_root
,
"
*deposition.csv
"
)
self
.
check_wildcard_exists_and_not_empty
(
data_input_root
,
"
*environment.csv
"
)
map_spam_root
=
os
.
path
.
join
(
TestEpi
.
TEST_OUT_PATH
,
TestEpi
.
TEST_JOB_DIR
,
"
EastAfrica
"
,
"
StemRust
"
,
"
input_data
"
,
"
wheat_area_frac_MapSPAM2010_EastAfrica*
"
)
self
.
check_wildcard_exists_and_not_empty
(
map_spam_root
,
"
.csv
"
)
self
.
check_wildcard_exists_and_not_empty
(
map_spam_root
,
"
.csv
"
)
def
test_standard_run_input_all_plotting_files_produced
(
self
):
input_csvs_root
=
os
.
path
.
join
(
TestEpi
.
TEST_OUT_PATH
,
TestEpi
.
TEST_JOB_DIR
,
"
plotting
"
,
"
input_csvs
"
,
"
*stem*
"
)
self
.
check_wildcard_exists_and_not_empty
(
input_csvs_root
,
"
.csv
"
)
images_root
=
os
.
path
.
join
(
TestEpi
.
TEST_OUT_PATH
,
TestEpi
.
TEST_JOB_DIR
,
"
plotting
"
,
"
images
"
,
"
*stem*
"
)
self
.
check_wildcard_exists_and_not_empty
(
images_root
,
"
png
"
)
def
check_wildcard_exists_and_not_empty
(
self
,
root
:
str
,
extension
:
str
):
file_exists
:
bool
=
IntegrationTestUtils
.
check_wildcard_exists_and_not_empty
(
root
+
extension
)
self
.
assertTrue
(
file_exists
)
if
__name__
==
'
__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