Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-web
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre-Yves David
swh-web
Commits
e61a0dbb
Commit
e61a0dbb
authored
2 years ago
by
vlorentz
Browse files
Options
Downloads
Patches
Plain Diff
test_metadata: Reuse swh-model's raw_extrinsic_metadata() strategy
It now allows setting custom strategies as 'target'
parent
4e388ee9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
requirements-swh.txt
+1
-1
1 addition, 1 deletion
requirements-swh.txt
swh/web/tests/api/views/test_metadata.py
+9
-20
9 additions, 20 deletions
swh/web/tests/api/views/test_metadata.py
with
10 additions
and
21 deletions
requirements-swh.txt
+
1
−
1
View file @
e61a0dbb
...
...
@@ -2,7 +2,7 @@ swh.auth[django] >= 0.5.3
swh.core >= 0.0.95
swh.counters >= 0.5.1
swh.indexer >= 2.0.0
swh.model >= 6.
2
.0
swh.model >= 6.
3
.0
swh.scheduler >= 0.7.0
swh.search >= 0.2.0
swh.storage >= 1.4.0
...
...
This diff is collapsed.
Click to expand it.
swh/web/tests/api/views/test_metadata.py
+
9
−
20
View file @
e61a0dbb
...
...
@@ -8,32 +8,21 @@ from hypothesis import given
from
hypothesis.strategies
import
composite
,
sampled_from
,
sets
import
pytest
from
swh.model.hypothesis_strategies
import
(
raw_extrinsic_metadata
as
raw_extrinsic_metadata_orig
,
)
from
swh.model.hypothesis_strategies
import
sha1_git
from
swh.model.swhids
import
ExtendedObjectType
,
ExtendedSWHID
,
ObjectType
from
swh.model.hypothesis_strategies
import
raw_extrinsic_metadata
,
sha1_git
from
swh.model.swhids
import
CoreSWHID
,
ObjectType
from
swh.web.common.utils
import
reverse
from
swh.web.tests.api.views.utils
import
scroll_results
from
swh.web.tests.utils
import
check_api_get_responses
,
check_http_get_response
# public Web API endpoint for raw extrinsic metadata does not support
# extended SWHIDs so we ensure only core ones will be used in test inputs.
@composite
def
raw_extrinsic_metadata
(
draw
):
remd
=
draw
(
raw_extrinsic_metadata_orig
())
remd
=
attr
.
evolve
(
remd
,
target
=
ExtendedSWHID
(
object_type
=
ExtendedObjectType
(
draw
(
sampled_from
(
ObjectType
)).
value
),
object_id
=
draw
(
sha1_git
()),
),
)
return
attr
.
evolve
(
remd
,
id
=
remd
.
compute_hash
())
def
core_swhids
(
draw
):
object_type
=
draw
(
sampled_from
(
ObjectType
))
object_id
=
draw
(
sha1_git
())
return
CoreSWHID
(
object_type
=
object_type
,
object_id
=
object_id
).
to_extended
()
@given
(
raw_extrinsic_metadata
())
@given
(
raw_extrinsic_metadata
(
target
=
core_swhids
()
))
def
test_api_raw_extrinsic_metadata
(
api_client
,
subtest
,
metadata
):
# ensure archive_data fixture will be reset between each hypothesis
# example test run
...
...
@@ -73,7 +62,7 @@ def test_api_raw_extrinsic_metadata(api_client, subtest, metadata):
@pytest.mark.parametrize
(
"
limit
"
,
[
1
,
2
,
10
,
100
])
@given
(
sets
(
raw_extrinsic_metadata
(),
min_size
=
1
))
@given
(
sets
(
raw_extrinsic_metadata
(
target
=
core_swhids
()
),
min_size
=
1
))
def
test_api_raw_extrinsic_metadata_scroll
(
api_client
,
subtest
,
limit
,
meta
):
# ensure archive_data fixture will be reset between each hypothesis
# example test run
...
...
@@ -179,7 +168,7 @@ def test_api_raw_extrinsic_metadata_check_params(
check_api_get_responses
(
api_client
,
url
,
status_code
=
status_code
)
@given
(
raw_extrinsic_metadata
())
@given
(
raw_extrinsic_metadata
(
target
=
core_swhids
()
))
def
test_api_raw_extrinsic_metadata_list_authorities
(
api_client
,
subtest
,
metadata
):
# ensure archive_data fixture will be reset between each hypothesis
# example test run
...
...
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