Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-indexer
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
Model registry
Operate
Environments
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
Platform
Development
swh-indexer
Commits
c2db7446
Commit
c2db7446
authored
6 years ago
by
vlorentz
Browse files
Options
Downloads
Patches
Plain Diff
Update CommonContentIndexerTest to work with non-mocked storage.
parent
fb34e1aa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!433
Remove mocks from range tests of mimetype and license indexers.
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
swh/indexer/storage/in_memory.py
+1
-2
1 addition, 2 deletions
swh/indexer/storage/in_memory.py
swh/indexer/tests/test_ctags.py
+5
-0
5 additions, 0 deletions
swh/indexer/tests/test_ctags.py
swh/indexer/tests/test_utils.py
+10
-8
10 additions, 8 deletions
swh/indexer/tests/test_utils.py
with
16 additions
and
10 deletions
swh/indexer/storage/in_memory.py
+
1
−
2
View file @
c2db7446
...
...
@@ -166,8 +166,7 @@ class IndexerStorage:
if
conflict_update
:
item_ctags
=
[]
else
:
# TODO: this merges old ctags with new ctags. This is
# pointless, new ctags should replace the old ones.
# merge old ctags with new ctags
existing
=
list
(
self
.
_content_ctags
.
get
([
item
[
'
id
'
]]))
item_ctags
=
[
{
...
...
This diff is collapsed.
Click to expand it.
swh/indexer/tests/test_ctags.py
+
5
−
0
View file @
c2db7446
...
...
@@ -107,8 +107,13 @@ class TestCtagsIndexer(CommonContentIndexerTest, unittest.TestCase):
- Unknown sha1 in the input list are not indexed
"""
def
get_indexer_results
(
self
,
ids
):
yield
from
self
.
idx_storage
.
content_ctags_get
(
ids
)
def
setUp
(
self
):
self
.
indexer
=
CtagsIndexerTest
()
self
.
idx_storage
=
self
.
indexer
.
idx_storage
# Prepare test input
self
.
id0
=
'
01c9379dfc33803963d07c1ccc748d3fe4c96bb5
'
...
...
This diff is collapsed.
Click to expand it.
swh/indexer/tests/test_utils.py
+
10
−
8
View file @
c2db7446
...
...
@@ -659,7 +659,13 @@ class CommonIndexerWithErrorsTest:
class
CommonContentIndexerTest
:
def
assert_results_ok
(
self
,
actual_results
,
expected_results
=
None
):
def
get_indexer_results
(
self
,
ids
):
"""
Override this for indexers that don
'
t have a mock storage.
"""
return
self
.
indexer
.
idx_storage
.
state
def
assert_results_ok
(
self
,
sha1s
,
expected_results
=
None
):
actual_results
=
self
.
get_indexer_results
(
sha1s
)
if
expected_results
is
None
:
expected_results
=
self
.
expected_results
...
...
@@ -678,15 +684,12 @@ class CommonContentIndexerTest:
# when
self
.
indexer
.
run
(
sha1s
,
policy_update
=
'
update-dups
'
)
actual_results
=
self
.
indexer
.
idx_storage
.
state
self
.
assertTrue
(
self
.
indexer
.
idx_storage
.
conflict_update
)
self
.
assert_results_ok
(
actual_results
)
self
.
assert_results_ok
(
sha1s
)
# 2nd pass
self
.
indexer
.
run
(
sha1s
,
policy_update
=
'
ignore-dups
'
)
self
.
assertFalse
(
self
.
indexer
.
idx_storage
.
conflict_update
)
self
.
assert_results_ok
(
actual_results
)
self
.
assert_results_ok
(
sha1s
)
def
test_index_one_unknown_sha1
(
self
):
"""
Unknown sha1 are not indexed
"""
...
...
@@ -696,14 +699,13 @@ class CommonContentIndexerTest:
# when
self
.
indexer
.
run
(
sha1s
,
policy_update
=
'
update-dups
'
)
actual_results
=
self
.
indexer
.
idx_storage
.
state
# then
expected_results
=
{
k
:
v
for
k
,
v
in
self
.
expected_results
.
items
()
if
k
in
sha1s
}
self
.
assert_results_ok
(
actual_result
s
,
expected_results
)
self
.
assert_results_ok
(
sha1
s
,
expected_results
)
class
CommonContentIndexerRangeTest
:
...
...
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