A library for generating fake data and populating database tables.

Overview

Knockoff Factory

codecov Test PyPi Release Docker Build License Python Versions Docker Image Size Python Wheel

A library for generating mock data and creating database fixtures that can be used for unit testing.

Table of content

Installation

pip install knockoff

Changelog

See the changelog for a history of notable changes to knockoff.

Documentation

We are working on adding more documentation and examples!

Unit Tests

Prerequisites

  • docker
  • poetry (curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python)

Some of the unit tests depend on a database instance. Knockoff will create ephemeral databases within that instance and clean them up when tests have completed. By default it will attempt to connect to an existing instance at postgresql://[email protected]:5432/postgres and will create and destroy databases per test. This postgres location can be overridden with the KNOCKOFF_TEST_DB_URI environment variable.

If no external postgres instance is available for testing, but postgresql is installed, the TEST_USE_EXTERNAL_DB environment variable can be set to 0. The fixtures will then rely on the testing.postgresql library to create ephemeral postgres instances per fixture.

If postgres is not available, dependent tests can be disabled with the following: export TEST_POSTGRES_ENABLED=0.

Create the database instance using docker:

docker run --rm  --name pg-docker -e POSTGRES_HOST_AUTH_METHOD=trust -d -p 5432:5432  postgres:11.9

Install poetry:

poetry install

Run unit test:

poetry run pytest

Future work

  • Further documentation and examples for SDK
  • Add yaml based configuration for SDK
  • Make extensible generic output for KnockffDB.insert (csv, parquet, etc)
  • Enable append option for KnockoffDB.insert
  • Autodiscover and populate all tables by using reflection and building dependency graph with foreign key relationships
  • Parallelize execution of dag. (e.g. https://ipython.org/ipython-doc/stable/parallel/dag_dependencies.html)
You might also like...
A Python Selenium library inspired by the Testing Library

Selenium Testing Library Slenium Testing Library (STL) is a Python library for Selenium inspired by Testing-Library. Dependencies Python 3.6, 3.7, 3.8

A command-line tool and Python library and Pytest plugin for automated testing of RESTful APIs, with a simple, concise and flexible YAML-based syntax

1.0 Release See here for details about breaking changes with the upcoming 1.0 release: https://github.com/taverntesting/tavern/issues/495 Easier API t

Test django schema and data migrations, including migrations' order and best practices.

django-test-migrations Features Allows to test django schema and data migrations Allows to test both forward and rollback migrations Allows to test th

Hypothesis is a powerful, flexible, and easy to use library for property-based testing.

Hypothesis Hypothesis is a family of testing libraries which let you write tests parametrized by a source of examples. A Hypothesis implementation the

Python version of the Playwright testing and automation library.

🎭 Playwright for Python Docs | API Playwright is a Python library to automate Chromium, Firefox and WebKit browsers with a single API. Playwright del

A library to make concurrent selenium tests that automatically download and setup webdrivers

AutoParaSelenium A library to make parallel selenium tests that automatically download and setup webdrivers Usage Installation pip install autoparasel

pytest plugin for manipulating test data directories and files

pytest-datadir pytest plugin for manipulating test data directories and files. Usage pytest-datadir will look up for a directory with the name of your

A mocking library for requests

httmock A mocking library for requests for Python 2.7 and 3.4+. Installation pip install httmock Or, if you are a Gentoo user: emerge dev-python/httm

A utility for mocking out the Python Requests library.

Responses A utility library for mocking out the requests Python library. Note Responses requires Python 2.7 or newer, and requests = 2.0 Installing p

Releases(v4.3.2)
  • v4.3.2(Aug 3, 2022)

    • Removed dependency on six which was required for py23 compatibility.
    • Updated dependency-injector version to resolve poetry lock issue with six <=1.15.0.

    Additional information about the changes can be found here.

    Source code(tar.gz)
    Source code(zip)
  • v4.3.1(Aug 3, 2022)

    Fixed backwards compatibility issue in KnockoffContainer with sqlalchemy breaking change for create_engine's positional arg changing into a kwarg, url. Fix KnockoffDB class so that it actually skips inserts where insert=False for a node Fix KnockoffTableFactory so that if you pass next_strategy_factory it won't complain about also providing next_strategy_callable

    Additional information about the changes can be found here.

    Source code(tar.gz)
    Source code(zip)
  • v4.3.0(Jul 27, 2021)

    • Added io utilities for parallelizing writes to sql with joblib
    • Added rename and drop parameters for KnockoffTable
    • Added support for MySQL to TempDatabaseService (knockoff.tempdb.setup_teardown:mysql_setup_teardown)
    • Added reflect_schema method to KnockoffDatabaseService
    • Moved knockoff.testing_postgresql modules to knockoff.utilities.testing.postgresql
    • Parallelized DefaultDatabaseService inserts
    • Renamed KnockoffTable.build_record method to KnockoffTable._build_record declaring it as private by convention
    • Fixed DefaultDatabaseService's reflect_table method for MySql

    Additional information about changes can be found here.

    Source code(tar.gz)
    Source code(zip)
  • v4.2.1(Jul 27, 2021)

    • Added default configurations for knockoff run CLI with environment variable override options
    • Moved clear_env_vars from knockoff.orm to knockoff.utilities.environ
    • Fixed issue where knockoff run CLI was not using the temp db created with the --ephemeral flag
    Source code(tar.gz)
    Source code(zip)
  • v4.2.0(Jul 19, 2021)

    • Add --ephemeral flag for knockoff run CLI to create temp database for loading knockoff configuration from sdk
    • Add unit tests for KnockoffDB.build and knockoff run CLI
    • Add Documentation and jupyter notebook for TempDatabaseService
    • Add Documentation and jupyter notebook for KnockoffDB
    • Moved legacy YAML based knockoff cli from README.md to legacy.MD
    Source code(tar.gz)
    Source code(zip)
  • v4.1.0(Jul 19, 2021)

  • v4.0.0(Jul 15, 2021)

    • Added ColumnFactory for providing factory functions instead of requiring as a tuple (column, factory)
    • Added build method for KnockoffDB to enable building dataframes without inserting into DB
    • Added run CLI command for loading data into database from sdk configuration
    • Added Blueprint class to sdk for more composable configuration
    • Added tempdb module and TempDatabaseService class
    • Made CLI extensible with injectable subcommands
    • Moved previous CLI to legacy subcommand for loading data into database using yaml configuration
    • Renamed knockoff.utilities.mixin:FactoryMixin to knockoff.utilities.mixin:ResourceLocatorMixin
    • Updated internal knockoff fixtures to use TempDatabaseService

    Additional changes can be found here.

    Source code(tar.gz)
    Source code(zip)
Owner
Nike Inc.
Nike Inc.
tidevice can be used to communicate with iPhone device

tidevice can be used to communicate with iPhone device

Alibaba 1.8k Jan 08, 2023
A single module to link Python ecosystem to the Web

A single module to link Python ecosystem to the Web. Have a quick look at the Gallery first to get convinced ! FAQ For any questions, please use Stack

66 Dec 21, 2022
PyAutoEasy is a extension / wrapper around the famous PyAutoGUI, a cross-platform GUI automation tool to replace your boooring repetitive tasks.

PyAutoEasy PyAutoEasy is a extension / wrapper around the famous PyAutoGUI, a cross-platform GUI automation tool to replace your boooring repetitive t

Dingu Sagar 7 Oct 27, 2022
Avocado is a set of tools and libraries to help with automated testing.

Welcome to Avocado Avocado is a set of tools and libraries to help with automated testing. One can call it a test framework with benefits. Native test

Ana Guerrero Lopez 1 Nov 19, 2021
Flexible test automation for Python

Nox - Flexible test automation for Python nox is a command-line tool that automates testing in multiple Python environments, similar to tox. Unlike to

Stargirl Flowers 941 Jan 03, 2023
Green is a clean, colorful, fast python test runner.

Green -- A clean, colorful, fast python test runner. Features Clean - Low redundancy in output. Result statistics for each test is vertically aligned.

Nathan Stocks 756 Dec 22, 2022
bulk upload files to libgen.lc (Selenium script)

LibgenBulkUpload bulk upload files to http://libgen.lc/librarian.php (Selenium script) Usage ./upload.py to_upload uploaded rejects So title and autho

8 Jul 07, 2022
A complete test automation tool

Golem - Test Automation Golem is a test framework and a complete tool for browser automation. Tests can be written with code in Python, codeless using

486 Dec 30, 2022
Language-agnostic HTTP API Testing Tool

Dredd — HTTP API Testing Framework Dredd is a language-agnostic command-line tool for validating API description document against backend implementati

Apiary 4k Jan 05, 2023
The successor to nose, based on unittest2

Welcome to nose2 nose2 is the successor to nose. It's unittest with plugins. nose2 is a new project and does not support all of the features of nose.

736 Dec 16, 2022
The evaluator covering all of the metrics required by tasks within the DUE Benchmark.

DUE Evaluator The repository contains the evaluator covering all of the metrics required by tasks within the DUE Benchmark, i.e., set-based F1 (for KI

DUE Benchmark 4 Jan 21, 2022
Kent - Fake Sentry server for local development, debugging, and integration testing

Kent is a service for debugging and integration testing Sentry.

Will Kahn-Greene 100 Dec 15, 2022
An AWS Pentesting tool that lets you use one-liner commands to backdoor an AWS account's resources with a rogue AWS account - or share the resources with the entire internet 😈

An AWS Pentesting tool that lets you use one-liner commands to backdoor an AWS account's resources with a rogue AWS account - or share the resources with the entire internet 😈

Brandon Galbraith 276 Mar 03, 2021
Divide full port scan results and use it for targeted Nmap runs

Divide Et Impera And Scan (and also merge the scan results) DivideAndScan is used to efficiently automate port scanning routine by splitting it into 3

snovvcrash 226 Dec 30, 2022
Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source.

Mockoon Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source. It has been built wi

mockoon 4.4k Dec 30, 2022
Public repo for automation scripts

Script_Quickies Public repo for automation scripts Dependencies Chrome webdriver .exe (make sure it matches the version of chrome you are using) Selen

CHR-onicles 1 Nov 04, 2021
Spam the buzzer and upgrade automatically - Selenium

CookieClicker Usage: Let's check your chrome navigator version : Consequently, you have to : download the right chromedriver in the follow link : http

Iliam Amara 1 Nov 22, 2021
A Django plugin for pytest.

Welcome to pytest-django! pytest-django allows you to test your Django project/applications with the pytest testing tool. Quick start / tutorial Chang

pytest-dev 1.1k Dec 31, 2022
Python Webscraping using Selenium

Web Scraping with Python and Selenium The code shows how to do web scraping using Python and Selenium. We use as data the https://sbot.org.br/localize

Luís Miguel Massih Pereira 1 Dec 01, 2021
Network automation lab using nornir, scrapli, and containerlab with Arista EOS

nornir-scrapli-eos-lab Network automation lab using nornir, scrapli, and containerlab with Arista EOS. Objectives Deploy base configs to 4xArista devi

Vireak Ouk 13 Jul 07, 2022