Skip to main content

An easy way to mock Snowflake connections in Python!

Project description

asbestos

An easy way to mock Snowflake connections in Python!

What is this?

asbestos is a library for Python 3.9+ to allow easy mocking of Snowflake calls during local development or testing to save on costs and time. The docs have more information, but here's a quick example:

from asbestos import asbestos_cursor, config as asbestos_config


def snowflake_cursor() -> SnowflakeCursor | AsbestosCursor:
    # Use a flag to decide whether it returns the test cursor
    # or the real thing
    if settings.ENABLE_ASBESTOS:
        return asbestos_cursor()
    return snowflake_connection().cursor(DictCursor)


asbestos_config.register(
    query="your sql goes %s",
    data=("here",),
    response={"It's a": "response!"}
)

with snowflake_cursor() as cursor:
    cursor.execute("your sql goes %s", ('here',))
    assert cursor.fetchall() == {"It's a": "response!"}

asbestos is not a 1:1 mocking of the full Snowflake API, but includes synchronous and async query mocking that handle most use cases. Check out some fun things you can do with it here!

Installation:

poetry add asbestos

Docs

Check out the documentation here!

To work on the docs locally, ensure that your python3 version is up-to-date (pyenv is a great way of managing this) and run make docs. This will create a dedicated documentation environment and serve the docs locally for testing. To remove the environment, run make docs_clean.

Development

asbestos uses pre-commit to help us keep the repo clean. To get started, make sure you have poetry installed and follow these steps:

  • clone the respository:
    • git clone git@github.com:SpotOnInc/asbestos.git (preferred)
    • OR git clone https://github.com/SpotOnInc/asbestos
  • poetry install
  • poetry shell
  • pre-commit install

After that, you're ready to go!

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

asbestos-1.5.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

asbestos-1.5.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file asbestos-1.5.1.tar.gz.

File metadata

  • Download URL: asbestos-1.5.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1024-azure

File hashes

Hashes for asbestos-1.5.1.tar.gz
Algorithm Hash digest
SHA256 09f60c350ff2924e3a6af22dae54d02a6ac1f4277d6c1c085bca61eb655284c0
MD5 c3e7608e1f6e0ef5edc7a7f85917b2db
BLAKE2b-256 343785d2871712579b79b4b9c9a9f0f9416e1f5311af08a84f54ac01d6ece0ad

See more details on using hashes here.

Provenance

File details

Details for the file asbestos-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: asbestos-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1024-azure

File hashes

Hashes for asbestos-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 49c7ebc603cdf2854defa2ae7dadafa0ebb6e2cc9388ed95fbbff35986b17778
MD5 5469d4b6c162799469a9875ad1dd480f
BLAKE2b-256 14cb04d11779cb4640d6ca91800d2629a0fa4dcf0b6a936644b781c9a2afd0f5

See more details on using hashes here.

Provenance

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