Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • workers/base-worker
1 result
Show changes
......@@ -66,7 +66,7 @@ def test_readonly(responses, mock_elements_worker):
"""Test readonly worker does not trigger any API calls"""
# Setup the worker as read-only
mock_elements_worker.worker_version_id = None
mock_elements_worker.worker_run_id = None
assert mock_elements_worker.is_read_only is True
out = mock_elements_worker.update_activity("1234-deadbeef", ActivityState.Processed)
......
This diff is collapsed.
......@@ -7,14 +7,14 @@ repos:
rev: 22.6.0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies:
- 'flake8-coding==1.3.1'
- 'flake8-copyright==0.2.2'
- 'flake8-debugger==3.1.0'
- flake8-coding==1.3.1
- flake8-copyright==0.2.3
- flake8-debugger==3.1.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
......@@ -40,6 +40,3 @@ repos:
- repo: meta
hooks:
- id: check-useless-excludes
default_language_version:
python: python3.9
# {{ cookiecutter.slug }}
{{ cookiecutter.description }}
### Development
For development and tests purpose it may be useful to install the worker as a editable package with pip.
```shell
pip3 install -e .
```
### Linter
Code syntax is analyzed before submitting the code.\
To run the linter tools suite you may use pre-commit.
```shell
pip install pre-commit
pre-commit run -a
```
### Run tests
Tests are executed with tox using [pytest](https://pytest.org).
```shell
pip install tox
tox
```
To recreate tox virtual environment (e.g. a dependencies update), you may run `tox -r`
arkindex-base-worker==0.2.4
arkindex-base-worker==0.3.1
......@@ -2,10 +2,13 @@
import os
import pytest
from arkindex_worker.worker.base import BaseWorker
from arkindex.mock import MockApiClient
@pytest.fixture(autouse=True)
def setup_environment(responses):
def setup_environment(responses, monkeypatch):
"""Setup needed environment variables"""
# Allow accessing remote API schemas
......@@ -18,7 +21,8 @@ def setup_environment(responses):
# Set schema url in environment
os.environ["ARKINDEX_API_SCHEMA_URL"] = schema_url
# Setup a fake worker version ID
os.environ["WORKER_VERSION_ID"] = "1234-{{ cookiecutter.slug }}"
# Setup a fake worker run ID
os.environ["ARKINDEX_WORKER_RUN_ID"] = "1234-{{ cookiecutter.slug }}"
# Setup a mock api client instead of using a real one
monkeypatch.setattr(BaseWorker, "setup_api_client", lambda _: MockApiClient())