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
Commits
7085f19f
Commit
7085f19f
authored
3 years ago
by
Janet Goldstein
Browse files
Options
Downloads
Patches
Plain Diff
WS-796: tests for delivery of initial_weblog with final standard calibration
parent
4aefef11
No related branches found
Branches containing commit
Tags
end-of-sprint-25
Tags containing commit
1 merge request
!670
WS-796: tests for delivery of initial_weblog with final standard calibration
Pipeline
#3739
passed
3 years ago
Stage: cache-build
Stage: build
Stage: unit-test
Stage: push
Stage: generate-yaml
Stage: trigger
Stage: deploy
Stage: e2e-test
Stage: .post
Pipeline: workspaces
#3740
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/cli/executables/pexable/deliver/test/test_final_cal.py
+119
-0
119 additions, 0 deletions
apps/cli/executables/pexable/deliver/test/test_final_cal.py
with
119 additions
and
0 deletions
apps/cli/executables/pexable/deliver/test/test_final_cal.py
0 → 100644
+
119
−
0
View file @
7085f19f
#
# 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
"""
# pylint: disable=C0103, R0903, W0511
import
pathlib
from
unittest.mock
import
patch
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
()
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