Skip to main content

pytest-snowflake_bdd

PyPI version Python versions See Build Status on AppVeyor

Setup test data and run tests on snowflake in BDD style!


Features

Provides pytest-bdd step definitions for testing snow-sql scripts against a snowflake account.

Installation

You can install “pytest-snowflake_bdd” via pip from PyPI:

$ pip install pytest-snowflake_bdd

Usage

This plugin relies on pytest-bdd to run bdd tests. Below example illustrates the usage of step definitions provided by the plugin.

Feature: ExampleFeature for snowflake testing

  Scenario: example_scenario
    Given a snowflake connection
    When a temporary called "SNOWFLAKE_LIQUIBASE.PUBLIC.DEPARTMENT" has
      | dept_id: INTEGER | dept_name: STRING      |
      | 1                | "Computer Science"     |
      | 2                | "Software Engineering" |
    When a temporary called "SNOWFLAKE_LIQUIBASE.PUBLIC.PEOPLE" has
      | people_id: INTEGER | name: STRING | dept_id: INTEGER |
      | 10                 | "tilak"      | 1                |
    Then a sql script "./sql/example.sql" runs and the result is
      | people_id: INTEGER | name: STRING | dept_id: INTEGER | dept_name: STRING  |
      | 10                 | "tilak"      | 1                | "Computer Science" |
  • dept_id: INTEGER. dept_id is the column name and INTEGER is the snowflake data type.

  • The step a temporary table called "<fully_qualified_table_name>" has

    Replaces the existing table with a temporary table. And adds data to the temporary table. This shadows the existing table in snowflake for the entire session. Any changes done to the temporary table does not reflect on the actual database. If the table does not exists creates a new temporary table.

  • The step Then a sql script "<sql_script_path>" runs and the result is This runs the sql script and compares the output with given dataframe.

Available Step definitions

Creating a new snowflake session

Given a snowflake connection

Setting up a temporary snowflake table for test

  • Replaces the existing table with a temporary table. And adds data to the temporary table. This shadows the existing table in snowflake for the entire session. Any changes done to the temporary table does not reflect on the actual database. If the table does not exists creates a new temporary table.

When a temporary called "SNOWFLAKE_LIQUIBASE.PUBLIC.DEPARTMENT" has
 | dept_id: INTEGER | dept_name: STRING      |
 | 1                | "Computer Science"     |
 | 2                | "Software Engineering" |

Setting up a snowflake table for test

  • Creates a normal table. Will fail if table already exists.

When a called "SNOWFLAKE_LIQUIBASE.PUBLIC.DEPARTMENT" has
 | dept_id: INTEGER | dept_name: STRING      |
 | 1                | "Computer Science"     |
 | 2                | "Software Engineering" |

Running a sql script and validating results

Then a sql script "./sql/example.sql" runs and the result is
  | people_id: INTEGER | name: STRING | dept_id: INTEGER | dept_name: STRING  |
  | 10                 | "tilak"      | 1                | "Computer Science" |

Representing null in table data

Use <null>

| people_id: INTEGER | name: STRING | dept_id: INTEGER | dept_name: STRING  |
| 10                 | "tilak"      | 1                | <null> |

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, “pytest-snowflake_bdd” is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

Download files

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

Source Distribution

pytest-snowflake_bdd-0.1.0.post6.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_snowflake_bdd-0.1.0.post6-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file pytest-snowflake_bdd-0.1.0.post6.tar.gz.

File metadata

  • Download URL: pytest-snowflake_bdd-0.1.0.post6.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.9.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pytest-snowflake_bdd-0.1.0.post6.tar.gz
Algorithm Hash digest
SHA256 ddec4e89e1c9e9748d37068dac55cbb4cd2663b5f7ac19dc3bcf1cdf4916767b
MD5 07ca95dcf50a2d09ace51aabafaf75d3
BLAKE2b-256 0fe98916f318bb82630d697d9d9f88bf832a2043e711ee14467dcba3e7152eed

See more details on using hashes here.

File details

Details for the file pytest_snowflake_bdd-0.1.0.post6-py3-none-any.whl.

File metadata

  • Download URL: pytest_snowflake_bdd-0.1.0.post6-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.9.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pytest_snowflake_bdd-0.1.0.post6-py3-none-any.whl
Algorithm Hash digest
SHA256 d802225e370e2c486b10c77313fcf437db35ceff4176b430b0ffa750606846e5
MD5 2c96839b0340cc65b21d57b7205caead
BLAKE2b-256 dff6b2ba4fb4868a2124f28312c4e0a51d46d6110c030e545fc78ced817fc5cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page