Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-lister
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
Antoine R. Dumont
swh-lister
Commits
f63b8326
Commit
f63b8326
authored
6 years ago
by
David Douard
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for npm tasks
parent
264e9ea5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
swh/lister/core/tests/conftest.py
+1
-0
1 addition, 0 deletions
swh/lister/core/tests/conftest.py
swh/lister/npm/tests/conftest.py
+1
-0
1 addition, 0 deletions
swh/lister/npm/tests/conftest.py
swh/lister/npm/tests/test_tasks.py
+55
-0
55 additions, 0 deletions
swh/lister/npm/tests/test_tasks.py
with
57 additions
and
0 deletions
swh/lister/core/tests/conftest.py
+
1
−
0
View file @
f63b8326
...
...
@@ -13,6 +13,7 @@ def celery_includes():
'
swh.lister.debian.tasks
'
,
'
swh.lister.github.tasks
'
,
'
swh.lister.gitlab.tasks
'
,
'
swh.lister.npm.tasks
'
,
]
...
...
This diff is collapsed.
Click to expand it.
swh/lister/npm/tests/conftest.py
0 → 100644
+
1
−
0
View file @
f63b8326
from
swh.lister.core.tests.conftest
import
*
# noqa
This diff is collapsed.
Click to expand it.
swh/lister/npm/tests/test_tasks.py
0 → 100644
+
55
−
0
View file @
f63b8326
from
contextlib
import
contextmanager
from
unittest.mock
import
patch
@contextmanager
def
mock_save
(
lister
):
yield
def
test_ping
(
swh_app
,
celery_session_worker
):
res
=
swh_app
.
send_task
(
'
swh.lister.npm.tasks.ping
'
)
assert
res
res
.
wait
()
assert
res
.
successful
()
assert
res
.
result
==
'
OK
'
@patch
(
'
swh.lister.npm.tasks.save_registry_state
'
)
@patch
(
'
swh.lister.npm.tasks.NpmLister
'
)
def
test_lister
(
lister
,
save
,
swh_app
,
celery_session_worker
):
# setup the mocked NpmLister
lister
.
return_value
=
lister
lister
.
run
.
return_value
=
None
save
.
side_effect
=
mock_save
res
=
swh_app
.
send_task
(
'
swh.lister.npm.tasks.NpmListerTask
'
)
assert
res
res
.
wait
()
assert
res
.
successful
()
lister
.
assert_called_once_with
()
lister
.
run
.
assert_called_once_with
()
@patch
(
'
swh.lister.npm.tasks.save_registry_state
'
)
@patch
(
'
swh.lister.npm.tasks.get_last_update_seq
'
)
@patch
(
'
swh.lister.npm.tasks.NpmIncrementalLister
'
)
def
test_incremental
(
lister
,
seq
,
save
,
swh_app
,
celery_session_worker
):
# setup the mocked NpmLister
lister
.
return_value
=
lister
lister
.
run
.
return_value
=
None
lister
.
request_headers
.
return_value
=
[]
seq
.
return_value
=
42
save
.
side_effect
=
mock_save
res
=
swh_app
.
send_task
(
'
swh.lister.npm.tasks.NpmIncrementalListerTask
'
)
assert
res
res
.
wait
()
assert
res
.
successful
()
lister
.
assert_called_once_with
()
seq
.
assert_called_once_with
(
lister
)
lister
.
run
.
assert_called_once_with
(
min_bound
=
42
)
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