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
0419e50c
Commit
0419e50c
authored
2 years ago
by
L. Bower
Browse files
Options
Downloads
Patches
Plain Diff
restructuring the advisory test to get ready for a full-fat implementation
parent
db3eb80d
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/partial/test_advisory.py
+22
-58
22 additions, 58 deletions
tests/integration/partial/test_advisory.py
tests/integration/test_suites/advisory_test_suite.py
+67
-0
67 additions, 0 deletions
tests/integration/test_suites/advisory_test_suite.py
with
89 additions
and
58 deletions
tests/integration/partial/test_advisory.py
+
22
−
58
View file @
0419e50c
import
copy
import
copy
import
glob
import
os
import
os
import
unittest
import
unittest
from
integration.partial.integration_test_utils
import
IntegrationTestUtils
from
integration.partial.integration_test_utils
import
IntegrationTestUtils
from
integration.test_suites.advisory_test_suite
import
BaseAdvisoryTestSuite
class
TestAdvisory
(
unittest
.
TestCas
e
):
class
TestAdvisory
(
BaseAdvisoryTestSuite
.
AdvisoryTestSuit
e
):
TEST_OUT_PATH
:
str
=
"
not_set
"
def
set_expected_values
(
self
):
TEST_START_DATE
:
str
=
'
20221001
'
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_START_DATE
=
'
20221001
'
TEST_JOB_DIR
:
str
=
"
ADVISORY_
"
+
TEST_START_DATE
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_JOB_DIR
=
"
ADVISORY_
"
+
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_START_DATE
@classmethod
def
setUpClass
(
cls
)
->
None
:
def
setUp
(
self
)
->
None
:
TestAdvisory
.
write_temp_run_config_files
()
TestAdvisory
.
unpack_dependencies
()
self
.
set_expected_values
()
TestAdvisory
.
run_advisory_pipeline
()
if
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_OUT_PATH
is
None
or
not
os
.
path
.
isdir
(
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_OUT_PATH
):
TestAdvisory
.
write_temp_run_config_files
()
TestAdvisory
.
unpack_dependencies
()
TestAdvisory
.
run_advisory_pipeline
()
else
:
print
(
f
"
output in
{
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_OUT_PATH
}
already written, skipping rerun
"
)
@staticmethod
@staticmethod
def
write_temp_run_config_files
():
def
write_temp_run_config_files
():
nowstring
:
str
=
IntegrationTestUtils
.
get_now_string
()
nowstring
:
str
=
IntegrationTestUtils
.
get_now_string
()
prefix
:
str
=
"
temp_advisory_
"
+
nowstring
#
prefix: str = "temp_advisory_" + nowstring
#
prefix: str = ""
prefix
:
str
=
"
temp_advisory
"
default_config
=
IntegrationTestUtils
.
DEFAULT_CONFIG_FILE_PATH
default_config
=
IntegrationTestUtils
.
DEFAULT_CONFIG_FILE_PATH
default_config_dict
:
dict
=
IntegrationTestUtils
.
load_json_file
(
default_config
)
default_config_dict
:
dict
=
IntegrationTestUtils
.
load_json_file
(
default_config
)
run_dict
:
dict
=
copy
.
deepcopy
(
default_config_dict
)
run_dict
:
dict
=
copy
.
deepcopy
(
default_config_dict
)
TestAdvisory
.
TEST_OUT_PATH
=
run_dict
[
'
WorkspacePathout
'
]
+
prefix
+
os
.
sep
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_OUT_PATH
=
IntegrationTestUtils
.
TEST_WORKSPACE_PATH
+
prefix
+
os
.
sep
run_dict
[
'
WorkspacePathout
'
]
=
TestAdvisory
.
TEST_OUT_PATH
# TestAdvisory.TEST_OUT_PATH = run_dict['WorkspacePathout'] + prefix + os.sep
run_dict
[
'
WorkspacePath
'
]
=
TestAdvisory
.
TEST_OUT_PATH
run_dict
[
'
WorkspacePathout
'
]
=
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_OUT_PATH
run_dict
[
'
WorkspacePath
'
]
=
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_OUT_PATH
run_dict
[
'
ServerName
'
]
=
''
# nothing, as local machine
run_dict
[
'
ServerName
'
]
=
''
# nothing, as local machine
IntegrationTestUtils
.
write_json_file
(
run_dict
,
IntegrationTestUtils
.
TEMP_CONFIG_FILE_NAME
)
IntegrationTestUtils
.
write_json_file
(
run_dict
,
IntegrationTestUtils
.
TEMP_CONFIG_FILE_NAME
)
...
@@ -49,48 +56,5 @@ class TestAdvisory(unittest.TestCase):
...
@@ -49,48 +56,5 @@ class TestAdvisory(unittest.TestCase):
IntegrationTestUtils
.
run_unittest_pipeline
(
component
,
TestAdvisory
.
TEST_START_DATE
)
IntegrationTestUtils
.
run_unittest_pipeline
(
component
,
TestAdvisory
.
TEST_START_DATE
)
def
test_standard_run_input_status_success
(
self
):
status_file_path
=
os
.
path
.
join
(
TestAdvisory
.
TEST_OUT_PATH
,
TestAdvisory
.
TEST_JOB_DIR
,
"
STATUS_SUCCESS
"
)
success_file_exists
:
bool
=
os
.
path
.
isfile
(
status_file_path
)
self
.
assertTrue
(
success_file_exists
)
def
test_standard_run_input_all_docs_produced
(
self
):
east_africa_image_path
=
os
.
path
.
join
(
TestAdvisory
.
TEST_OUT_PATH
,
TestAdvisory
.
TEST_JOB_DIR
,
"
tight-layout
"
,
"
wheat_rust_advisory_template_EastAfrica_20221001.docx
"
)
ethiopia_image_path
=
os
.
path
.
join
(
TestAdvisory
.
TEST_OUT_PATH
,
TestAdvisory
.
TEST_JOB_DIR
,
"
tight-layout
"
,
"
wheat_rust_advisory_template_Ethiopia_20221001.docx
"
)
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
)
def
test_standard_run_input_images_produced
(
self
):
east_africa_image_wildcard
=
os
.
path
.
join
(
TestAdvisory
.
TEST_OUT_PATH
,
TestAdvisory
.
TEST_JOB_DIR
,
"
images
"
,
"
*eastafrica*.png
"
)
ethiopia_image_wildcard
=
os
.
path
.
join
(
TestAdvisory
.
TEST_OUT_PATH
,
TestAdvisory
.
TEST_JOB_DIR
,
"
images
"
,
"
*ethiopia*.png
"
)
africa_image_count
:
int
=
len
(
glob
.
glob
(
east_africa_image_wildcard
))
ethiopia_image_count
:
int
=
len
(
glob
.
glob
(
ethiopia_image_wildcard
))
self
.
assertEqual
(
3
,
africa_image_count
)
self
.
assertEqual
(
3
,
ethiopia_image_count
)
def
test_standard_run_input_shapefiles_produced
(
self
):
east_africa_image_wildcard
=
os
.
path
.
join
(
TestAdvisory
.
TEST_OUT_PATH
,
TestAdvisory
.
TEST_JOB_DIR
,
"
images
"
,
"
*eastafrica*.shp
"
)
africa_image_count
:
int
=
len
(
glob
.
glob
(
east_africa_image_wildcard
))
self
.
assertEqual
(
3
,
africa_image_count
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
unittest
.
main
()
unittest
.
main
()
This diff is collapsed.
Click to expand it.
tests/integration/test_suites/advisory_test_suite.py
0 → 100644
+
67
−
0
View file @
0419e50c
import
abc
import
glob
import
os
import
unittest
from
integration.partial.integration_test_utils
import
IntegrationTestUtils
class
BaseAdvisoryTestSuite
:
class
AdvisoryTestSuite
(
unittest
.
TestCase
):
TEST_OUT_PATH
:
str
=
None
TEST_START_DATE
:
str
=
None
TEST_JOB_DIR
:
str
=
None
@abc.abstractmethod
def
set_expected_values
(
self
):
pass
def
test_standard_run_input_status_success
(
self
):
status_file_path
=
os
.
path
.
join
(
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_OUT_PATH
,
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_JOB_DIR
,
"
STATUS_SUCCESS
"
)
success_file_exists
:
bool
=
os
.
path
.
isfile
(
status_file_path
)
self
.
assertTrue
(
success_file_exists
)
def
test_standard_run_input_all_docs_produced
(
self
):
east_africa_image_path
=
os
.
path
.
join
(
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_OUT_PATH
,
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_JOB_DIR
,
"
tight-layout
"
,
"
wheat_rust_advisory_template_EastAfrica_20221001.docx
"
)
ethiopia_image_path
=
os
.
path
.
join
(
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_OUT_PATH
,
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_JOB_DIR
,
"
tight-layout
"
,
"
wheat_rust_advisory_template_Ethiopia_20221001.docx
"
)
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
)
def
test_standard_run_input_images_produced
(
self
):
east_africa_image_wildcard
=
os
.
path
.
join
(
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_OUT_PATH
,
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_JOB_DIR
,
"
images
"
,
"
*eastafrica*.png
"
)
ethiopia_image_wildcard
=
os
.
path
.
join
(
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_OUT_PATH
,
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_JOB_DIR
,
"
images
"
,
"
*ethiopia*.png
"
)
africa_image_count
:
int
=
len
(
glob
.
glob
(
east_africa_image_wildcard
))
ethiopia_image_count
:
int
=
len
(
glob
.
glob
(
ethiopia_image_wildcard
))
self
.
assertEqual
(
3
,
africa_image_count
)
self
.
assertEqual
(
3
,
ethiopia_image_count
)
def
test_standard_run_input_shapefiles_produced
(
self
):
east_africa_image_wildcard
=
os
.
path
.
join
(
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_OUT_PATH
,
BaseAdvisoryTestSuite
.
AdvisoryTestSuite
.
TEST_JOB_DIR
,
"
images
"
,
"
*eastafrica*.shp
"
)
africa_image_count
:
int
=
len
(
glob
.
glob
(
east_africa_image_wildcard
))
self
.
assertEqual
(
3
,
africa_image_count
)
\ No newline at end of file
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