Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions contributing-docs/testing/unit_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@ For selected test types (example - the tests will run for Providers/API/CLI code

breeze testing providers-tests --skip-db-tests --parallel-test-types "Providers[google] Providers[amazon]"

You can also enter interactive shell with ``--skip-db-tests`` flag and run the tests iteratively

.. code-block:: bash

breeze shell --skip-db-tests
> pytest tests/your_test.py


How to make your test not depend on DB
......................................
Expand Down
8 changes: 8 additions & 0 deletions providers/tests/microsoft/azure/fs/test_adls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@

from __future__ import annotations

import os
from unittest import mock

import pytest

from airflow.models import Connection
from airflow.providers.microsoft.azure.fs.adls import get_fs

if os.environ.get("_AIRFLOW_SKIP_DB_TESTS") == "true":
# Handle collection of the test by non-db case
Connection = mock.MagicMock() # type: ignore[misc]


pytestmark = pytest.mark.db_test


@pytest.fixture
def mocked_blob_file_system():
Expand Down
5 changes: 5 additions & 0 deletions providers/tests/microsoft/azure/hooks/test_adx.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# under the License.
from __future__ import annotations

import os
from unittest import mock

import pytest
Expand All @@ -31,6 +32,10 @@

pytestmark = pytest.mark.db_test

if os.environ.get("_AIRFLOW_SKIP_DB_TESTS") == "true":
# Handle collection of the test by non-db case
Connection = mock.MagicMock() # type: ignore[misc]


class TestAzureDataExplorerHook:
@pytest.mark.parametrize(
Expand Down
7 changes: 6 additions & 1 deletion providers/tests/microsoft/azure/hooks/test_base_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
# under the License.
from __future__ import annotations

from unittest.mock import Mock, patch
import os
from unittest.mock import MagicMock, Mock, patch

import pytest

Expand All @@ -25,6 +26,10 @@

pytestmark = pytest.mark.db_test

if os.environ.get("_AIRFLOW_SKIP_DB_TESTS") == "true":
# Handle collection of the test by non-db case
Connection = MagicMock() # type: ignore[misc]

MODULE = "airflow.providers.microsoft.azure.hooks.base_azure"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@
# under the License.
from __future__ import annotations

import os
from unittest import mock

import pytest

from airflow.models import Connection
from airflow.providers.microsoft.azure.hooks.container_registry import AzureContainerRegistryHook

pytestmark = pytest.mark.db_test

if os.environ.get("_AIRFLOW_SKIP_DB_TESTS") == "true":
# Handle collection of the test by non-db case
Connection = mock.MagicMock() # type: ignore[misc]


class TestAzureContainerRegistryHook:
@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@
# under the License.
from __future__ import annotations

import os
from unittest import mock

import pytest

from airflow.models import Connection
from airflow.providers.microsoft.azure.hooks.container_volume import AzureContainerVolumeHook

pytestmark = pytest.mark.db_test

if os.environ.get("_AIRFLOW_SKIP_DB_TESTS") == "true":
# Handle collection of the test by non-db case
Connection = mock.MagicMock() # type: ignore[misc]


class TestAzureContainerVolumeHook:
@pytest.mark.parametrize(
Expand Down
7 changes: 7 additions & 0 deletions providers/tests/microsoft/azure/hooks/test_cosmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from __future__ import annotations

import logging
import os
import uuid
from unittest import mock
from unittest.mock import PropertyMock
Expand All @@ -30,8 +31,14 @@
from airflow.models import Connection
from airflow.providers.microsoft.azure.hooks.cosmos import AzureCosmosDBHook

pytestmark = pytest.mark.db_test

MODULE = "airflow.providers.microsoft.azure.hooks.cosmos"

if os.environ.get("_AIRFLOW_SKIP_DB_TESTS") == "true":
# Handle collection of the test by non-db case
Connection = mock.MagicMock() # type: ignore[misc]


class TestAzureCosmosDbHook:
# Set up an environment to test with
Expand Down
6 changes: 6 additions & 0 deletions providers/tests/microsoft/azure/hooks/test_data_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
# TODO: FIXME: the tests here have tricky issues with typing and need a bit more thought to fix them
# mypy: disable-error-code="union-attr,call-overload"

pytestmark = pytest.mark.db_test

if os.environ.get("_AIRFLOW_SKIP_DB_TESTS") == "true":
# Handle collection of the test by non-db case
Connection = mock.MagicMock() # type: ignore[misc]


@pytest.fixture(autouse=True)
def setup_connections(create_mock_connections):
Expand Down
4 changes: 4 additions & 0 deletions providers/tests/microsoft/azure/hooks/test_wasb.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# under the License.
from __future__ import annotations

import os
import re
from unittest import mock

Expand All @@ -31,6 +32,9 @@

pytestmark = pytest.mark.db_test

if os.environ.get("_AIRFLOW_SKIP_DB_TESTS") == "true":
# Handle collection of the test by non-db case
Connection = mock.MagicMock() # type: ignore[misc]

# connection_string has a format
CONN_STRING = (
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ testing = ["dev", "providers.tests", "task_sdk.tests", "tests_common", "tests"]

# Test compat imports banned imports to allow testing against older airflow versions
"tests_common/test_utils/compat.py" = ["TID251", "F401"]
"tests_common/pytest_plugin.py" = ["F811"]

[tool.ruff.lint.flake8-tidy-imports]
# Disallow all relative imports.
Expand Down