Integration with Google BigQuery using the BigQuery Emulator.
pip install pytest-databases[bigquery]The bigquery extra is kept as a compatibility group. Install the BigQuery client
that your application already uses.
from google.api_core.client_options import ClientOptions
from google.auth.credentials import AnonymousCredentials
from google.cloud import bigquery
from pytest_databases.docker.bigquery import BigQueryService
pytest_plugins = ["pytest_databases.docker.bigquery"]
def test(bigquery_service: BigQueryService) -> None:
client = bigquery.Client(
project=bigquery_service.project,
client_options=ClientOptions(api_endpoint=bigquery_service.endpoint),
credentials=AnonymousCredentials(),
)
job = client.query(query="SELECT 1 AS one")
rows = list(job.result())
assert rows[0].one == 1bigquery_image: The Docker image to use for the BigQuery emulator.bigquery_service: A fixture that provides a running BigQuery emulator service.
.. automodule:: pytest_databases.docker.bigquery :members: :undoc-members: :show-inheritance: