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
!176
Delivery rework
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Delivery rework
delivery-rework
into
main
Overview
10
Commits
5
Pipelines
4
Changes
15
7 unresolved threads
Hide all comments
Merged
Daniel Lyons
requested to merge
delivery-rework
into
main
3 years ago
Overview
10
Commits
5
Pipelines
4
Changes
2
7 unresolved threads
Hide all comments
Expand
Clean up destination code and add some functionality
Split the destinations into separate files
New DestinationTempFile for writing tempfiles into the destination which eventually get added
All of the close() methods are now streaming
Implemented ChecksumDecorator, so we get a SHA1SUMS file
Implemented FetchFile decorator, so we get a rudimentary fetch-all.sh script
Configured Docker and delivery for local development to have a separate volume mount for serving files
0
0
Merge request reports
Compare
version 1
version 3
74ebed80
3 years ago
version 2
298cc45d
3 years ago
version 1
be61a3bd
3 years ago
main (base)
and
version 2
latest version
32ac7fd4
5 commits,
3 years ago
version 3
74ebed80
5 commits,
3 years ago
version 2
298cc45d
4 commits,
3 years ago
version 1
be61a3bd
3 commits,
3 years ago
Show latest version
2 files
+
74
−
55
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
apps/cli/executables/delivery/test/test_api.py
+
59
−
16
Options
import
filecmp
import
pathlib
from
os
import
path
import
pytest
from
delivery.deliverer
import
LocalDestination
def
test_local_delivery_add_file
(
tmpdir
):
"""
Ensure that local delivery does something
"""
@pytest.fixture
Janet Goldstein
@jgoldste
·
3 years ago
this and the next function need pydoc
Please
register
or
sign in
to reply
def
dest_dir
(
tmpdir
)
->
pathlib
.
Path
:
"""
Generate a destination directory.
:param tmpdir: the tmpdir fixture we depend on
:return: path to the destination directory
"""
# generate the destination directory
dest_dir
=
pathlib
.
Path
(
tmpdir
)
/
"
after
"
dest_dir
.
mkdir
()
return
dest_dir
@pytest.fixture
def
file_to_deliver
(
tmpdir
)
->
pathlib
.
Path
:
"""
Generate some files in a test directory for delivery.
:param tmpdir: pytest fixture for the temporary directory
:return: a file in the test directory
"""
# rewrap the tmpdir as a pathlib.Path instance
tmpdir
=
pathlib
.
Path
(
tmpdir
)
# generate the test file in prior
(
tmpdir
/
"
prior
"
).
mkdir
()
file_name
=
"
test.txt
"
temp_file
=
tmpdir
.
mkdir
(
"
prior
"
).
join
(
file_name
)
# place a file into the source
temp_file
=
tmpdir
/
"
prior
"
/
file_name
# place a file into the source
temp_file
.
write_text
(
"
content
"
,
encoding
=
None
)
# write something into that file
dest_dir
=
tmpdir
.
mkdir
(
"
after
"
)
# create a destination
# secretly generate a second file
temp_file2
=
tmpdir
/
"
prior
"
/
"
test2.txt
"
# make another file in source
temp_file2
.
write_text
(
"
more content
"
,
encoding
=
None
)
# add some content to the second file
return
temp_file
def
test_local_delivery_add_file
(
tmpdir
,
file_to_deliver
:
pathlib
.
Path
,
dest_dir
:
pathlib
.
Path
):
"""
Ensure that local delivery works
"""
# generate the destination
local_dest
=
LocalDestination
(
None
,
dest_dir
)
local_dest
.
add_file
(
temp_file
,
str
(
dest_dir
/
file_name
))
# add the file to it
local_dest
.
add_file
(
file_to_deliver
,
file_to_deliver
.
name
)
# see if the source file eneded up in the destination
assert
path
.
exists
(
dest_dir
/
file_name
)
assert
(
dest_dir
/
file_to_deliver
.
name
).
exists
()
# see if the content of the file is intact
assert
(
dest_dir
/
file_name
).
read_text
(
encoding
=
None
)
==
"
content
"
assert
(
dest_dir
/
file_
to_deliver
.
name
).
read_text
(
encoding
=
None
)
==
"
content
"
def
test_local_delivery_add_directory
(
tmpdir
):
def
test_local_delivery_add_directory
(
tmpdir
:
pathlib
.
Path
,
file_to_deliver
:
pathlib
.
Path
,
dest_dir
:
pathlib
.
Path
):
"""
Ensure that local delivery does something
"""
source_dir
=
tmpdir
.
mkdir
(
"
prior
"
)
# create a source
temp_file
=
source_dir
.
join
(
"
test.txt
"
)
# add a file to the source dir
temp_file
.
write_text
(
"
content
"
,
encoding
=
None
)
# add some content to the file
temp_file2
=
source_dir
.
join
(
"
test2.txt
"
)
# make another file in source
temp_file2
.
write_text
(
"
more content
"
,
encoding
=
None
)
# add some content to the second file
local_dest
=
LocalDestination
(
None
,
str
(
tmpdir
))
local_dest
.
add_directory
(
source_dir
,
"
after
"
)
# destination is defined here
compare_dirs
=
filecmp
.
dircmp
(
source_dir
,
tmpdir
/
"
after
"
)
tmpdir
=
pathlib
.
Path
(
tmpdir
)
local_dest
=
LocalDestination
(
None
,
dest_dir
)
local_dest
.
add_directory
(
file_to_deliver
.
parent
,
file_to_deliver
.
parent
.
name
)
compare_dirs
=
filecmp
.
dircmp
(
file_to_deliver
.
parent
,
dest_dir
/
"
prior
"
)
# see if the destination got all the files from source
assert
(
len
(
compare_dirs
.
left_only
)
==
0
Loading
this and the next function need pydoc