pytest-databases 0.3.1__tar.gz → 0.4.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.
Files changed (66) hide show
  1. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/.pre-commit-config.yaml +1 -1
  2. pytest_databases-0.4.0/.vscode/launch.json +13 -0
  3. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/PKG-INFO +6 -3
  4. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/README.md +3 -2
  5. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/pyproject.toml +35 -15
  6. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/requirements/requirements-dev.txt +26 -15
  7. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/requirements/requirements-docs.txt +71 -21
  8. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/sonar-project.properties +5 -4
  9. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/__init__.py +2 -2
  10. pytest_databases-0.4.0/src/pytest_databases/docker/bigquery.py +133 -0
  11. pytest_databases-0.4.0/src/pytest_databases/docker/docker-compose.bigquery.yml +18 -0
  12. pytest_databases-0.4.0/tests/docker/test_bigquery.py +75 -0
  13. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/.gitignore +0 -0
  14. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/.sourcery.yaml +0 -0
  15. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/.vscode/settings.json +0 -0
  16. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/CODEOWNERS +0 -0
  17. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/CONTRIBUTING.rst +0 -0
  18. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/LICENSE +0 -0
  19. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/Makefile +0 -0
  20. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/requirements/requirements.txt +0 -0
  21. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/scripts/__init__.py +0 -0
  22. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/scripts/build_docs.py +0 -0
  23. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/scripts/convert_docs.sh +0 -0
  24. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/__init__.py +0 -0
  25. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/__metadata__.py +0 -0
  26. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/alloydb_omni.py +0 -0
  27. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/cockroachdb.py +0 -0
  28. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/docker-compose.alloydb-omni.yml +0 -0
  29. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/docker-compose.cockroachdb.yml +0 -0
  30. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/docker-compose.dragonfly.yml +0 -0
  31. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/docker-compose.elasticsearch.yml +0 -0
  32. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/docker-compose.keydb.yml +0 -0
  33. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/docker-compose.mariadb.yml +0 -0
  34. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/docker-compose.mssql.yml +0 -0
  35. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/docker-compose.mysql.yml +0 -0
  36. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/docker-compose.oracle.yml +0 -0
  37. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/docker-compose.postgres.yml +0 -0
  38. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/docker-compose.redis.yml +0 -0
  39. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/docker-compose.spanner.yml +0 -0
  40. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/dragonfly.py +0 -0
  41. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/elastic_search.py +0 -0
  42. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/keydb.py +0 -0
  43. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/mariadb.py +0 -0
  44. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/mssql.py +0 -0
  45. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/mysql.py +0 -0
  46. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/oracle.py +0 -0
  47. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/postgres.py +0 -0
  48. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/redis.py +0 -0
  49. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/docker/spanner.py +0 -0
  50. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/helpers.py +0 -0
  51. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/src/pytest_databases/py.typed +0 -0
  52. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/__init__.py +0 -0
  53. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/conftest.py +0 -0
  54. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/__init__.py +0 -0
  55. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/test_alloydb_omni.py +0 -0
  56. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/test_cockroachdb.py +0 -0
  57. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/test_dragonfly.py +0 -0
  58. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/test_elasticsearch.py +0 -0
  59. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/test_keydb.py +0 -0
  60. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/test_mariadb.py +0 -0
  61. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/test_mssql.py +0 -0
  62. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/test_mysql.py +0 -0
  63. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/test_oracle.py +0 -0
  64. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/test_postgres.py +0 -0
  65. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/test_redis.py +0 -0
  66. {pytest_databases-0.3.1 → pytest_databases-0.4.0}/tests/docker/test_spanner.py +0 -0
@@ -19,7 +19,7 @@ repos:
19
19
 
20
20
  # Ruff replaces black, flake8, autoflake and isort
21
21
  - repo: https://github.com/charliermarsh/ruff-pre-commit
22
- rev: "v0.3.7" # make sure this is always consistent with hatch configs
22
+ rev: "v0.4.0" # make sure this is always consistent with hatch configs
23
23
  hooks:
24
24
  - id: ruff
25
25
  args: [--config, ./pyproject.toml]
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Python Debugger: Current File",
6
+ "type": "debugpy",
7
+ "request": "launch",
8
+ "program": "${file}",
9
+ "console": "integratedTerminal",
10
+ "justMyCode": false
11
+ }
12
+ ]
13
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytest-databases
3
- Version: 0.3.1
3
+ Version: 0.4.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
@@ -20,6 +20,8 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
20
20
  Classifier: Programming Language :: Python :: Implementation :: PyPy
21
21
  Requires-Python: >=3.8
22
22
  Requires-Dist: pytest
23
+ Provides-Extra: bigquery
24
+ Requires-Dist: google-cloud-bigquery; extra == 'bigquery'
23
25
  Provides-Extra: cockroachdb
24
26
  Requires-Dist: psycopg; extra == 'cockroachdb'
25
27
  Provides-Extra: dragonfly
@@ -46,7 +48,7 @@ Provides-Extra: sqlite
46
48
  Requires-Dist: aiosqlite; extra == 'sqlite'
47
49
  Description-Content-Type: text/markdown
48
50
 
49
- # pytest-databases
51
+ # Pytest Databases
50
52
 
51
53
  Reusable test fixtures for any and all databases.
52
54
 
@@ -56,7 +58,7 @@ Reusable test fixtures for any and all databases.
56
58
 
57
59
  | Project | | Status |
58
60
  |-----------|:----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
59
- | CI/CD | | [![Latest Release](https://github.com/litestar-org/pytest-databases/actions/workflows/release.yml/badge.svg)](https://github.com/litestar-org/pytest-databases/actions/workflows/release.yml) [![ci](https://github.com/litestar-org/pytest-databases/actions/workflows/ci.yml/badge.svg)](https://github.com/litestar-org/pytest-databases/actions/workflows/ci.yml) [![Documentation Building](https://github.com/litestar-org/pytest-databases/actions/workflows/docs.yml/badge.svg?branch=main)](https://github.com/litestar-org/pytest-databases/actions/workflows/docs.yml) |
61
+ | CI/CD | | [![Latest Release](https://github.com/litestar-org/pytest-databases/actions/workflows/release.yaml/badge.svg)](https://github.com/litestar-org/pytest-databases/actions/workflows/release.yaml) [![ci](https://github.com/litestar-org/pytest-databases/actions/workflows/ci.yaml/badge.svg)](https://github.com/litestar-org/pytest-databases/actions/workflows/ci.yaml) [![Documentation Building](https://github.com/litestar-org/pytest-databases/actions/workflows/docs.yaml/badge.svg?branch=main)](https://github.com/litestar-org/pytest-databases/actions/workflows/docs.yaml) |
60
62
  | Quality | | [![Coverage](https://codecov.io/github/litestar-org/pytest-databases/graph/badge.svg?token=vKez4Pycrc)](https://codecov.io/github/litestar-org/pytest-databases) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_pytest_databases&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest_databases) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_pytest_databases&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest_databases) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_pytest_databases&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest_databases) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_pytest_databases&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest_databases) |
61
63
  | Package | | [![PyPI - Version](https://img.shields.io/pypi/v/pytest-databases?labelColor=202235&color=edb641&logo=python&logoColor=edb641)](https://badge.fury.io/py/pytest-databases) ![PyPI - Support Python Versions](https://img.shields.io/pypi/pyversions/pytest-databases?labelColor=202235&color=edb641&logo=python&logoColor=edb641) |
62
64
  | Community | | [![Reddit](https://img.shields.io/reddit/subreddit-subscribers/litestarapi?label=r%2FLitestar&logo=reddit&labelColor=202235&color=edb641&logoColor=edb641)](https://reddit.com/r/litestarapi) [![Discord](https://img.shields.io/discord/919193495116337154?labelColor=202235&color=edb641&label=chat%20on%20discord&logo=discord&logoColor=edb641)](https://discord.gg/litestar-919193495116337154) [![Matrix](https://img.shields.io/badge/chat%20on%20Matrix-bridged-202235?labelColor=202235&color=edb641&logo=matrix&logoColor=edb641)](https://matrix.to/#/#litestar:matrix.org) [![Medium](https://img.shields.io/badge/Medium-202235?labelColor=202235&color=edb641&logo=medium&logoColor=edb641)](https://blog.litestar.dev) [![Twitter](https://img.shields.io/twitter/follow/LitestarAPI?labelColor=202235&color=edb641&logo=twitter&logoColor=edb641&style=flat)](https://twitter.com/LitestarAPI) [![Blog](https://img.shields.io/badge/Blog-litestar.dev-202235?logo=blogger&labelColor=202235&color=edb641&logoColor=edb641)](https://blog.litestar.dev) |
@@ -86,6 +88,7 @@ It is designed to offer pre-configured testing setups for many different types a
86
88
  - **SQL Server**: Version 2022 is available
87
89
  - **Google AlloyDB Omni**: Simplified Omni installation for easy testing.
88
90
  - **Google Spanner**: The latest cloud-emulator from Google is available
91
+ - **Google BigQuery**: Unofficial BigQuery emulator
89
92
  - **Cockroach**: Version 23.1-latest is available
90
93
  - **Redis**: Latest server
91
94
  - **Dragonfly**: Latest server
@@ -1,4 +1,4 @@
1
- # pytest-databases
1
+ # Pytest Databases
2
2
 
3
3
  Reusable test fixtures for any and all databases.
4
4
 
@@ -8,7 +8,7 @@ Reusable test fixtures for any and all databases.
8
8
 
9
9
  | Project | | Status |
10
10
  |-----------|:----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
11
- | CI/CD | | [![Latest Release](https://github.com/litestar-org/pytest-databases/actions/workflows/release.yml/badge.svg)](https://github.com/litestar-org/pytest-databases/actions/workflows/release.yml) [![ci](https://github.com/litestar-org/pytest-databases/actions/workflows/ci.yml/badge.svg)](https://github.com/litestar-org/pytest-databases/actions/workflows/ci.yml) [![Documentation Building](https://github.com/litestar-org/pytest-databases/actions/workflows/docs.yml/badge.svg?branch=main)](https://github.com/litestar-org/pytest-databases/actions/workflows/docs.yml) |
11
+ | CI/CD | | [![Latest Release](https://github.com/litestar-org/pytest-databases/actions/workflows/release.yaml/badge.svg)](https://github.com/litestar-org/pytest-databases/actions/workflows/release.yaml) [![ci](https://github.com/litestar-org/pytest-databases/actions/workflows/ci.yaml/badge.svg)](https://github.com/litestar-org/pytest-databases/actions/workflows/ci.yaml) [![Documentation Building](https://github.com/litestar-org/pytest-databases/actions/workflows/docs.yaml/badge.svg?branch=main)](https://github.com/litestar-org/pytest-databases/actions/workflows/docs.yaml) |
12
12
  | Quality | | [![Coverage](https://codecov.io/github/litestar-org/pytest-databases/graph/badge.svg?token=vKez4Pycrc)](https://codecov.io/github/litestar-org/pytest-databases) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_pytest_databases&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest_databases) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_pytest_databases&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest_databases) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_pytest_databases&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest_databases) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_pytest_databases&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_pytest_databases) |
13
13
  | Package | | [![PyPI - Version](https://img.shields.io/pypi/v/pytest-databases?labelColor=202235&color=edb641&logo=python&logoColor=edb641)](https://badge.fury.io/py/pytest-databases) ![PyPI - Support Python Versions](https://img.shields.io/pypi/pyversions/pytest-databases?labelColor=202235&color=edb641&logo=python&logoColor=edb641) |
14
14
  | Community | | [![Reddit](https://img.shields.io/reddit/subreddit-subscribers/litestarapi?label=r%2FLitestar&logo=reddit&labelColor=202235&color=edb641&logoColor=edb641)](https://reddit.com/r/litestarapi) [![Discord](https://img.shields.io/discord/919193495116337154?labelColor=202235&color=edb641&label=chat%20on%20discord&logo=discord&logoColor=edb641)](https://discord.gg/litestar-919193495116337154) [![Matrix](https://img.shields.io/badge/chat%20on%20Matrix-bridged-202235?labelColor=202235&color=edb641&logo=matrix&logoColor=edb641)](https://matrix.to/#/#litestar:matrix.org) [![Medium](https://img.shields.io/badge/Medium-202235?labelColor=202235&color=edb641&logo=medium&logoColor=edb641)](https://blog.litestar.dev) [![Twitter](https://img.shields.io/twitter/follow/LitestarAPI?labelColor=202235&color=edb641&logo=twitter&logoColor=edb641&style=flat)](https://twitter.com/LitestarAPI) [![Blog](https://img.shields.io/badge/Blog-litestar.dev-202235?logo=blogger&labelColor=202235&color=edb641&logoColor=edb641)](https://blog.litestar.dev) |
@@ -38,6 +38,7 @@ It is designed to offer pre-configured testing setups for many different types a
38
38
  - **SQL Server**: Version 2022 is available
39
39
  - **Google AlloyDB Omni**: Simplified Omni installation for easy testing.
40
40
  - **Google Spanner**: The latest cloud-emulator from Google is available
41
+ - **Google BigQuery**: Unofficial BigQuery emulator
41
42
  - **Cockroach**: Version 23.1-latest is available
42
43
  - **Redis**: Latest server
43
44
  - **Dragonfly**: Latest server
@@ -12,7 +12,7 @@ license = "MIT"
12
12
  name = "pytest-databases"
13
13
  readme = "README.md"
14
14
  requires-python = ">=3.8"
15
- version = "0.3.1"
15
+ version = "0.4.0"
16
16
  #
17
17
  authors = [{ name = "Cody Fincher", email = "cody.fincher@gmail.com" }]
18
18
  keywords = [
@@ -52,6 +52,7 @@ Issues = "https://github.com/litestar-org/pytest-databases/issues"
52
52
  Source = "https://github.com/litestar-org/pytest-databases"
53
53
 
54
54
  [project.optional-dependencies]
55
+ bigquery = ["google-cloud-bigquery"]
55
56
  cockroachdb = ["psycopg"]
56
57
  dragonfly = ["redis"]
57
58
  elasticsearch7 = ["elasticsearch7[async]"]
@@ -117,12 +118,13 @@ features = [
117
118
  "redis",
118
119
  "elasticsearch7",
119
120
  "elasticsearch8",
121
+ "bigquery",
120
122
  ]
121
123
  template = "default"
122
124
  type = "virtual"
123
125
 
124
126
  [tool.hatch.envs.test.env-vars]
125
- PYTHONPATH = "."
127
+ PYTHONPATH = ".:src/"
126
128
  PYTHONUNBUFFERED = "1"
127
129
  SOURCE_DATE_EPOCH = "1580601600"
128
130
 
@@ -131,7 +133,7 @@ SOURCE_DATE_EPOCH = "1580601600"
131
133
  python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
132
134
 
133
135
  [tool.hatch.envs.test.scripts]
134
- cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov-report=xml"
136
+ cov = "pytest --cov=pytest_databases --cov-report=xml"
135
137
  debug = "cov --no-cov -s --pdb --pdbcls=IPython.core.debugger:Pdb"
136
138
  no-cov = "cov --no-cov"
137
139
 
@@ -174,6 +176,7 @@ features = [
174
176
  "redis",
175
177
  "elasticsearch7",
176
178
  "elasticsearch8",
179
+ "bigquery",
177
180
  ]
178
181
  lock-filename = "requirements/requirements-docs.txt"
179
182
  pip-compile-constraint = "default"
@@ -245,6 +248,7 @@ features = [
245
248
  "redis",
246
249
  "elasticsearch7",
247
250
  "elasticsearch8",
251
+ "bigquery",
248
252
  ]
249
253
  lock-filename = "requirements/requirements-dev.txt"
250
254
  path = ".venv/"
@@ -283,6 +287,7 @@ features = [
283
287
  "redis",
284
288
  "elasticsearch7",
285
289
  "elasticsearch8",
290
+ "bigquery",
286
291
  ]
287
292
  python = "3.11"
288
293
  template = "docs"
@@ -392,8 +397,17 @@ warn_no_return = false
392
397
  warn_unused_ignores = true
393
398
 
394
399
  [[tool.mypy.overrides]]
400
+ disable_error_code = "attr-defined"
401
+ module = "pytest_databases.docker.spanner"
402
+
403
+ [[tool.mypy.overrides]]
404
+ disable_error_code = "attr-defined"
405
+ module = "pytest_databases.docker.bigquery"
406
+
407
+ [[tool.mypy.overrides]]
408
+ disable_error_code = "attr-defined"
395
409
  disallow_untyped_decorators = false
396
- module = ["tests.*"]
410
+ module = "tests.*"
397
411
  warn_unused_ignores = false
398
412
 
399
413
  [[tool.mypy.overrides]]
@@ -403,6 +417,18 @@ disallow_untyped_decorators = false
403
417
  module = ["docutils.nodes.*"]
404
418
 
405
419
 
420
+ [[tool.mypy.overrides]]
421
+ ignore_missing_imports = true
422
+ module = [
423
+ "asyncmy",
424
+ "pyodbc",
425
+ "google.auth.*",
426
+ "google.cloud.*",
427
+ "google.protobuf.*",
428
+ "googleapiclient",
429
+ "googleapiclient.*",
430
+ ]
431
+
406
432
  [tool.ruff]
407
433
  exclude = [
408
434
  ".bzr",
@@ -474,12 +500,13 @@ lint.ignore = [
474
500
  "FBT002", # Boolean default positional argument in function definition
475
501
  "FBT003", # Boolean Boolean default positional argument in function definition
476
502
  "ARG002", # Unused method argument
477
- "ARG001", # Unused function argument
503
+ "ARG001", # Unused function argument
478
504
  "TD002",
479
505
  "TD003",
480
506
  "FIX002",
481
507
  "PGH003",
482
508
  "RUF006",
509
+ "RUF029", # Ruff - Function is declared `async`, but doesn't `await` or use `async` features. # ignore
483
510
  "SLF001",
484
511
  "PT007",
485
512
  'PT004',
@@ -568,7 +595,7 @@ line-length = 120
568
595
  ## Testing Tools
569
596
 
570
597
  [tool.pytest.ini_options]
571
- addopts = "-ra -q --doctest-glob='*.md'"
598
+ addopts = "--dist loadfile -n 2 -ra -q --doctest-glob='*.md'"
572
599
  filterwarnings = ["ignore::DeprecationWarning:pkg_resources", "ignore::DeprecationWarning:xdist.*"]
573
600
  markers = [
574
601
  "mysql: MySQL Tests",
@@ -579,13 +606,12 @@ markers = [
579
606
  "mssql: Microsoft SQL Server Tests",
580
607
  "elasticsearch: Elasticsearch Tests",
581
608
  ]
582
- minversion = "6.0"
583
609
  testpaths = ["tests"]
584
610
 
585
611
  [tool.coverage.run]
586
612
  branch = true
587
- concurrency = ["multiprocessing", "thread"]
588
- disable_warnings = ["no-data-collected", "module-not-measured"]
613
+ concurrency = ["multiprocessing"]
614
+ disable_warnings = ["no-data-collected", "module-not-measured", "module-not-imported"]
589
615
  omit = [
590
616
  "_version.py", # automatically created by hatch-vcs, not in repo
591
617
  "src/pytest_databases/__metadata__.py",
@@ -593,12 +619,6 @@ omit = [
593
619
  "scripts/*",
594
620
  ]
595
621
  parallel = true
596
- source = ["src/pytest_databases"]
597
- source_pkgs = ["pytest_databases"]
598
-
599
- [tool.coverage.paths]
600
- pytest_databases = ["src/pytest_databases"]
601
- tests = ["tests"]
602
622
 
603
623
  [tool.coverage.report]
604
624
  # Regexes for lines to exclude from consideration
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # This file is autogenerated by hatch-pip-compile with Python 3.11
3
3
  #
4
- # [constraints] requirements/requirements-docs.txt (SHA256: bc66ec3f548a65764214d7adf74c74992465c90498f84a07b19b829ae70e0bfb)
4
+ # [constraints] requirements/requirements-docs.txt (SHA256: a093b9560889a29cbc3c8aa0b34a88712507f753d6e17b1f14300bb5327d479e)
5
5
  #
6
6
  # - nodeenv
7
7
  # - cython
@@ -38,6 +38,7 @@
38
38
  # - types-docutils
39
39
  # - types-redis
40
40
  # - pytest
41
+ # - google-cloud-bigquery
41
42
  # - psycopg
42
43
  # - elasticsearch7[async]
43
44
  # - elasticsearch8[async]
@@ -124,8 +125,6 @@ cryptography==42.0.5
124
125
  cssutils==2.10.2
125
126
  # via dict2css
126
127
  cython==3.0.10
127
- deprecated==1.2.14
128
- # via google-cloud-spanner
129
128
  dict2css==0.3.0.post1
130
129
  # via sphinx-toolbox
131
130
  dill==0.3.8
@@ -150,7 +149,7 @@ duckdb==0.10.2
150
149
  # via harlequin
151
150
  elastic-transport==8.13.0
152
151
  # via elasticsearch8
153
- elasticsearch7==7.9.1
152
+ elasticsearch7==7.17.9
154
153
  elasticsearch8==8.13.0
155
154
  execnet==2.1.1
156
155
  # via pytest-xdist
@@ -165,15 +164,24 @@ frozenlist==1.4.1
165
164
  # aiosignal
166
165
  google-api-core==2.18.0
167
166
  # via
167
+ # google-cloud-bigquery
168
168
  # google-cloud-core
169
169
  # google-cloud-spanner
170
170
  google-auth==2.29.0
171
171
  # via
172
172
  # google-api-core
173
+ # google-cloud-bigquery
173
174
  # google-cloud-core
175
+ google-cloud-bigquery==3.21.0
174
176
  google-cloud-core==2.4.1
175
- # via google-cloud-spanner
176
- google-cloud-spanner==3.44.0
177
+ # via
178
+ # google-cloud-bigquery
179
+ # google-cloud-spanner
180
+ google-cloud-spanner==3.45.0
181
+ google-crc32c==1.5.0
182
+ # via google-resumable-media
183
+ google-resumable-media==2.7.0
184
+ # via google-cloud-bigquery
177
185
  googleapis-common-protos==1.63.0
178
186
  # via
179
187
  # google-api-core
@@ -183,14 +191,14 @@ grpc-google-iam-v1==0.13.0
183
191
  # via google-cloud-spanner
184
192
  grpc-interceptor==0.15.4
185
193
  # via google-cloud-spanner
186
- grpcio==1.62.1
194
+ grpcio==1.62.2
187
195
  # via
188
196
  # google-api-core
189
197
  # googleapis-common-protos
190
198
  # grpc-google-iam-v1
191
199
  # grpc-interceptor
192
200
  # grpcio-status
193
- grpcio-status==1.62.1
201
+ grpcio-status==1.62.2
194
202
  # via google-api-core
195
203
  h11==0.14.0
196
204
  # via uvicorn
@@ -254,6 +262,7 @@ numpy==1.26.4
254
262
  oracledb==2.1.2
255
263
  packaging==24.0
256
264
  # via
265
+ # google-cloud-bigquery
257
266
  # pydata-sphinx-theme
258
267
  # pytest
259
268
  # pytest-sugar
@@ -322,6 +331,8 @@ pytest-mock==3.14.0
322
331
  pytest-sugar==1.0.0
323
332
  pytest-vcr==1.0.2
324
333
  pytest-xdist==3.5.0
334
+ python-dateutil==2.9.0.post0
335
+ # via google-cloud-bigquery
325
336
  pyyaml==6.0.1
326
337
  # via
327
338
  # pre-commit
@@ -334,6 +345,7 @@ requests==2.31.0
334
345
  # apeye
335
346
  # cachecontrol
336
347
  # google-api-core
348
+ # google-cloud-bigquery
337
349
  # sphinx
338
350
  rich==13.7.1
339
351
  # via
@@ -347,14 +359,16 @@ ruamel-yaml==0.18.6
347
359
  # via sphinx-toolbox
348
360
  ruamel-yaml-clib==0.2.8
349
361
  # via ruamel-yaml
350
- ruff==0.3.7
362
+ ruff==0.4.0
351
363
  # via auto-pytabs
352
364
  setuptools==69.5.1
353
365
  # via nodeenv
354
366
  shandy-sqlfmt==0.21.2
355
367
  # via harlequin
356
368
  six==1.16.0
357
- # via html5lib
369
+ # via
370
+ # html5lib
371
+ # python-dateutil
358
372
  sniffio==1.3.1
359
373
  # via anyio
360
374
  snowballstemmer==2.2.0
@@ -456,7 +470,7 @@ typing-extensions==4.11.0
456
470
  # textual
457
471
  uc-micro-py==1.0.3
458
472
  # via linkify-it-py
459
- urllib3==2.2.1
473
+ urllib3==1.26.18
460
474
  # via
461
475
  # elastic-transport
462
476
  # elasticsearch7
@@ -476,11 +490,8 @@ webencodings==0.5.1
476
490
  websockets==12.0
477
491
  # via sphinx-autobuild
478
492
  wrapt==1.16.0
479
- # via
480
- # deprecated
481
- # vcrpy
493
+ # via vcrpy
482
494
  yarl==1.9.4
483
495
  # via
484
496
  # aiohttp
485
- # elasticsearch7
486
497
  # vcrpy
@@ -24,6 +24,7 @@
24
24
  # - sphinxcontrib-mermaid>=0.9.2
25
25
  # - auto-pytabs[sphinx]>=0.4.0
26
26
  # - pytest
27
+ # - google-cloud-bigquery
27
28
  # - psycopg
28
29
  # - elasticsearch7[async]
29
30
  # - elasticsearch8[async]
@@ -42,12 +43,14 @@ aiohttp==3.9.5
42
43
  # elasticsearch7
43
44
  # elasticsearch8
44
45
  aioodbc==0.5.0
46
+ # via hatch.envs.docs
45
47
  aiosignal==1.3.1
46
48
  # via aiohttp
47
49
  alabaster==0.7.16
48
50
  # via sphinx
49
51
  anyio==4.3.0
50
52
  # via
53
+ # hatch.envs.docs
51
54
  # starlette
52
55
  # watchfiles
53
56
  apeye==1.4.1
@@ -57,10 +60,13 @@ apeye-core==1.1.5
57
60
  async-timeout==4.0.3
58
61
  # via asyncpg
59
62
  asyncmy==0.2.9
63
+ # via hatch.envs.docs
60
64
  asyncpg==0.29.0
65
+ # via hatch.envs.docs
61
66
  attrs==23.2.0
62
67
  # via aiohttp
63
68
  auto-pytabs==0.4.0
69
+ # via hatch.envs.docs
64
70
  autodocsumm==0.2.12
65
71
  # via sphinx-toolbox
66
72
  babel==2.14.0
@@ -92,14 +98,15 @@ click==8.1.7
92
98
  colorama==0.4.6
93
99
  # via sphinx-autobuild
94
100
  coverage==7.4.4
95
- # via pytest-cov
101
+ # via
102
+ # hatch.envs.docs
103
+ # pytest-cov
96
104
  cryptography==42.0.5
97
105
  # via oracledb
98
106
  cssutils==2.10.2
99
107
  # via dict2css
100
108
  cython==3.0.10
101
- deprecated==1.2.14
102
- # via google-cloud-spanner
109
+ # via hatch.envs.docs
103
110
  dict2css==0.3.0.post1
104
111
  # via sphinx-toolbox
105
112
  docutils==0.21.1
@@ -118,8 +125,10 @@ domdf-python-tools==3.8.0.post2
118
125
  # sphinx-toolbox
119
126
  elastic-transport==8.13.0
120
127
  # via elasticsearch8
121
- elasticsearch7==7.9.1
128
+ elasticsearch7==7.17.9
129
+ # via hatch.envs.docs
122
130
  elasticsearch8==8.13.0
131
+ # via hatch.envs.docs
123
132
  execnet==2.1.1
124
133
  # via pytest-xdist
125
134
  filelock==3.13.4
@@ -132,15 +141,26 @@ frozenlist==1.4.1
132
141
  # aiosignal
133
142
  google-api-core==2.18.0
134
143
  # via
144
+ # google-cloud-bigquery
135
145
  # google-cloud-core
136
146
  # google-cloud-spanner
137
147
  google-auth==2.29.0
138
148
  # via
139
149
  # google-api-core
150
+ # google-cloud-bigquery
140
151
  # google-cloud-core
152
+ google-cloud-bigquery==3.21.0
153
+ # via hatch.envs.docs
141
154
  google-cloud-core==2.4.1
142
- # via google-cloud-spanner
143
- google-cloud-spanner==3.44.0
155
+ # via
156
+ # google-cloud-bigquery
157
+ # google-cloud-spanner
158
+ google-cloud-spanner==3.45.0
159
+ # via hatch.envs.docs
160
+ google-crc32c==1.5.0
161
+ # via google-resumable-media
162
+ google-resumable-media==2.7.0
163
+ # via google-cloud-bigquery
144
164
  googleapis-common-protos==1.63.0
145
165
  # via
146
166
  # google-api-core
@@ -150,14 +170,14 @@ grpc-google-iam-v1==0.13.0
150
170
  # via google-cloud-spanner
151
171
  grpc-interceptor==0.15.4
152
172
  # via google-cloud-spanner
153
- grpcio==1.62.1
173
+ grpcio==1.62.2
154
174
  # via
155
175
  # google-api-core
156
176
  # googleapis-common-protos
157
177
  # grpc-google-iam-v1
158
178
  # grpc-interceptor
159
179
  # grpcio-status
160
- grpcio-status==1.62.1
180
+ grpcio-status==1.62.2
161
181
  # via google-api-core
162
182
  h11==0.14.0
163
183
  # via uvicorn
@@ -172,12 +192,15 @@ idna==3.7
172
192
  imagesize==1.4.1
173
193
  # via sphinx
174
194
  iniconfig==2.0.0
175
- # via pytest
195
+ # via
196
+ # -c requirements/requirements.txt
197
+ # pytest
176
198
  jinja2==3.1.3
177
199
  # via
178
200
  # sphinx
179
201
  # sphinx-jinja2-compat
180
- litestar-sphinx-theme @ git+https://github.com/litestar-org/litestar-sphinx-theme.git@c5ce66aadc8f910c24f54bf0d172798c237a67eb
202
+ litestar-sphinx-theme @ git+https://github.com/litestar-org/litestar-sphinx-theme.git
203
+ # via hatch.envs.docs
181
204
  markupsafe==2.1.5
182
205
  # via
183
206
  # jinja2
@@ -191,9 +214,13 @@ multidict==6.0.5
191
214
  natsort==8.4.0
192
215
  # via domdf-python-tools
193
216
  nodeenv==1.8.0
217
+ # via hatch.envs.docs
194
218
  oracledb==2.1.2
219
+ # via hatch.envs.docs
195
220
  packaging==24.0
196
221
  # via
222
+ # -c requirements/requirements.txt
223
+ # google-cloud-bigquery
197
224
  # pydata-sphinx-theme
198
225
  # pytest
199
226
  # pytest-sugar
@@ -201,7 +228,9 @@ packaging==24.0
201
228
  platformdirs==4.2.0
202
229
  # via apeye
203
230
  pluggy==1.4.0
204
- # via pytest
231
+ # via
232
+ # -c requirements/requirements.txt
233
+ # pytest
205
234
  proto-plus==1.23.0
206
235
  # via
207
236
  # google-api-core
@@ -215,6 +244,7 @@ protobuf==4.25.3
215
244
  # grpcio-status
216
245
  # proto-plus
217
246
  psycopg==3.1.18
247
+ # via hatch.envs.docs
218
248
  pyasn1==0.6.0
219
249
  # via
220
250
  # pyasn1-modules
@@ -236,6 +266,8 @@ pyodbc==5.1.0
236
266
  # via aioodbc
237
267
  pytest==8.1.1
238
268
  # via
269
+ # -c requirements/requirements.txt
270
+ # hatch.envs.docs
239
271
  # pytest-click
240
272
  # pytest-cov
241
273
  # pytest-mock
@@ -243,19 +275,29 @@ pytest==8.1.1
243
275
  # pytest-vcr
244
276
  # pytest-xdist
245
277
  pytest-click==1.1.0
278
+ # via hatch.envs.docs
246
279
  pytest-cov==5.0.0
280
+ # via hatch.envs.docs
247
281
  pytest-mock==3.14.0
282
+ # via hatch.envs.docs
248
283
  pytest-sugar==1.0.0
284
+ # via hatch.envs.docs
249
285
  pytest-vcr==1.0.2
286
+ # via hatch.envs.docs
250
287
  pytest-xdist==3.5.0
288
+ # via hatch.envs.docs
289
+ python-dateutil==2.9.0.post0
290
+ # via google-cloud-bigquery
251
291
  pyyaml==6.0.1
252
292
  # via vcrpy
253
293
  redis==5.0.3
294
+ # via hatch.envs.docs
254
295
  requests==2.31.0
255
296
  # via
256
297
  # apeye
257
298
  # cachecontrol
258
299
  # google-api-core
300
+ # google-cloud-bigquery
259
301
  # sphinx
260
302
  rsa==4.9
261
303
  # via google-auth
@@ -263,12 +305,12 @@ ruamel-yaml==0.18.6
263
305
  # via sphinx-toolbox
264
306
  ruamel-yaml-clib==0.2.8
265
307
  # via ruamel-yaml
266
- ruff==0.3.7
308
+ ruff==0.4.0
267
309
  # via auto-pytabs
268
- setuptools==69.5.1
269
- # via nodeenv
270
310
  six==1.16.0
271
- # via html5lib
311
+ # via
312
+ # html5lib
313
+ # python-dateutil
272
314
  sniffio==1.3.1
273
315
  # via anyio
274
316
  snowballstemmer==2.2.0
@@ -277,6 +319,7 @@ soupsieve==2.5
277
319
  # via beautifulsoup4
278
320
  sphinx==7.3.6
279
321
  # via
322
+ # hatch.envs.docs
280
323
  # auto-pytabs
281
324
  # autodocsumm
282
325
  # pydata-sphinx-theme
@@ -289,12 +332,17 @@ sphinx==7.3.6
289
332
  # sphinx-tabs
290
333
  # sphinx-toolbox
291
334
  sphinx-autobuild==2024.4.16
335
+ # via hatch.envs.docs
292
336
  sphinx-autodoc-typehints==2.1.0
293
337
  # via sphinx-toolbox
294
338
  sphinx-click==5.1.0
339
+ # via hatch.envs.docs
295
340
  sphinx-copybutton==0.5.2
341
+ # via hatch.envs.docs
296
342
  sphinx-design==0.5.0
297
- # via litestar-sphinx-theme
343
+ # via
344
+ # hatch.envs.docs
345
+ # litestar-sphinx-theme
298
346
  sphinx-jinja2-compat==0.2.0.post1
299
347
  # via sphinx-toolbox
300
348
  sphinx-prompt==1.8.0
@@ -302,6 +350,7 @@ sphinx-prompt==1.8.0
302
350
  sphinx-tabs==3.4.5
303
351
  # via sphinx-toolbox
304
352
  sphinx-toolbox==3.5.0
353
+ # via hatch.envs.docs
305
354
  sphinxcontrib-applehelp==1.0.8
306
355
  # via sphinx
307
356
  sphinxcontrib-devhelp==1.0.6
@@ -311,6 +360,7 @@ sphinxcontrib-htmlhelp==2.0.5
311
360
  sphinxcontrib-jsmath==1.0.1
312
361
  # via sphinx
313
362
  sphinxcontrib-mermaid==0.9.2
363
+ # via hatch.envs.docs
314
364
  sphinxcontrib-qthelp==1.0.7
315
365
  # via sphinx
316
366
  sphinxcontrib-serializinghtml==1.1.10
@@ -329,7 +379,7 @@ typing-extensions==4.11.0
329
379
  # psycopg
330
380
  # pydata-sphinx-theme
331
381
  # sphinx-toolbox
332
- urllib3==2.2.1
382
+ urllib3==1.26.18
333
383
  # via
334
384
  # elastic-transport
335
385
  # elasticsearch7
@@ -345,11 +395,11 @@ webencodings==0.5.1
345
395
  websockets==12.0
346
396
  # via sphinx-autobuild
347
397
  wrapt==1.16.0
348
- # via
349
- # deprecated
350
- # vcrpy
398
+ # via vcrpy
351
399
  yarl==1.9.4
352
400
  # via
353
401
  # aiohttp
354
- # elasticsearch7
355
402
  # vcrpy
403
+
404
+ # The following packages are considered to be unsafe in a requirements file:
405
+ # setuptools
@@ -1,5 +1,5 @@
1
- sonar.organization=litestar-org
2
- sonar.projectKey=litestar-org_pytest_databases
1
+ sonar.organization=litestar-api
2
+ sonar.projectKey=litestar-org_pytest-databases
3
3
  sonar.python.coverage.reportPaths=coverage.xml
4
4
  sonar.python.version=3.8, 3.9, 3.10, 3.11, 3.12
5
5
  sonar.sourceEncoding=UTF-8
@@ -11,5 +11,6 @@ sonar.coverage.exclusions=\
11
11
  tests/*.py
12
12
  sonar.cpd.exclusions=\
13
13
  examples/*.py, \
14
- tests/conftest.py
15
- sonar.projectName=PyTest Databases
14
+ tests/conftest.py, \
15
+ src/pytest_databases/docker/**/*.py
16
+ sonar.projectName=Pytest Databases
@@ -125,11 +125,11 @@ class DockerServiceRegistry:
125
125
  )
126
126
 
127
127
  def stop(self, name: str) -> None:
128
- self.run_command("down", "--remove-orphans", "--volumes", "-t", "10", name)
128
+ self.run_command("down", "--volumes", "-t", "10", name)
129
129
 
130
130
  def down(self) -> None:
131
131
  if not SKIP_DOCKER_COMPOSE:
132
- self.run_command("down", "--remove-orphans", "--volumes", "-t", "10")
132
+ self.run_command("down", "-t", "10")
133
133
 
134
134
 
135
135
  @pytest.fixture(scope="session")
@@ -0,0 +1,133 @@
1
+ # MIT License
2
+
3
+ # Copyright (c) 2024 Litestar
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+
24
+ from __future__ import annotations
25
+
26
+ import os
27
+ from pathlib import Path
28
+ from typing import TYPE_CHECKING
29
+
30
+ import pytest
31
+ from google.api_core.client_options import ClientOptions
32
+ from google.auth.credentials import AnonymousCredentials, Credentials
33
+ from google.cloud import bigquery
34
+
35
+ if TYPE_CHECKING:
36
+ from pytest_databases.docker import DockerServiceRegistry
37
+
38
+
39
+ async def bigquery_responsive(
40
+ host: str,
41
+ bigquery_endpoint: str,
42
+ bigquery_dataset: str,
43
+ bigquery_client_options: ClientOptions,
44
+ bigquery_project: str,
45
+ bigquery_credentials: Credentials,
46
+ ) -> bool:
47
+ try:
48
+ client = bigquery.Client(
49
+ project=bigquery_project, client_options=bigquery_client_options, credentials=bigquery_credentials
50
+ )
51
+
52
+ job = client.query(query="SELECT 1 as one")
53
+
54
+ resp = list(job.result())
55
+ return resp[0].one == 1
56
+ except Exception: # noqa: BLE001
57
+ return False
58
+
59
+
60
+ @pytest.fixture
61
+ def bigquery_port() -> int:
62
+ return 9051
63
+
64
+
65
+ @pytest.fixture
66
+ def bigquery_grpc_port() -> int:
67
+ return 9061
68
+
69
+
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
76
+ def bigquery_dataset() -> str:
77
+ return "test-dataset"
78
+
79
+
80
+ @pytest.fixture
81
+ def bigquery_project() -> str:
82
+ return "emulator-test-project"
83
+
84
+
85
+ @pytest.fixture()
86
+ def bigquery_client_options(bigquery_endpoint: str) -> ClientOptions:
87
+ return ClientOptions(api_endpoint=bigquery_endpoint)
88
+
89
+
90
+ @pytest.fixture
91
+ def bigquery_credentials() -> Credentials:
92
+ return AnonymousCredentials()
93
+
94
+
95
+ @pytest.fixture(scope="session")
96
+ def docker_compose_files() -> list[Path]:
97
+ return [Path(Path(__file__).parent / "docker-compose.bigquery.yml")]
98
+
99
+
100
+ @pytest.fixture(scope="session")
101
+ def default_bigquery_service_name() -> str:
102
+ return "bigquery"
103
+
104
+
105
+ @pytest.fixture(autouse=False)
106
+ async def bigquery_service(
107
+ docker_services: DockerServiceRegistry,
108
+ default_bigquery_service_name: str,
109
+ docker_compose_files: list[Path],
110
+ bigquery_port: int,
111
+ bigquery_grpc_port: int,
112
+ bigquery_endpoint: str,
113
+ bigquery_dataset: str,
114
+ bigquery_project: str,
115
+ bigquery_credentials: Credentials,
116
+ bigquery_client_options: ClientOptions,
117
+ ) -> None:
118
+ os.environ["BIGQUERY_ENDPOINT"] = bigquery_endpoint
119
+ os.environ["BIGQUERY_DATASET"] = bigquery_dataset
120
+ os.environ["BIGQUERY_PORT"] = str(bigquery_port)
121
+ os.environ["BIGQUERY_GRPC_PORT"] = str(bigquery_grpc_port)
122
+ os.environ["GOOGLE_CLOUD_PROJECT"] = bigquery_project
123
+ await docker_services.start(
124
+ name=default_bigquery_service_name,
125
+ docker_compose_files=docker_compose_files,
126
+ timeout=60,
127
+ check=bigquery_responsive,
128
+ bigquery_endpoint=bigquery_endpoint,
129
+ bigquery_dataset=bigquery_dataset,
130
+ bigquery_project=bigquery_project,
131
+ bigquery_credentials=bigquery_credentials,
132
+ bigquery_client_options=bigquery_client_options,
133
+ )
@@ -0,0 +1,18 @@
1
+ services:
2
+ bigquery:
3
+ image: ghcr.io/goccy/bigquery-emulator:latest
4
+ ports:
5
+ - "${BIGQUERY_PORT:-9050}:9050"
6
+ - "${BIGQUERY_GRPC_PORT:-9060}:9060"
7
+ entrypoint: /bin/bigquery-emulator
8
+ command: --project=${GOOGLE_CLOUD_PROJECT:-emulator-test-project} --dataset=${BIGQUERY_DATASET:-test-dataset}
9
+ environment:
10
+ PROJECT_ID: ${GOOGLE_CLOUD_PROJECT:-emulator-test-project}
11
+ DATASET_NAME: ${BIGQUERY_DATASET:-test-dataset}
12
+ volumes:
13
+ - bigquerydata:/work
14
+ networks:
15
+ default:
16
+ driver: bridge
17
+ volumes:
18
+ bigquerydata:
@@ -0,0 +1,75 @@
1
+ # MIT License
2
+
3
+ # Copyright (c) 2024 Litestar
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ from __future__ import annotations
24
+
25
+ from typing import TYPE_CHECKING
26
+
27
+ import pytest
28
+
29
+ from pytest_databases.docker.bigquery import bigquery_responsive
30
+
31
+ if TYPE_CHECKING:
32
+ from google.api_core.client_options import ClientOptions
33
+ from google.auth.credentials import Credentials
34
+
35
+ from pytest_databases.docker import DockerServiceRegistry
36
+
37
+ pytestmark = pytest.mark.anyio
38
+ pytest_plugins = [
39
+ "pytest_databases.docker.bigquery",
40
+ ]
41
+
42
+
43
+ def test_bigquery_default_config(
44
+ docker_ip: str,
45
+ bigquery_port: int,
46
+ bigquery_grpc_port: int,
47
+ bigquery_dataset: str,
48
+ bigquery_endpoint: str,
49
+ bigquery_project: str,
50
+ ) -> None:
51
+ assert bigquery_port == 9051
52
+ assert bigquery_grpc_port == 9061
53
+ assert bigquery_dataset == "test-dataset"
54
+ assert bigquery_endpoint == f"http://{docker_ip}:9051"
55
+ assert bigquery_project == "emulator-test-project"
56
+
57
+
58
+ async def test_bigquery_services(
59
+ docker_ip: str,
60
+ bigquery_service: DockerServiceRegistry,
61
+ bigquery_endpoint: str,
62
+ bigquery_dataset: str,
63
+ bigquery_client_options: ClientOptions,
64
+ bigquery_project: str,
65
+ bigquery_credentials: Credentials,
66
+ ) -> None:
67
+ ping = await bigquery_responsive(
68
+ docker_ip,
69
+ bigquery_endpoint=bigquery_endpoint,
70
+ bigquery_dataset=bigquery_dataset,
71
+ bigquery_project=bigquery_project,
72
+ bigquery_credentials=bigquery_credentials,
73
+ bigquery_client_options=bigquery_client_options,
74
+ )
75
+ assert ping