Skip to main content

BigQuery fixtures and fixture factories for Pytest.

Project description

Pytest GCS

This is a pytest plugin in similar vein to pytest-postgres and pytest-kafka.

This would have been much more painful without Mirakuru and bigquery-emulator; this is a simple wrapper around those tools.

Installation

This tool requires you to have a copy of the bigquery-emulator binary somewhere on your path. Depending upon your architecture you'll need a different version of the tool.

wget https://github.com/goccy/bigquery-emulator/releases/download/v0.6.1/bigquery-emulator-linux-amd64
mv bigquery-emulator-linux-amd64 /usr/local/bin/bigquery-emulator

To install this library:

pip install pytest-bq

Demo

# conftest.py
from pytest_bq.factories import client as bq_client
from pytest_bq.factories import proc as bq_process

# Create a process and a local client that targets that process.
bq_proc = bq_process.bq_proc(executable='/usr/local/bin/bigquery-emulator', project_id='test')
bqlocal = bq_client.bqlocal("bq_proc")

# tests/test_bq.py
from google.cloud import bigquery
from pytest_bq.executor.process import BQExecutor


def test_can_list_datasets(bq_proc: BQExecutor, bqlocal: bigquery.Client) -> None:
    """MVP to ensure everything works."""
    test_dataset = "test_base"
    bqlocal.create_dataset(test_dataset)
    datasets = [x.full_dataset_id for x in bqlocal.list_datasets()]

    assert test_dataset in datasets

Contributing

PRs are accepted.

# Install the dependencies with:
pip install .[test]
# Install pre-commit hooks.
pre-commit install
# Validate everything passes.
pre-commit run --all
# Run the tests.
pytest tests/

TODOs

  • Implement the events outputs, -event.bucket, -event.list, etc.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_bq-0.0.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

pytest_bq-0.0.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file pytest_bq-0.0.1.tar.gz.

File metadata

  • Download URL: pytest_bq-0.0.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for pytest_bq-0.0.1.tar.gz
Algorithm Hash digest
SHA256 2c83181309f406ab8f9843300b18fd9c6516d2af4f6e74f5122fea4a970d93f2
MD5 8f6c2ebdcb9b63c1742156db4d41385d
BLAKE2b-256 cec4ea94d72ac1c6126b7700b883a52f8285d24b0900407da841d637c1fac539

See more details on using hashes here.

File details

Details for the file pytest_bq-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pytest_bq-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for pytest_bq-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 540ab00273a09944980e01367618bdc0a935b966e0a1508a8f550be78b840ce8
MD5 32d0ef11a46a05fc89ee4df21cd013c7
BLAKE2b-256 d3228bd139467e198701edc31ae17b000fe68408049e3eade47c0f4cc1a3839d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page