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
!1036
make productfectcher use default threads capo property
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
make productfectcher use default threads capo property
productfetcher_tweaks
into
main
Overview
0
Commits
4
Pipelines
4
Changes
3
Merged
Charlotte Hausman
requested to merge
productfetcher_tweaks
into
main
2 years ago
Overview
0
Commits
4
Pipelines
4
Changes
1
Expand
0
0
Merge request reports
Compare
version 2
version 3
54261ade
2 years ago
version 2
8b151e6f
2 years ago
version 1
13e191a7
2 years ago
main (base)
and
latest version
latest version
78e52d60
4 commits,
2 years ago
version 3
54261ade
3 commits,
2 years ago
version 2
8b151e6f
2 commits,
2 years ago
version 1
13e191a7
1 commit,
2 years ago
Show latest version
1 file
+
51
−
46
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
apps/cli/executables/pexable/productfetcher/tests/test_product_fetcher.py
+
51
−
46
Options
@@ -21,6 +21,7 @@
from
pathlib
import
Path
from
typing
import
List
,
Union
from
unittest.mock
import
patch
import
pytest
from
productfetcher.fetchers
import
DryRunFakeFileFetcher
,
ForceMode
@@ -87,27 +88,29 @@ def test_multiple_locator_fetching(capsys, resource_path_root):
:param capsys:
:return:
"""
img
=
resource_path_root
/
"
location_files
"
/
"
IMG.json
"
cal
=
resource_path_root
/
"
location_files
"
/
"
CALIBRATION.json
"
with
patch
(
"
productfetcher.product_fetcher.CapoConfig
"
)
as
mocked_capo
:
mocked_capo
.
return_value
.
settings
.
return_value
.
defaultThreadsPerHost
=
1
img
=
resource_path_root
/
"
location_files
"
/
"
IMG.json
"
cal
=
resource_path_root
/
"
location_files
"
/
"
CALIBRATION.json
"
# parse the command line with these two
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
FILE
.
value
,
str
(
img
),
CLIParam
.
FILE
.
value
,
str
(
cal
)])
assert
len
(
fc
.
locators
)
==
2
# parse the command line with these two
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
FILE
.
value
,
str
(
img
),
CLIParam
.
FILE
.
value
,
str
(
cal
)])
assert
len
(
fc
.
locators
)
==
2
# let's make the plan and ensure we have all the stuff we expect from both
plan
=
fc
.
generate_plan
()
# let's make the plan and ensure we have all the stuff we expect from both
plan
=
fc
.
generate_plan
()
# we'll need to open these files ourselves to figure out what fetchers we expect
for
locator_file
in
[
img
,
cal
]:
for
file
in
FileLocator
(
locator_file
).
locate
().
files
:
seen
=
False
# we'll need to open these files ourselves to figure out what fetchers we expect
for
locator_file
in
[
img
,
cal
]:
for
file
in
FileLocator
(
locator_file
).
locate
().
files
:
seen
=
False
# there may be a more "test friendly" way of doing this, such as by asking the plan
# if it is fetching a certain file, but it seems like a lot of refactoring for this
# one test, so I'm going to leave it alone for now
for
hostgroup_fetcher
in
plan
.
fetchers
:
seen
=
seen
or
file
in
[
fetcher
.
file
for
fetcher
in
hostgroup_fetcher
.
fetchers
]
assert
seen
# there may be a more "test friendly" way of doing this, such as by asking the plan
# if it is fetching a certain file, but it seems like a lot of refactoring for this
# one test, so I'm going to leave it alone for now
for
hostgroup_fetcher
in
plan
.
fetchers
:
seen
=
seen
or
file
in
[
fetcher
.
file
for
fetcher
in
hostgroup_fetcher
.
fetchers
]
assert
seen
def
test_argument_parsing
(
capsys
):
@@ -117,32 +120,34 @@ def test_argument_parsing(capsys):
:param capsys:
:return:
"""
# ensure that various combinations do not work
with
pytest
.
raises
(
SystemExit
):
# must have an SPL or a file
FetchContext
.
parse_commandline
([])
# check the dry run value
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
DRY
.
value
,
CLIParam
.
FILE
.
value
,
"
foo
"
])
assert
fc
.
dry_run
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
FILE
.
value
,
"
foo
"
])
assert
not
fc
.
dry_run
# check the force value
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
FORCE
.
value
,
CLIParam
.
FILE
.
value
,
"
foo
"
])
assert
fc
.
force
==
ForceMode
.
FORCE
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
FILE
.
value
,
"
foo
"
])
assert
fc
.
force
==
ForceMode
.
NORMAL
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
FILE
.
value
,
"
foo
"
])
assert
isinstance
(
fc
.
locators
[
0
],
FileLocator
)
assert
fc
.
locators
[
0
].
file
==
Path
(
"
foo
"
)
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
SPL
.
value
,
"
uid://this/is/a/fakesy
"
])
assert
isinstance
(
fc
.
locators
[
0
],
ServiceLocator
)
assert
fc
.
locators
[
0
].
spl
==
"
uid://this/is/a/fakesy
"
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
FILE
.
value
,
"
foo
"
,
CLIParam
.
CONCURRENCY
.
value
,
"
732
"
])
assert
fc
.
concurrency
==
732
capsys
.
readouterr
()
with
patch
(
"
productfetcher.product_fetcher.CapoConfig
"
)
as
mocked_capo
:
mocked_capo
.
return_value
.
settings
.
return_value
.
defaultThreadsPerHost
=
1
# ensure that various combinations do not work
with
pytest
.
raises
(
SystemExit
):
# must have an SPL or a file
FetchContext
.
parse_commandline
([])
# check the dry run value
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
DRY
.
value
,
CLIParam
.
FILE
.
value
,
"
foo
"
])
assert
fc
.
dry_run
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
FILE
.
value
,
"
foo
"
])
assert
not
fc
.
dry_run
# check the force value
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
FORCE
.
value
,
CLIParam
.
FILE
.
value
,
"
foo
"
])
assert
fc
.
force
==
ForceMode
.
FORCE
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
FILE
.
value
,
"
foo
"
])
assert
fc
.
force
==
ForceMode
.
NORMAL
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
FILE
.
value
,
"
foo
"
])
assert
isinstance
(
fc
.
locators
[
0
],
FileLocator
)
assert
fc
.
locators
[
0
].
file
==
Path
(
"
foo
"
)
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
SPL
.
value
,
"
uid://this/is/a/fakesy
"
])
assert
isinstance
(
fc
.
locators
[
0
],
ServiceLocator
)
assert
fc
.
locators
[
0
].
spl
==
"
uid://this/is/a/fakesy
"
fc
=
FetchContext
.
parse_commandline
([
CLIParam
.
FILE
.
value
,
"
foo
"
,
CLIParam
.
CONCURRENCY
.
value
,
"
732
"
])
assert
fc
.
concurrency
==
732
capsys
.
readouterr
()
Loading