Utility to generate test queries

Usage

python -m nsaph.dbt.create_test [-h] –script SCRIPT [SCRIPT …]

[–autocommit] [–db DB] [–connection CONNECTION] [–verbose] [–table TABLE]

Options:
-h, --help

show this help message and exit

–script SCRIPT [SCRIPT …], -s SCRIPT [SCRIPT …]

Path to the file(s) containing test scripts. When generating test, the file is used to output the script, while when running the tests, the scripts from the specified files are executed

--autocommit

Use autocommit, default: False

--db DB, --database DB

Path to a database connection parameters file, default: database.ini

--connection CONNECTION, --connection_name CONNECTION

Section in the database connection parameters file, default: nsaph2

--verbose

Verbose output, default: False

--table TABLE, -t TABLE

Name of the table to manipulate, default: None

Details

A utility to generate a test based on a sample table.

The tool introspects a table, given as an input and generates a set of queries each of which tests that the data in a certain column has not changed.

The queries are output into a file that can be executed as a single SQL query producing a table with the following columns:

  1. Name of the column being tested

2. What value is being tested not to change: MD5 hash, number of distinct records, mean value or variance 3. Whether the value has changed (indicated by string failed) or remained the same (indicated by string passed)

Individual queries are separated by a comment strings:

  • – Test case end

  • – Test case start

so a test runner can execute them individually if desired

class CType(value)[source]

An enumeration.

categorical = 'categorical'
text = 'text'
integral = 'integral'
numeric = 'numeric'
date = 'date'
class Column(name: str, ctype: CType, is_indexed: bool)[source]
class TableFingerprint(context: Optional[DBTConfig] = None)[source]
CATEGORICAL_THRESHOLD = 24
get_columns()[source]
get_categories() List[Column][source]
generate_tests()[source]
test_column(c: Column)[source]
test_case_sql(name: str, test: str, condition: str) str[source]
test_exact(sql: str, name: str, test: str) str[source]
test_approximate(sql: str, name: str, test: str) str[source]
union()[source]
write_test_script()[source]