Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Base Worker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container 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
Workers
Base Worker
Commits
bd5d15ae
Commit
bd5d15ae
authored
3 years ago
by
Valentin Rigal
Browse files
Options
Downloads
Patches
Plain Diff
Update existing tests
parent
00e45a11
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/conftest.py
+12
-0
12 additions, 0 deletions
tests/conftest.py
tests/test_elements_worker/test_worker.py
+7
-25
7 additions, 25 deletions
tests/test_elements_worker/test_worker.py
with
19 additions
and
25 deletions
tests/conftest.py
+
12
−
0
View file @
bd5d15ae
...
@@ -202,6 +202,18 @@ def mock_user_api(responses):
...
@@ -202,6 +202,18 @@ def mock_user_api(responses):
)
)
@pytest.fixture
def
mock_activity_calls
(
responses
):
"""
Mock responses when updating the activity state for multiple element of the same version
"""
responses
.
add
(
responses
.
PUT
,
"
http://testserver/api/v1/workers/versions/12341234-1234-1234-1234-123412341234/activity/
"
,
status
=
200
,
)
@pytest.fixture
@pytest.fixture
def
mock_elements_worker
(
monkeypatch
,
mock_config_api
):
def
mock_elements_worker
(
monkeypatch
,
mock_config_api
):
"""
Build and configure an ElementsWorker with fixed CLI parameters to avoid issues with pytest
"""
"""
Build and configure an ElementsWorker with fixed CLI parameters to avoid issues with pytest
"""
...
...
This diff is collapsed.
Click to expand it.
tests/test_elements_worker/test_worker.py
+
7
−
25
View file @
bd5d15ae
...
@@ -169,7 +169,12 @@ def test_update_call(responses, mock_elements_worker, mock_process_api):
...
@@ -169,7 +169,12 @@ def test_update_call(responses, mock_elements_worker, mock_process_api):
],
],
)
)
def
test_run
(
def
test_run
(
monkeypatch
,
mock_elements_worker
,
responses
,
process_exception
,
final_state
monkeypatch
,
mock_elements_worker
,
responses
,
process_exception
,
final_state
,
mock_activity_calls
,
):
):
"""
Check the normal runtime sends 2 API calls to update activity
"""
"""
Check the normal runtime sends 2 API calls to update activity
"""
# Disable second configure call from run()
# Disable second configure call from run()
...
@@ -193,29 +198,6 @@ def test_run(
...
@@ -193,29 +198,6 @@ def test_run(
"
name
"
:
"
Test Page n°1
"
,
"
name
"
:
"
Test Page n°1
"
,
},
},
)
)
# Mock Update activity
responses
.
add
(
responses
.
PUT
,
"
http://testserver/api/v1/workers/versions/12341234-1234-1234-1234-123412341234/activity/
"
,
status
=
200
,
json
=
{
"
element_id
"
:
"
1234-deadbeef
"
,
"
process_id
"
:
"
aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff
"
,
"
state
"
:
"
started
"
,
},
)
responses
.
add
(
responses
.
PUT
,
"
http://testserver/api/v1/workers/versions/12341234-1234-1234-1234-123412341234/activity/
"
,
status
=
200
,
json
=
{
"
element_id
"
:
"
1234-deadbeef
"
,
"
process_id
"
:
"
aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff
"
,
"
state
"
:
final_state
,
},
)
assert
mock_elements_worker
.
is_read_only
is
False
assert
mock_elements_worker
.
is_read_only
is
False
# Mock exception in process_element
# Mock exception in process_element
...
@@ -262,7 +244,7 @@ def test_run(
...
@@ -262,7 +244,7 @@ def test_run(
def
test_run_cache
(
def
test_run_cache
(
monkeypatch
,
mocker
,
mock_elements_worker_with_cache
,
mock_cached_elements
monkeypatch
,
mocker
,
mock_elements_worker_with_cache
,
mock_cached_elements
,
mock_activity_calls
,
):
):
# Disable second configure call from run()
# Disable second configure call from run()
monkeypatch
.
setattr
(
mock_elements_worker_with_cache
,
"
configure
"
,
lambda
:
None
)
monkeypatch
.
setattr
(
mock_elements_worker_with_cache
,
"
configure
"
,
lambda
:
None
)
...
...
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