-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored fixture usage in unit tests
- Loading branch information
Showing
7 changed files
with
76 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
import pytest | ||
from pytest_lazyfixture import lazy_fixture | ||
|
||
from pytest_celery import CELERY_BACKEND | ||
from pytest_celery import CELERY_BACKEND_CLUSTER | ||
from pytest_celery import CeleryBackendCluster | ||
from pytest_celery import CeleryTestBackend | ||
|
||
|
||
@pytest.mark.parametrize("backend", [lazy_fixture(CELERY_BACKEND)]) | ||
class test_celey_test_backend: | ||
def test_default_config_format(self, celery_backend: CeleryTestBackend): | ||
def test_default_config_format(self, backend: CeleryTestBackend): | ||
expected_format = {"url", "local_url"} | ||
assert set(celery_backend.default_config().keys()) == expected_format | ||
assert set(backend.default_config().keys()) == expected_format | ||
|
||
|
||
@pytest.mark.parametrize("cluster", [lazy_fixture(CELERY_BACKEND_CLUSTER)]) | ||
class test_celery_backend_cluster: | ||
def test_default_config_format(self, celery_backend_cluster: CeleryBackendCluster): | ||
def test_default_config_format(self, cluster: CeleryBackendCluster): | ||
expected_format = {"urls", "local_urls"} | ||
assert set(celery_backend_cluster.default_config().keys()) == expected_format | ||
assert set(cluster.default_config().keys()) == expected_format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
import pytest | ||
from pytest_lazyfixture import lazy_fixture | ||
|
||
from pytest_celery import CELERY_BROKER | ||
from pytest_celery import CELERY_BROKER_CLUSTER | ||
from pytest_celery import CeleryBrokerCluster | ||
from pytest_celery import CeleryTestBroker | ||
|
||
|
||
@pytest.mark.parametrize("broker", [lazy_fixture(CELERY_BROKER)]) | ||
class test_celey_test_broker: | ||
def test_default_config_format(self, celery_broker: CeleryTestBroker): | ||
def test_default_config_format(self, broker: CeleryTestBroker): | ||
expected_format = {"url", "local_url"} | ||
assert set(celery_broker.default_config().keys()) == expected_format | ||
assert set(broker.default_config().keys()) == expected_format | ||
|
||
|
||
@pytest.mark.parametrize("cluster", [lazy_fixture(CELERY_BROKER_CLUSTER)]) | ||
class test_celery_broker_cluster: | ||
def test_default_config_format(self, celery_broker_cluster: CeleryBrokerCluster): | ||
def test_default_config_format(self, cluster: CeleryBrokerCluster): | ||
expected_format = {"urls", "local_urls"} | ||
assert set(celery_broker_cluster.default_config().keys()) == expected_format | ||
assert set(cluster.default_config().keys()) == expected_format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
import pytest | ||
from celery import Celery | ||
from pytest_lazyfixture import lazy_fixture | ||
|
||
from pytest_celery import CELERY_WORKER | ||
from pytest_celery import CELERY_WORKER_CLUSTER | ||
from pytest_celery import DEFAULT_WORKER_VERSION | ||
from pytest_celery import CeleryTestWorker | ||
from pytest_celery import CeleryWorkerCluster | ||
|
||
|
||
@pytest.mark.parametrize("worker", [lazy_fixture(CELERY_WORKER)]) | ||
class test_celey_test_worker: | ||
def test_ready(self, celery_worker: CeleryTestWorker): | ||
assert celery_worker.ready() | ||
celery_worker.container.ready.assert_called_once() | ||
def test_ready(self, worker: CeleryTestWorker): | ||
assert worker.ready() | ||
worker.container.ready.assert_called_once() | ||
|
||
|
||
@pytest.mark.parametrize("cluster", [lazy_fixture(CELERY_WORKER_CLUSTER)]) | ||
class test_celery_worker_cluster: | ||
def test_app(self, celery_worker_cluster: CeleryWorkerCluster, celery_setup_app: Celery): | ||
def test_app(self, cluster: CeleryWorkerCluster, celery_setup_app: Celery): | ||
node: CeleryTestWorker | ||
for node in celery_worker_cluster: | ||
for node in cluster: | ||
assert node.app is celery_setup_app | ||
|
||
def test_versions(self, celery_worker_cluster: CeleryWorkerCluster): | ||
assert celery_worker_cluster.versions == {DEFAULT_WORKER_VERSION} | ||
def test_versions(self, cluster: CeleryWorkerCluster): | ||
assert cluster.versions == {DEFAULT_WORKER_VERSION} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters