Sable is a testing tool for SQL.
Project description
Sable
Sable is a testing tool for SQL, which is committed to providing a simple and user-friendly solution for testing SQL queries.
By design, the user would specify his/her test cases in an easy-to-read YAML file, and sable
will run those test cases and generate a report.
For example, given a test file under the demo folder named test_find_email.yaml, the user should be able to use sable demo/test_find_email.yaml
to run tests and get results printed in the console.
Please note that the sable project is still in the planning stage and interfaces may be changed in the future.
Test Case Defination
Test Suite
Each YAML document will be considered as a test suite. It should be an associative array that contains at least version
, suite
, cases
as keys.
- The value in
version
is referring to the version of test define schema. - The value in
suite
is the name of this test suite. - The value in
cases
should be a list of test cases.
Test Case
The test case is also been defined in an associative array. It is mandatory to include uid
, sql
and exp
, and other keys are optional: msg
, var
, env
.
uid
Unique Identifier (uid) is the key that will show in the final result and it helps the user quickly find the test case definition in files.
msg
Message (msg) will show to the user when the test cases if failed.
sql
SQL query or SQL query template which will be executed for testing.
It is a good practice to split the code and the tests. So, sable allows users to define SQL query in a separate file and use !file
followed by file path to identify the file.
For example, given a SQL stored in find_email.sql under the same folder demo with the test definition YAML, the test case can be written as:
sql: !file find_email.sql
var
If using a template in SQL, this is the place to set the actual value.
For example:
Given a SQL query template:
SELECT ${x} + ${y}
When specifying var
as the following:
var:
x: 1
y: 2
The SQL be executed will become:
SELECT 1 + 2
env
The pre-defined environment before executing SQL query. It should be a list of associative arrays. Each member in the list represents a table, which should contain a DDL in metadata
and tabulation-like data in records
.
To give tabulation-like data in YAML, users can use !fwf
and !csv
.
For example:
records: !fwf |
user_id first_name last_name
1 Jack Ma
2 Tony Ma
3 Robin Li
records: !csv |
user_id,email
1,jack_ma@alibaba.com
2,tony_ma@qq.com
6,robin_li@baidu.com
exp
Expected result (exp) defines where
to inspect and what records
should the program expected to see.
For example:
where: result set
records: !fwf |
mail
jack_ma@alibaba.com
tony_ma@qq.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sable-0.0.1.tar.gz
.
File metadata
- Download URL: sable-0.0.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44c4c8a2eb516875df45ab566cb348fd7d2ef53bdf0f5b11aff5d84330c6db28 |
|
MD5 | 5aefaf5905aae35f87b6a58a514c6017 |
|
BLAKE2b-256 | 8f551eb73b086328de7faf40bbbfa6f303a7e2425a0c1b268b9d75b4568df599 |
File details
Details for the file sable-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: sable-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3345578cc26921a9f4bb313f189e9d5c857df164d1614db3bab954cf70af7cc4 |
|
MD5 | 556ed80801a78148afdbed45e4b356de |
|
BLAKE2b-256 | 6bc64d43a3fd58d125af8b819b88eea1c763d637d66871944d6fcbe26ca7577b |