All Projects → lycantropos → hypothesis_sqlalchemy

lycantropos / hypothesis_sqlalchemy

Licence: MIT license
hypothesis strategies for generating SQLAlchemy objects

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects
powershell
5483 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to hypothesis sqlalchemy

gooseberry
A command line utility to generate a knowledge base from Hypothesis annotations
Stars: ✭ 103 (+329.17%)
Mutual labels:  hypothesis
django-rest-witchcraft
Django REST Framework integration with SQLAlchemy
Stars: ✭ 38 (+58.33%)
Mutual labels:  sqlalchemy
bag
A Python library for several purposes
Stars: ✭ 25 (+4.17%)
Mutual labels:  sqlalchemy
AUCR
Analyst Unknown Cyber Range - a micro web service framework
Stars: ✭ 24 (+0%)
Mutual labels:  sqlalchemy
hypothesis-graphql
Generate arbitrary queries matching your GraphQL schema, and use them to verify your backend implementation.
Stars: ✭ 32 (+33.33%)
Mutual labels:  hypothesis
kitimat
A library for generative, property-based testing in TypeScript and Jest.
Stars: ✭ 68 (+183.33%)
Mutual labels:  quickcheck
efftester
Effect-Driven Compiler Tester for OCaml
Stars: ✭ 37 (+54.17%)
Mutual labels:  quickcheck
OpenAlchemy
Define SQLAlchemy models using the OpenAPI specification.
Stars: ✭ 39 (+62.5%)
Mutual labels:  sqlalchemy
falcon-sqla
SQLAlchemy session management middleware for Falcon applications.
Stars: ✭ 20 (-16.67%)
Mutual labels:  sqlalchemy
yosai alchemystore
SQLAlchemy-enabled Account Store for Yosai that features a flat Role-Based Access Control (RBAC) data model
Stars: ✭ 17 (-29.17%)
Mutual labels:  sqlalchemy
trashed
Trashed is an organizational tool designed to help users keep their communities clean.
Stars: ✭ 13 (-45.83%)
Mutual labels:  sqlalchemy
AnyBlok
AnyBlok is a Python framework for building business applications.
Stars: ✭ 19 (-20.83%)
Mutual labels:  sqlalchemy
CourseCake
By serving course 📚 data that is more "edible" 🍰 for developers, we hope CourseCake offers a smooth approach to build useful tools for students.
Stars: ✭ 21 (-12.5%)
Mutual labels:  sqlalchemy
py-data-api
A user-friendly client for AWS Aurora Serverless's Data API
Stars: ✭ 37 (+54.17%)
Mutual labels:  sqlalchemy
pyramid-cookiecutter-alchemy
[DEPRECATED - Please use https://github.com/pylons/pyramid-cookiecutter-starter instead] A Cookiecutter (project template) for creating a Pyramid project using SQLite for persistent storage, SQLAlchemy for an ORM, Alembic for database migrations, URL dispatch for routing, and Jinja2 for templating.
Stars: ✭ 39 (+62.5%)
Mutual labels:  sqlalchemy
chm-documentation
chm documentation PostgreSQL pgadmin3 SQLAlchemy Django Flask jinja2 webpy doc chm compiled html help Postgres Postgre документация russian
Stars: ✭ 17 (-29.17%)
Mutual labels:  sqlalchemy
soar-php
SQL optimizer and rewriter. - SQL 优化、重写器(辅助 SQL 调优)。
Stars: ✭ 140 (+483.33%)
Mutual labels:  sqlalchemy
magql
The magical GraphQL framework that generates an API for your data.
Stars: ✭ 26 (+8.33%)
Mutual labels:  sqlalchemy
databricks-dbapi
DBAPI and SQLAlchemy dialect for Databricks Workspace and SQL Analytics clusters
Stars: ✭ 21 (-12.5%)
Mutual labels:  sqlalchemy
mock-alchemy
SQLAlchemy mock helpers.
Stars: ✭ 44 (+83.33%)
Mutual labels:  sqlalchemy

hypothesis_sqlalchemy

In what follows python is an alias for python3.6 or pypy3.6 or any later version (python3.7, pypy3.7 and so on).

Installation

Install the latest pip & setuptools packages versions

python -m pip install --upgrade pip setuptools

User

Download and install the latest stable version from PyPI repository

python -m pip install --upgrade hypothesis_sqlalchemy

Developer

Download the latest version from GitHub repository

git clone https://github.com/lycantropos/hypothesis_sqlalchemy.git
cd hypothesis_sqlalchemy

Install dependencies

python -m pip install -r requirements.txt

Install

python setup.py install

Usage

With setup

>>> import warnings
>>> from hypothesis.errors import NonInteractiveExampleWarning
>>> # ignore hypothesis warnings caused by `example` method call
... warnings.filterwarnings('ignore', category=NonInteractiveExampleWarning)

let's take a look at what can be generated and how.

Tables

We can write a strategy that produces tables

>>> from hypothesis_sqlalchemy import scheme
>>> from sqlalchemy.engine.default import DefaultDialect
>>> dialect = DefaultDialect()
>>> tables = scheme.tables(dialect,
...                        min_size=3,
...                        max_size=10)
>>> table = tables.example()
>>> from sqlalchemy.schema import Table
>>> isinstance(table, Table)
True
>>> from sqlalchemy.schema import Column
>>> all(isinstance(column, Column) for column in table.columns)
True
>>> 3 <= len(table.columns) <= 10
True

Records

Suppose we have a table

>>> from sqlalchemy.schema import (Column,
...                                MetaData,
...                                Table)
>>> from sqlalchemy.sql.sqltypes import (Integer,
...                                      String)
>>> metadata = MetaData()
>>> user_table = Table('user', metadata,
...                    Column('user_id', Integer,
...                           primary_key=True),
...                    Column('user_name', String(16),
...                           nullable=False),
...                    Column('email_address', String(60)),
...                    Column('password', String(20),
...                           nullable=False))

and we can write strategy that

  • produces single records (as tuples)
    >>> from hypothesis import strategies
    >>> from hypothesis_sqlalchemy.sample import table_records
    >>> records = table_records(user_table, 
    ...                         email_address=strategies.emails())
    >>> record = records.example()
    >>> isinstance(record, tuple)
    True
    >>> len(record) == len(user_table.columns)
    True
    >>> all(column.nullable and value is None
    ...     or isinstance(value, column.type.python_type) 
    ...     for value, column in zip(record, user_table.columns))
    True
  • produces records lists (with configurable list size bounds)
    >>> from hypothesis_sqlalchemy.sample import table_records_lists
    >>> records_lists = table_records_lists(user_table,
    ...                                     min_size=2,
    ...                                     max_size=5, 
    ...                                     email_address=strategies.emails())
    >>> records_list = records_lists.example()
    >>> isinstance(records_list, list)
    True
    >>> 2 <= len(records_list) <= 5
    True
    >>> all(isinstance(record, tuple) for record in records_list)
    True
    >>> all(len(record) == len(user_table.columns) for record in records_list)
    True

Development

Bumping version

Preparation

Install bump2version.

Pre-release

Choose which version number category to bump following semver specification.

Test bumping version

bump2version --dry-run --verbose $CATEGORY

where $CATEGORY is the target version number category name, possible values are patch/minor/major.

Bump version

bump2version --verbose $CATEGORY

This will set version to major.minor.patch-alpha.

Release

Test bumping version

bump2version --dry-run --verbose release

Bump version

bump2version --verbose release

This will set version to major.minor.patch.

Running tests

Install dependencies

python -m pip install -r requirements-tests.txt

Plain

pytest

Inside Docker container:

  • with CPython
    docker-compose --file docker-compose.cpython.yml up
  • with PyPy
    docker-compose --file docker-compose.pypy.yml up

Bash script:

  • with CPython

    ./run-tests.sh

    or

    ./run-tests.sh cpython
  • with PyPy

    ./run-tests.sh pypy

PowerShell script:

  • with CPython
    .\run-tests.ps1
    or
    .\run-tests.ps1 cpython
  • with PyPy
    .\run-tests.ps1 pypy
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].