Metadata-Version: 2.1
Name: pytest-snowflake-bdd
Version: 0.1.0.post6
Summary: Setup test data and run tests on snowflake in BDD style!
Home-page: https://github.com/tilakpatidar/pytest-snowflake_bdd
Author: Tilak Patidar
Author-email: tilakpatidar@gmail.com
Maintainer: Tilak Patidar
Maintainer-email: tilakpatidar@gmail.com
License: MIT
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Testing :: BDD
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Framework :: Pytest
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.6.7
License-File: LICENSE
Requires-Dist: pytest (>=6.2.0)
Requires-Dist: pytest-bdd (>=3.2.1)
Requires-Dist: snowflake-sqlalchemy (>=1.3.2)
Requires-Dist: SQLAlchemy (>=1.4.27)
Requires-Dist: pandas (>=0.25.3)

pytest-snowflake_bdd
--------------------
.. image:: https://img.shields.io/pypi/v/pytest-snowflake_bdd.svg
    :target: https://pypi.org/project/pytest-snowflake_bdd
    :alt: PyPI version

.. image:: https://img.shields.io/pypi/pyversions/pytest-snowflake_bdd.svg
    :target: https://pypi.org/project/pytest-snowflake_bdd
    :alt: Python versions

.. image:: https://ci.appveyor.com/api/projects/status/github/tilakpatidar/pytest-snowflake_bdd?branch=master
    :target: https://ci.appveyor.com/project/tilakpatidar/pytest-snowflake_bdd/branch/master
    :alt: 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.

.. code:: gherkin

   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**


.. code:: gherkin

    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.

.. code:: gherkin

    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.

.. code:: gherkin

    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**

.. code:: gherkin

    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>``

.. code:: gherkin

      | 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.

.. _`MIT`: http://opensource.org/licenses/MIT
.. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause
.. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt
.. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0
.. _`file an issue`: https://github.com/tilakpatidar/pytest-snowflake_bdd/issues
.. _`pytest`: https://github.com/pytest-dev/pytest
.. _`tox`: https://tox.readthedocs.io/en/latest/
.. _`pip`: https://pypi.org/project/pip/
.. _`PyPI`: https://pypi.org/project
.. _`pytest-bdd`: https://pypi.org/project/pytest-bdd/


