pytest-databases 0.4.0__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/PKG-INFO +3 -3
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/README.md +2 -2
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/pyproject.toml +1 -1
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/__init__.py +0 -22
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/alloydb_omni.py +46 -14
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/bigquery.py +52 -20
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/cockroachdb.py +44 -12
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/dragonfly.py +41 -10
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/elastic_search.py +62 -27
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/keydb.py +42 -10
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/mariadb.py +55 -22
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/mssql.py +57 -24
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/mysql.py +71 -36
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/oracle.py +65 -31
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/postgres.py +87 -50
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/redis.py +42 -10
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/spanner.py +48 -16
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/conftest.py +1 -1
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_alloydb_omni.py +2 -2
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_bigquery.py +4 -4
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_cockroachdb.py +4 -2
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_dragonfly.py +2 -2
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_elasticsearch.py +14 -14
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_keydb.py +2 -2
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_mariadb.py +4 -4
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_mssql.py +6 -6
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_mysql.py +8 -8
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_oracle.py +8 -4
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_postgres.py +12 -12
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_redis.py +2 -2
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/test_spanner.py +2 -2
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/.gitignore +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/.pre-commit-config.yaml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/.sourcery.yaml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/.vscode/launch.json +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/.vscode/settings.json +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/CODEOWNERS +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/CONTRIBUTING.rst +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/LICENSE +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/Makefile +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/requirements/requirements-dev.txt +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/requirements/requirements-docs.txt +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/requirements/requirements.txt +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/scripts/__init__.py +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/scripts/build_docs.py +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/scripts/convert_docs.sh +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/sonar-project.properties +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/__init__.py +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/__metadata__.py +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.alloydb-omni.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.bigquery.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.cockroachdb.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.dragonfly.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.elasticsearch.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.keydb.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.mariadb.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.mssql.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.mysql.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.oracle.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.postgres.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.redis.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/docker-compose.spanner.yml +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/helpers.py +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/py.typed +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/__init__.py +0 -0
- {pytest_databases-0.4.0 → pytest_databases-0.5.0}/tests/docker/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pytest-databases
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Reusable database fixtures for any and all databases.
|
|
5
5
|
Project-URL: Documentation, https://github.com/litestar-org/pytest-databases#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/litestar-org/pytest-databases/issues
|
|
@@ -59,9 +59,9 @@ Reusable test fixtures for any and all databases.
|
|
|
59
59
|
| Project | | Status |
|
|
60
60
|
|-----------|:----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
61
61
|
| CI/CD | | [](https://github.com/litestar-org/pytest-databases/actions/workflows/release.yaml) [](https://github.com/litestar-org/pytest-databases/actions/workflows/ci.yaml) [](https://github.com/litestar-org/pytest-databases/actions/workflows/docs.yaml) |
|
|
62
|
-
| Quality | | [](https://codecov.io/github/litestar-org/pytest-databases) [](https://codecov.io/github/litestar-org/pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) |
|
|
63
63
|
| Package | | [](https://badge.fury.io/py/pytest-databases)  |
|
|
64
|
-
| Community | | [](https://discord.gg/litestar-919193495116337154) [](https://matrix.to/#/#litestar:matrix.org) [](https://blog.litestar.dev) [](https://twitter.com/LitestarAPI) [](https://blog.litestar.dev) |
|
|
65
65
|
| Meta | | [](https://github.com/litestar-org/pytest-databases) [](https://github.com/python/mypy) [](https://spdx.org/licenses/) [](https://github.com/sponsors/litestar-org) [](https://github.com/astral-sh/ruff) [](https://github.com/psf/black)|
|
|
66
66
|
|
|
67
67
|
<!-- prettier-ignore-end -->
|
|
@@ -9,9 +9,9 @@ Reusable test fixtures for any and all databases.
|
|
|
9
9
|
| Project | | Status |
|
|
10
10
|
|-----------|:----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
11
11
|
| CI/CD | | [](https://github.com/litestar-org/pytest-databases/actions/workflows/release.yaml) [](https://github.com/litestar-org/pytest-databases/actions/workflows/ci.yaml) [](https://github.com/litestar-org/pytest-databases/actions/workflows/docs.yaml) |
|
|
12
|
-
| Quality | | [](https://codecov.io/github/litestar-org/pytest-databases) [](https://codecov.io/github/litestar-org/pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) [](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest-databases) |
|
|
13
13
|
| Package | | [](https://badge.fury.io/py/pytest-databases)  |
|
|
14
|
-
| Community | | [](https://discord.gg/litestar-919193495116337154) [](https://matrix.to/#/#litestar:matrix.org) [](https://blog.litestar.dev) [](https://twitter.com/LitestarAPI) [](https://blog.litestar.dev) |
|
|
15
15
|
| Meta | | [](https://github.com/litestar-org/pytest-databases) [](https://github.com/python/mypy) [](https://spdx.org/licenses/) [](https://github.com/sponsors/litestar-org) [](https://github.com/astral-sh/ruff) [](https://github.com/psf/black)|
|
|
16
16
|
|
|
17
17
|
<!-- prettier-ignore-end -->
|
|
@@ -130,25 +130,3 @@ class DockerServiceRegistry:
|
|
|
130
130
|
def down(self) -> None:
|
|
131
131
|
if not SKIP_DOCKER_COMPOSE:
|
|
132
132
|
self.run_command("down", "-t", "10")
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
@pytest.fixture(scope="session")
|
|
136
|
-
def compose_project_name() -> str:
|
|
137
|
-
return os.environ.get("COMPOSE_PROJECT_NAME", COMPOSE_PROJECT_NAME)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
@pytest.fixture(scope="session")
|
|
141
|
-
def docker_services(compose_project_name: str, worker_id: str = "main") -> Generator[DockerServiceRegistry, None, None]:
|
|
142
|
-
if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
|
|
143
|
-
pytest.skip("Docker not available on this platform")
|
|
144
|
-
|
|
145
|
-
registry = DockerServiceRegistry(worker_id, compose_project_name=compose_project_name)
|
|
146
|
-
try:
|
|
147
|
-
yield registry
|
|
148
|
-
finally:
|
|
149
|
-
registry.down()
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
@pytest.fixture(scope="session")
|
|
153
|
-
def docker_ip(docker_services: DockerServiceRegistry) -> str:
|
|
154
|
-
return docker_services.docker_ip
|
{pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/alloydb_omni.py
RENAMED
|
@@ -24,14 +24,21 @@
|
|
|
24
24
|
from __future__ import annotations
|
|
25
25
|
|
|
26
26
|
import os
|
|
27
|
+
import sys
|
|
27
28
|
from pathlib import Path
|
|
28
|
-
from typing import TYPE_CHECKING
|
|
29
|
+
from typing import TYPE_CHECKING, AsyncGenerator
|
|
29
30
|
|
|
30
31
|
import asyncpg
|
|
31
32
|
import pytest
|
|
32
33
|
|
|
34
|
+
from pytest_databases.docker import DockerServiceRegistry
|
|
35
|
+
from pytest_databases.helpers import simple_string_hash
|
|
36
|
+
|
|
33
37
|
if TYPE_CHECKING:
|
|
34
|
-
from
|
|
38
|
+
from collections.abc import Generator
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
COMPOSE_PROJECT_NAME: str = f"pytest-databases-alloydb-{simple_string_hash(__file__)}"
|
|
35
42
|
|
|
36
43
|
|
|
37
44
|
async def alloydb_omni_responsive(host: str, port: int, user: str, password: str, database: str) -> bool:
|
|
@@ -53,54 +60,78 @@ async def alloydb_omni_responsive(host: str, port: int, user: str, password: str
|
|
|
53
60
|
await conn.close()
|
|
54
61
|
|
|
55
62
|
|
|
56
|
-
@pytest.fixture()
|
|
63
|
+
@pytest.fixture(scope="session")
|
|
64
|
+
def alloydb_compose_project_name() -> str:
|
|
65
|
+
return os.environ.get("COMPOSE_PROJECT_NAME", COMPOSE_PROJECT_NAME)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@pytest.fixture(autouse=False, scope="session")
|
|
69
|
+
def alloydb_docker_services(
|
|
70
|
+
alloydb_compose_project_name: str, worker_id: str = "main"
|
|
71
|
+
) -> Generator[DockerServiceRegistry, None, None]:
|
|
72
|
+
if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
|
|
73
|
+
pytest.skip("Docker not available on this platform")
|
|
74
|
+
|
|
75
|
+
registry = DockerServiceRegistry(worker_id, compose_project_name=alloydb_compose_project_name)
|
|
76
|
+
try:
|
|
77
|
+
yield registry
|
|
78
|
+
finally:
|
|
79
|
+
registry.down()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@pytest.fixture(scope="session")
|
|
57
83
|
def postgres_user() -> str:
|
|
58
84
|
return "postgres"
|
|
59
85
|
|
|
60
86
|
|
|
61
|
-
@pytest.fixture()
|
|
87
|
+
@pytest.fixture(scope="session")
|
|
62
88
|
def postgres_password() -> str:
|
|
63
89
|
return "super-secret"
|
|
64
90
|
|
|
65
91
|
|
|
66
|
-
@pytest.fixture()
|
|
92
|
+
@pytest.fixture(scope="session")
|
|
67
93
|
def postgres_database() -> str:
|
|
68
94
|
return "postgres"
|
|
69
95
|
|
|
70
96
|
|
|
71
|
-
@pytest.fixture()
|
|
97
|
+
@pytest.fixture(scope="session")
|
|
72
98
|
def alloydb_omni_port() -> int:
|
|
73
99
|
return 5420
|
|
74
100
|
|
|
75
101
|
|
|
76
|
-
@pytest.fixture()
|
|
102
|
+
@pytest.fixture(scope="session")
|
|
77
103
|
def default_alloydb_omni_service_name() -> str:
|
|
78
104
|
return "alloydb"
|
|
79
105
|
|
|
80
106
|
|
|
81
107
|
@pytest.fixture(scope="session")
|
|
82
|
-
def
|
|
108
|
+
def alloydb_docker_compose_files() -> list[Path]:
|
|
83
109
|
return [Path(Path(__file__).parent / "docker-compose.alloydb-omni.yml")]
|
|
84
110
|
|
|
85
111
|
|
|
112
|
+
@pytest.fixture(scope="session")
|
|
113
|
+
def alloydb_docker_ip(alloydb_docker_services: DockerServiceRegistry) -> str:
|
|
114
|
+
return alloydb_docker_services.docker_ip
|
|
115
|
+
|
|
116
|
+
|
|
86
117
|
# alias to the latest
|
|
87
|
-
@pytest.fixture(autouse=False)
|
|
118
|
+
@pytest.fixture(autouse=False, scope="session")
|
|
88
119
|
async def alloydb_omni_service(
|
|
89
|
-
|
|
120
|
+
alloydb_docker_services: DockerServiceRegistry,
|
|
90
121
|
default_alloydb_omni_service_name: str,
|
|
91
|
-
|
|
122
|
+
alloydb_docker_compose_files: list[Path],
|
|
92
123
|
alloydb_omni_port: int,
|
|
93
124
|
postgres_database: str,
|
|
94
125
|
postgres_user: str,
|
|
95
126
|
postgres_password: str,
|
|
96
|
-
) -> None:
|
|
127
|
+
) -> AsyncGenerator[None, None]:
|
|
97
128
|
os.environ["POSTGRES_PASSWORD"] = postgres_password
|
|
98
129
|
os.environ["POSTGRES_USER"] = postgres_user
|
|
99
130
|
os.environ["POSTGRES_DATABASE"] = postgres_database
|
|
100
131
|
os.environ[f"{default_alloydb_omni_service_name.upper()}_PORT"] = str(alloydb_omni_port)
|
|
101
|
-
await
|
|
132
|
+
await alloydb_docker_services.start(
|
|
102
133
|
name=default_alloydb_omni_service_name,
|
|
103
|
-
docker_compose_files=
|
|
134
|
+
docker_compose_files=alloydb_docker_compose_files,
|
|
104
135
|
timeout=45,
|
|
105
136
|
pause=1,
|
|
106
137
|
check=alloydb_omni_responsive,
|
|
@@ -109,3 +140,4 @@ async def alloydb_omni_service(
|
|
|
109
140
|
user=postgres_user,
|
|
110
141
|
password=postgres_password,
|
|
111
142
|
)
|
|
143
|
+
yield
|
|
@@ -24,16 +24,23 @@
|
|
|
24
24
|
from __future__ import annotations
|
|
25
25
|
|
|
26
26
|
import os
|
|
27
|
+
import sys
|
|
27
28
|
from pathlib import Path
|
|
28
|
-
from typing import TYPE_CHECKING
|
|
29
|
+
from typing import TYPE_CHECKING, AsyncGenerator
|
|
29
30
|
|
|
30
31
|
import pytest
|
|
31
32
|
from google.api_core.client_options import ClientOptions
|
|
32
33
|
from google.auth.credentials import AnonymousCredentials, Credentials
|
|
33
34
|
from google.cloud import bigquery
|
|
34
35
|
|
|
36
|
+
from pytest_databases.docker import DockerServiceRegistry
|
|
37
|
+
from pytest_databases.helpers import simple_string_hash
|
|
38
|
+
|
|
35
39
|
if TYPE_CHECKING:
|
|
36
|
-
from
|
|
40
|
+
from collections.abc import Generator
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
COMPOSE_PROJECT_NAME: str = f"pytest-databases-bigquery-{simple_string_hash(__file__)}"
|
|
37
44
|
|
|
38
45
|
|
|
39
46
|
async def bigquery_responsive(
|
|
@@ -57,43 +64,57 @@ async def bigquery_responsive(
|
|
|
57
64
|
return False
|
|
58
65
|
|
|
59
66
|
|
|
60
|
-
@pytest.fixture
|
|
67
|
+
@pytest.fixture(scope="session")
|
|
68
|
+
def bigquery_compose_project_name() -> str:
|
|
69
|
+
return os.environ.get("COMPOSE_PROJECT_NAME", COMPOSE_PROJECT_NAME)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@pytest.fixture(autouse=False, scope="session")
|
|
73
|
+
def bigquery_docker_services(
|
|
74
|
+
bigquery_compose_project_name: str, worker_id: str = "main"
|
|
75
|
+
) -> Generator[DockerServiceRegistry, None, None]:
|
|
76
|
+
if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
|
|
77
|
+
pytest.skip("Docker not available on this platform")
|
|
78
|
+
|
|
79
|
+
registry = DockerServiceRegistry(worker_id, compose_project_name=bigquery_compose_project_name)
|
|
80
|
+
try:
|
|
81
|
+
yield registry
|
|
82
|
+
finally:
|
|
83
|
+
registry.down()
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@pytest.fixture(scope="session")
|
|
61
87
|
def bigquery_port() -> int:
|
|
62
88
|
return 9051
|
|
63
89
|
|
|
64
90
|
|
|
65
|
-
@pytest.fixture
|
|
91
|
+
@pytest.fixture(scope="session")
|
|
66
92
|
def bigquery_grpc_port() -> int:
|
|
67
93
|
return 9061
|
|
68
94
|
|
|
69
95
|
|
|
70
|
-
@pytest.fixture
|
|
71
|
-
def bigquery_endpoint(docker_ip: str, bigquery_port: int) -> str:
|
|
72
|
-
return f"http://{docker_ip}:{bigquery_port}"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
@pytest.fixture
|
|
96
|
+
@pytest.fixture(scope="session")
|
|
76
97
|
def bigquery_dataset() -> str:
|
|
77
98
|
return "test-dataset"
|
|
78
99
|
|
|
79
100
|
|
|
80
|
-
@pytest.fixture
|
|
101
|
+
@pytest.fixture(scope="session")
|
|
81
102
|
def bigquery_project() -> str:
|
|
82
103
|
return "emulator-test-project"
|
|
83
104
|
|
|
84
105
|
|
|
85
|
-
@pytest.fixture()
|
|
106
|
+
@pytest.fixture(scope="session")
|
|
86
107
|
def bigquery_client_options(bigquery_endpoint: str) -> ClientOptions:
|
|
87
108
|
return ClientOptions(api_endpoint=bigquery_endpoint)
|
|
88
109
|
|
|
89
110
|
|
|
90
|
-
@pytest.fixture
|
|
111
|
+
@pytest.fixture(scope="session")
|
|
91
112
|
def bigquery_credentials() -> Credentials:
|
|
92
113
|
return AnonymousCredentials()
|
|
93
114
|
|
|
94
115
|
|
|
95
116
|
@pytest.fixture(scope="session")
|
|
96
|
-
def
|
|
117
|
+
def bigquery_docker_compose_files() -> list[Path]:
|
|
97
118
|
return [Path(Path(__file__).parent / "docker-compose.bigquery.yml")]
|
|
98
119
|
|
|
99
120
|
|
|
@@ -102,11 +123,21 @@ def default_bigquery_service_name() -> str:
|
|
|
102
123
|
return "bigquery"
|
|
103
124
|
|
|
104
125
|
|
|
105
|
-
@pytest.fixture(
|
|
126
|
+
@pytest.fixture(scope="session")
|
|
127
|
+
def bigquery_docker_ip(bigquery_docker_services: DockerServiceRegistry) -> str:
|
|
128
|
+
return bigquery_docker_services.docker_ip
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@pytest.fixture(scope="session")
|
|
132
|
+
def bigquery_endpoint(bigquery_docker_ip: str, bigquery_port: int) -> str:
|
|
133
|
+
return f"http://{bigquery_docker_ip}:{bigquery_port}"
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@pytest.fixture(autouse=False, scope="session")
|
|
106
137
|
async def bigquery_service(
|
|
107
|
-
|
|
138
|
+
bigquery_docker_services: DockerServiceRegistry,
|
|
108
139
|
default_bigquery_service_name: str,
|
|
109
|
-
|
|
140
|
+
bigquery_docker_compose_files: list[Path],
|
|
110
141
|
bigquery_port: int,
|
|
111
142
|
bigquery_grpc_port: int,
|
|
112
143
|
bigquery_endpoint: str,
|
|
@@ -114,15 +145,15 @@ async def bigquery_service(
|
|
|
114
145
|
bigquery_project: str,
|
|
115
146
|
bigquery_credentials: Credentials,
|
|
116
147
|
bigquery_client_options: ClientOptions,
|
|
117
|
-
) -> None:
|
|
148
|
+
) -> AsyncGenerator[None, None]:
|
|
118
149
|
os.environ["BIGQUERY_ENDPOINT"] = bigquery_endpoint
|
|
119
150
|
os.environ["BIGQUERY_DATASET"] = bigquery_dataset
|
|
120
151
|
os.environ["BIGQUERY_PORT"] = str(bigquery_port)
|
|
121
152
|
os.environ["BIGQUERY_GRPC_PORT"] = str(bigquery_grpc_port)
|
|
122
153
|
os.environ["GOOGLE_CLOUD_PROJECT"] = bigquery_project
|
|
123
|
-
await
|
|
154
|
+
await bigquery_docker_services.start(
|
|
124
155
|
name=default_bigquery_service_name,
|
|
125
|
-
docker_compose_files=
|
|
156
|
+
docker_compose_files=bigquery_docker_compose_files,
|
|
126
157
|
timeout=60,
|
|
127
158
|
check=bigquery_responsive,
|
|
128
159
|
bigquery_endpoint=bigquery_endpoint,
|
|
@@ -131,3 +162,4 @@ async def bigquery_service(
|
|
|
131
162
|
bigquery_credentials=bigquery_credentials,
|
|
132
163
|
bigquery_client_options=bigquery_client_options,
|
|
133
164
|
)
|
|
165
|
+
yield
|
{pytest_databases-0.4.0 → pytest_databases-0.5.0}/src/pytest_databases/docker/cockroachdb.py
RENAMED
|
@@ -23,14 +23,21 @@
|
|
|
23
23
|
from __future__ import annotations
|
|
24
24
|
|
|
25
25
|
import os
|
|
26
|
+
import sys
|
|
26
27
|
from pathlib import Path
|
|
27
|
-
from typing import TYPE_CHECKING
|
|
28
|
+
from typing import TYPE_CHECKING, AsyncGenerator
|
|
28
29
|
|
|
29
30
|
import psycopg
|
|
30
31
|
import pytest
|
|
31
32
|
|
|
33
|
+
from pytest_databases.docker import DockerServiceRegistry
|
|
34
|
+
from pytest_databases.helpers import simple_string_hash
|
|
35
|
+
|
|
32
36
|
if TYPE_CHECKING:
|
|
33
|
-
from
|
|
37
|
+
from collections.abc import Generator
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
COMPOSE_PROJECT_NAME: str = f"pytest-databases-cockroachdb-{simple_string_hash(__file__)}"
|
|
34
41
|
|
|
35
42
|
|
|
36
43
|
async def cockroachdb_responsive(host: str, port: int, database: str, driver_opts: dict[str, str]) -> bool:
|
|
@@ -44,23 +51,42 @@ async def cockroachdb_responsive(host: str, port: int, database: str, driver_opt
|
|
|
44
51
|
return False
|
|
45
52
|
|
|
46
53
|
|
|
47
|
-
@pytest.fixture()
|
|
54
|
+
@pytest.fixture(scope="session")
|
|
55
|
+
def cockroachdb_compose_project_name() -> str:
|
|
56
|
+
return os.environ.get("COMPOSE_PROJECT_NAME", COMPOSE_PROJECT_NAME)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@pytest.fixture(autouse=False, scope="session")
|
|
60
|
+
def cockroachdb_docker_services(
|
|
61
|
+
cockroachdb_compose_project_name: str, worker_id: str = "main"
|
|
62
|
+
) -> Generator[DockerServiceRegistry, None, None]:
|
|
63
|
+
if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
|
|
64
|
+
pytest.skip("Docker not available on this platform")
|
|
65
|
+
|
|
66
|
+
registry = DockerServiceRegistry(worker_id, compose_project_name=cockroachdb_compose_project_name)
|
|
67
|
+
try:
|
|
68
|
+
yield registry
|
|
69
|
+
finally:
|
|
70
|
+
registry.down()
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@pytest.fixture(scope="session")
|
|
48
74
|
def cockroachdb_port() -> int:
|
|
49
75
|
return 26257
|
|
50
76
|
|
|
51
77
|
|
|
52
|
-
@pytest.fixture()
|
|
78
|
+
@pytest.fixture(scope="session")
|
|
53
79
|
def cockroachdb_database() -> str:
|
|
54
80
|
return "defaultdb"
|
|
55
81
|
|
|
56
82
|
|
|
57
|
-
@pytest.fixture()
|
|
83
|
+
@pytest.fixture(scope="session")
|
|
58
84
|
def cockroachdb_driver_opts() -> dict[str, str]:
|
|
59
85
|
return {"sslmode": "disable"}
|
|
60
86
|
|
|
61
87
|
|
|
62
88
|
@pytest.fixture(scope="session")
|
|
63
|
-
def
|
|
89
|
+
def cockroachdb_docker_compose_files() -> list[Path]:
|
|
64
90
|
return [Path(Path(__file__).parent / "docker-compose.cockroachdb.yml")]
|
|
65
91
|
|
|
66
92
|
|
|
@@ -69,20 +95,25 @@ def default_cockroachdb_service_name() -> str:
|
|
|
69
95
|
return "cockroachdb"
|
|
70
96
|
|
|
71
97
|
|
|
72
|
-
@pytest.fixture(
|
|
98
|
+
@pytest.fixture(scope="session")
|
|
99
|
+
def cockroachdb_docker_ip(cockroachdb_docker_services: DockerServiceRegistry) -> str:
|
|
100
|
+
return cockroachdb_docker_services.docker_ip
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@pytest.fixture(autouse=False, scope="session")
|
|
73
104
|
async def cockroachdb_service(
|
|
74
|
-
|
|
105
|
+
cockroachdb_docker_services: DockerServiceRegistry,
|
|
75
106
|
default_cockroachdb_service_name: str,
|
|
76
|
-
|
|
107
|
+
cockroachdb_docker_compose_files: list[Path],
|
|
77
108
|
cockroachdb_port: int,
|
|
78
109
|
cockroachdb_database: str,
|
|
79
110
|
cockroachdb_driver_opts: dict[str, str],
|
|
80
|
-
) -> None:
|
|
111
|
+
) -> AsyncGenerator[None, None]:
|
|
81
112
|
os.environ["COCKROACHDB_DATABASE"] = cockroachdb_database
|
|
82
113
|
os.environ["COCKROACHDB_PORT"] = str(cockroachdb_port)
|
|
83
|
-
await
|
|
114
|
+
await cockroachdb_docker_services.start(
|
|
84
115
|
name=default_cockroachdb_service_name,
|
|
85
|
-
docker_compose_files=
|
|
116
|
+
docker_compose_files=cockroachdb_docker_compose_files,
|
|
86
117
|
timeout=60,
|
|
87
118
|
pause=1,
|
|
88
119
|
check=cockroachdb_responsive,
|
|
@@ -90,3 +121,4 @@ async def cockroachdb_service(
|
|
|
90
121
|
database=cockroachdb_database,
|
|
91
122
|
driver_opts=cockroachdb_driver_opts,
|
|
92
123
|
)
|
|
124
|
+
yield
|
|
@@ -24,15 +24,21 @@
|
|
|
24
24
|
from __future__ import annotations
|
|
25
25
|
|
|
26
26
|
import os
|
|
27
|
+
import sys
|
|
27
28
|
from pathlib import Path
|
|
28
|
-
from typing import TYPE_CHECKING
|
|
29
|
+
from typing import TYPE_CHECKING, AsyncGenerator
|
|
29
30
|
|
|
30
31
|
import pytest
|
|
31
32
|
from redis.asyncio import Redis as AsyncRedis
|
|
32
33
|
from redis.exceptions import ConnectionError as RedisConnectionError
|
|
33
34
|
|
|
35
|
+
from pytest_databases.docker import DockerServiceRegistry
|
|
36
|
+
from pytest_databases.helpers import simple_string_hash
|
|
37
|
+
|
|
34
38
|
if TYPE_CHECKING:
|
|
35
|
-
from
|
|
39
|
+
from collections.abc import Generator
|
|
40
|
+
|
|
41
|
+
COMPOSE_PROJECT_NAME: str = f"pytest-databases-dragonfly-{simple_string_hash(__file__)}"
|
|
36
42
|
|
|
37
43
|
|
|
38
44
|
async def dragonfly_responsive(host: str, port: int) -> bool:
|
|
@@ -45,13 +51,32 @@ async def dragonfly_responsive(host: str, port: int) -> bool:
|
|
|
45
51
|
await client.aclose() # type: ignore[attr-defined]
|
|
46
52
|
|
|
47
53
|
|
|
48
|
-
@pytest.fixture()
|
|
54
|
+
@pytest.fixture(scope="session")
|
|
55
|
+
def dragonfly_compose_project_name() -> str:
|
|
56
|
+
return os.environ.get("COMPOSE_PROJECT_NAME", COMPOSE_PROJECT_NAME)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@pytest.fixture(autouse=False, scope="session")
|
|
60
|
+
def dragonfly_docker_services(
|
|
61
|
+
dragonfly_compose_project_name: str, worker_id: str = "main"
|
|
62
|
+
) -> Generator[DockerServiceRegistry, None, None]:
|
|
63
|
+
if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
|
|
64
|
+
pytest.skip("Docker not available on this platform")
|
|
65
|
+
|
|
66
|
+
registry = DockerServiceRegistry(worker_id, compose_project_name=dragonfly_compose_project_name)
|
|
67
|
+
try:
|
|
68
|
+
yield registry
|
|
69
|
+
finally:
|
|
70
|
+
registry.down()
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@pytest.fixture(scope="session")
|
|
49
74
|
def dragonfly_port() -> int:
|
|
50
75
|
return 6398
|
|
51
76
|
|
|
52
77
|
|
|
53
78
|
@pytest.fixture(scope="session")
|
|
54
|
-
def
|
|
79
|
+
def dragonfly_docker_compose_files() -> list[Path]:
|
|
55
80
|
return [Path(Path(__file__).parent / "docker-compose.dragonfly.yml")]
|
|
56
81
|
|
|
57
82
|
|
|
@@ -60,17 +85,23 @@ def default_dragonfly_service_name() -> str:
|
|
|
60
85
|
return "dragonfly"
|
|
61
86
|
|
|
62
87
|
|
|
63
|
-
@pytest.fixture(
|
|
88
|
+
@pytest.fixture(scope="session")
|
|
89
|
+
def dragonfly_docker_ip(dragonfly_docker_services: DockerServiceRegistry) -> str:
|
|
90
|
+
return dragonfly_docker_services.docker_ip
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@pytest.fixture(autouse=False, scope="session")
|
|
64
94
|
async def dragonfly_service(
|
|
65
|
-
|
|
95
|
+
dragonfly_docker_services: DockerServiceRegistry,
|
|
66
96
|
default_dragonfly_service_name: str,
|
|
67
|
-
|
|
97
|
+
dragonfly_docker_compose_files: list[Path],
|
|
68
98
|
dragonfly_port: int,
|
|
69
|
-
) -> None:
|
|
99
|
+
) -> AsyncGenerator[None, None]:
|
|
70
100
|
os.environ["DRAGONFLY_PORT"] = str(dragonfly_port)
|
|
71
|
-
await
|
|
101
|
+
await dragonfly_docker_services.start(
|
|
72
102
|
name=default_dragonfly_service_name,
|
|
73
|
-
docker_compose_files=
|
|
103
|
+
docker_compose_files=dragonfly_docker_compose_files,
|
|
74
104
|
check=dragonfly_responsive,
|
|
75
105
|
port=dragonfly_port,
|
|
76
106
|
)
|
|
107
|
+
yield
|