Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidemoro/play_sql
pytest-play support for SQL expressions and assertions
https://github.com/davidemoro/play_sql
pytest python sql sqlalchemy testing
Last synced: about 2 months ago
JSON representation
pytest-play support for SQL expressions and assertions
- Host: GitHub
- URL: https://github.com/davidemoro/play_sql
- Owner: davidemoro
- License: apache-2.0
- Created: 2018-01-10T15:24:09.000Z (about 7 years ago)
- Default Branch: develop
- Last Pushed: 2019-01-25T23:16:40.000Z (almost 6 years ago)
- Last Synced: 2024-11-08T08:08:21.899Z (2 months ago)
- Topics: pytest, python, sql, sqlalchemy, testing
- Language: Python
- Homepage: https://github.com/pytest-dev/pytest-play
- Size: 41 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
========
play sql
========.. image:: https://img.shields.io/pypi/v/play_sql.svg
:target: https://pypi.python.org/pypi/play_sql.. image:: https://travis-ci.org/davidemoro/play_sql.svg?branch=develop
:target: https://travis-ci.org/davidemoro/play_sql.. image:: https://readthedocs.org/projects/play-sql/badge/?version=latest
:target: https://play-sql.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status.. image:: https://codecov.io/gh/davidemoro/play_sql/branch/develop/graph/badge.svg
:target: https://codecov.io/gh/davidemoro/play_sqlpytest-play support for SQL expressions and assertions
More info and examples on:
* pytest-play_, documentation
* cookiecutter-qa_, see ``pytest-play`` in action with a working example if you want to start hackingFeatures
--------This project defines a new pytest-play_ command:
::
- type: sql
provider: play_sql
database_url: postgresql://$db_user:$db_pwd@$db_host/$db_name
query: SELECT id, title FROM invoices
variable: invoice_id
variable_expression: results.first()[0]
assertion: invoice_id == $invoice_idwhere:
* ``database_url`` follows the format described
http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls
* ``variable_expression`` is a Python expression
* ``results.fetchone()`` returns an array whose elements matches with the next row's
columns and it could be invoked many times until there will be no more rows (eg: first call
``(1, 'first',)``, second call ``(2, 'second')``)
* ``results.first()`` returns an array whose elements matches with the first row's colums and it
can be invoked exactly one time
* ``results.fetchall()`` returns an array of tuples whose elements matches with the selected
colums (eg: ``[(1, 'first'), (2, 'second'), (3, 'third')]``)
-------``pytest-play`` tweets happens here:
* `@davidemoro`_
Credits
-------This package was created with Cookiecutter_ and the cookiecutter-play-plugin_ (based on `audreyr/cookiecutter-pypackage`_ project template).
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
.. _`cookiecutter-play-plugin`: https://github.com/davidemoro/cookiecutter-play-plugin
.. _pytest-play: https://github.com/davidemoro/pytest-play
.. _cookiecutter-qa: https://github.com/davidemoro/cookiecutter-qa
.. _`@davidemoro`: https://twitter.com/davidemoro