Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
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
ssa
workspaces
Merge requests
!670
WS-796: tests for delivery of initial_weblog with final standard calibration
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
WS-796: tests for delivery of initial_weblog with final standard calibration
WS-796-verify-download-weblogs
into
main
Overview
1
Commits
2
Pipelines
2
Changes
1
1 unresolved thread
Hide all comments
Merged
Janet Goldstein
requested to merge
WS-796-verify-download-weblogs
into
main
3 years ago
Overview
1
Commits
2
Pipelines
2
Changes
1
1 unresolved thread
Hide all comments
Expand
test written for initial calibration use case
test written for final calibration use case
0
0
Merge request reports
Compare
main
version 1
16b3169c
3 years ago
main (base)
and
version 1
latest version
972cb5a3
2 commits,
3 years ago
version 1
16b3169c
1 commit,
3 years ago
1 file
+
119
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
apps/cli/executables/pexable/deliver/test/test_final_cal.py
0 → 100644
+
119
−
0
Options
#
# Copyright (C) 2021 Associated Universities, Inc. Washington DC, USA.
#
# This file is part of NRAO Workspaces.
#
# Workspaces is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Workspaces is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Workspaces. If not, see <https://www.gnu.org/licenses/>.
"""
Tests for delivery standard calibration products
"""
import
pathlib
from
unittest.mock
import
patch
# pylint: disable=C0103, R0903, W0511
Nathan Hertz
@nhertz
·
3 years ago
Same with this
pylint
ignore.
Collapse replies
Janet Goldstein
changed this line in
version 2 of the diff
3 years ago
changed this line in
version 2 of the diff
Please
register
or
sign in
to reply
Please
register
or
sign in
to reply
from
_pytest.tmpdir
import
TempdirFactory
from
delivery.context
import
DeliveryContext
from
delivery.delivery
import
Delivery
WEBLOG_FILENAME
=
"
weblog.tgz
"
INIT_WEBLOG_FILENAME
=
"
initial_weblog.tgz
"
SDM_NAME
=
"
17A-109.sb33151331.eb33786546.57892.65940042824
"
# TODO Some Fine Day: consolidate duplicate code
def
test_no_init_weblog_in_first_cal
(
resource_path_root
,
tmpdir_factory
:
TempdirFactory
,
capsys
):
"""
If there is just one version of a standard calibration,
weblog.tgz should be delivered, but not initial_weblog.tgz.
:return:
"""
temp_directory
=
pathlib
.
Path
(
tmpdir_factory
.
mktemp
(
"
test_no_init_weblog_in_first_cal
"
))
assert
temp_directory
.
is_dir
()
test_data_path
=
resource_path_root
/
"
724126739_with_tmp
"
assert
test_data_path
.
is_dir
()
top_dir
=
test_data_path
/
SDM_NAME
assert
top_dir
.
is_dir
()
working_dir
=
top_dir
/
"
working
"
assert
working_dir
.
is_dir
()
weblog
=
working_dir
/
WEBLOG_FILENAME
try
:
weblog
.
touch
()
test_context
=
DeliveryContext
.
parse_commandline
([
"
-r
"
,
str
(
test_data_path
)])
with
patch
(
"
delivery.destinations.sharedweb.CapoConfig
"
)
as
mocked_capo_config
:
mocked_capo_config
.
return_value
.
settings
.
return_value
.
downloadDirectory
=
str
(
temp_directory
)
mocked_capo_config
.
return_value
.
settings
.
return_value
.
downloadUrl
=
"
http://testing
"
assert
str
(
temp_directory
)
==
mocked_capo_config
().
settings
().
downloadDirectory
results
=
Delivery
().
deliver
(
test_context
)
actual_delivery_dir
=
pathlib
.
Path
(
results
[
"
delivered_to
"
])
top_dir
=
actual_delivery_dir
/
SDM_NAME
working_dir
=
top_dir
/
"
working
"
wl
=
working_dir
/
WEBLOG_FILENAME
assert
wl
.
exists
()
il
=
working_dir
/
INIT_WEBLOG_FILENAME
assert
not
il
.
exists
()
finally
:
weblog
.
unlink
()
capsys
.
readouterr
()
def
test_both_weblogs_in_final_cal
(
resource_path_root
,
tmpdir_factory
:
TempdirFactory
,
capsys
):
"""
If there is just one version of a standard calibration,
weblog.tgz -and- initial_weblog.tgz should be delivered.
:return:
"""
temp_directory
=
pathlib
.
Path
(
tmpdir_factory
.
mktemp
(
"
test_init_weblog_in_final_cal
"
))
assert
temp_directory
.
is_dir
()
test_data_path
=
resource_path_root
/
"
724126739_with_tmp
"
assert
test_data_path
.
is_dir
()
top_dir
=
test_data_path
/
SDM_NAME
assert
top_dir
.
is_dir
()
working_dir
=
top_dir
/
"
working
"
assert
working_dir
.
is_dir
()
weblog
=
working_dir
/
WEBLOG_FILENAME
init_weblog
=
working_dir
/
INIT_WEBLOG_FILENAME
try
:
weblog
.
touch
()
init_weblog
.
touch
()
test_context
=
DeliveryContext
.
parse_commandline
([
"
-r
"
,
str
(
test_data_path
)])
with
patch
(
"
delivery.destinations.sharedweb.CapoConfig
"
)
as
mocked_capo_config
:
mocked_capo_config
.
return_value
.
settings
.
return_value
.
downloadDirectory
=
str
(
temp_directory
)
mocked_capo_config
.
return_value
.
settings
.
return_value
.
downloadUrl
=
"
http://testing
"
assert
str
(
temp_directory
)
==
mocked_capo_config
().
settings
().
downloadDirectory
results
=
Delivery
().
deliver
(
test_context
)
actual_delivery_dir
=
pathlib
.
Path
(
results
[
"
delivered_to
"
])
top_dir
=
actual_delivery_dir
/
SDM_NAME
working_dir
=
top_dir
/
"
working
"
wl
=
working_dir
/
WEBLOG_FILENAME
assert
wl
.
exists
()
il
=
working_dir
/
INIT_WEBLOG_FILENAME
assert
il
.
exists
()
finally
:
weblog
.
unlink
()
init_weblog
.
unlink
()
capsys
.
readouterr
()
Loading
Same with this
pylint
ignore.changed this line in version 2 of the diff