pytest-bigquery-mock
Pytest plugin that provides a bq_client_mock fixture.
This fixture mocks the google.cloud.bigquery.Client class and provides a way to mock an API response using pytest.mark, for example:
Install and use
Install the plugin with
pip install pytest-bigquery-mock
Then, in your conftest.py file add pytest-bigquery-mock to your list of plugins
plugins = ["pytest-bigquery-mock"]
This allows you to use the bq_client_mock fixture in your pytest tests.
def function_that_calls_bigquery(bq_client):
row_iter = bq_client.query("SELECT * FROM table").result()
return row_iter
@pytest.mark.bq_query_return_data(
[
{
"query": "SELECT * FROM table",
"table": {
"columns": [
"id_row",
"name",
],
"rows": [
[1, "Alice"],
[2, "Pete"],
[3, "Steven"],
],
},
},
]
)
def test_function_that_calls_bigquery(bq_client_mock):
row_iter = function_that_calls_bigquery(bq_client_mock)
expected_row_dicts = [
{"id_row": 1, "name": "Alice"},
{"id_row": 2, "name": "Pete"},
{"id_row": 3, "name": "Steven"},
]
for row, expected_row in zip(row_iter, expected_row_dicts):
assert dict(row) == expected_row
Metadata
Release files for pytest-bigquery-mock 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pytest-bigquery-mock-0.1.2.tar.gz | 3.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_bigquery_mock-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / pytest-bigquery-mock-0.1.2.tar.gz
| Download URL | pytest-bigquery-mock-0.1.2.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb31fb17a93bbaff69fca545092fbffa111310b9b11c843b3f26b0117a37215d
|
|
BLAKE2b-256 checksum How to use checksums |
208aea884e105a452db251a53d5e4d23c67613ced1752fb2c59752ae64d5fd7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.13
|
Release files / pytest_bigquery_mock-0.1.2-py3-none-any.whl
| Download URL | pytest_bigquery_mock-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
57ef3085731a84cf377815e5416204d516383c35069d57d3e5ba6f8cc4b21da8
|
|
BLAKE2b-256 checksum How to use checksums |
c56573afce07ed8cfbc86f51f013dc65f0e2e4e718aa705d5bf7e875d923c2b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.13
|
Security for pytest-bigquery-mock 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.