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
3b70083a
Commit
3b70083a
authored
3 years ago
by
Eva Bardou
Browse files
Options
Downloads
Patches
Plain Diff
Fix tests
parent
7559cda0
No related branches found
No related tags found
1 merge request
!101
Refactoring use_cache attribute on Worker classes
Pipeline
#78506
passed
3 years ago
Stage: test
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/conftest.py
+4
-10
4 additions, 10 deletions
tests/conftest.py
tests/test_base_worker.py
+1
-1
1 addition, 1 deletion
tests/test_base_worker.py
tests/test_elements_worker/test_elements.py
+1
-1
1 addition, 1 deletion
tests/test_elements_worker/test_elements.py
with
6 additions
and
12 deletions
tests/conftest.py
+
4
−
10
View file @
3b70083a
...
...
@@ -91,14 +91,6 @@ def setup_api(responses, monkeypatch, cache_yaml):
monkeypatch
.
setenv
(
"
ARKINDEX_API_TOKEN
"
,
"
unittest1234
"
)
@pytest.fixture
(
autouse
=
True
)
def
temp_working_directory
(
monkeypatch
,
tmp_path
):
def
_getcwd
():
return
str
(
tmp_path
)
monkeypatch
.
setattr
(
os
,
"
getcwd
"
,
_getcwd
)
@pytest.fixture
(
autouse
=
True
)
def
give_worker_version_id_env_variable
(
monkeypatch
):
monkeypatch
.
setenv
(
"
WORKER_VERSION_ID
"
,
"
12341234-1234-1234-1234-123412341234
"
)
...
...
@@ -183,9 +175,11 @@ def mock_base_worker_with_cache(mocker, monkeypatch, mock_worker_version_api):
@pytest.fixture
def
mock_elements_worker_with_cache
(
monkeypatch
,
mock_worker_version_api
):
def
mock_elements_worker_with_cache
(
monkeypatch
,
mock_worker_version_api
,
tmp_path
):
"""
Build and configure an ElementsWorker using SQLite cache with fixed CLI parameters to avoid issues with pytest
"""
monkeypatch
.
setattr
(
sys
,
"
argv
"
,
[
"
worker
"
])
cache_path
=
tmp_path
/
"
db.sqlite
"
cache_path
.
touch
()
monkeypatch
.
setattr
(
sys
,
"
argv
"
,
[
"
worker
"
,
"
-d
"
,
str
(
cache_path
)])
monkeypatch
.
setenv
(
"
ARKINDEX_CORPUS_ID
"
,
"
11111111-1111-1111-1111-111111111111
"
)
worker
=
ElementsWorker
(
support_cache
=
True
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_base_worker.py
+
1
−
1
View file @
3b70083a
...
...
@@ -33,7 +33,7 @@ def test_init_with_local_cache(monkeypatch):
assert
worker
.
work_dir
==
os
.
path
.
expanduser
(
"
~/.local/share/arkindex
"
)
assert
worker
.
worker_version_id
==
"
12341234-1234-1234-1234-123412341234
"
assert
worker
.
use
_cache
is
True
assert
worker
.
support
_cache
is
True
def
test_init_var_ponos_data_given
(
monkeypatch
):
...
...
This diff is collapsed.
Click to expand it.
tests/test_elements_worker/test_elements.py
+
1
−
1
View file @
3b70083a
...
...
@@ -145,7 +145,7 @@ def test_database_arg(mocker, mock_elements_worker, tmp_path):
),
)
worker
=
ElementsWorker
()
worker
=
ElementsWorker
(
support_cache
=
True
)
worker
.
configure
()
assert
worker
.
use_cache
is
True
...
...
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