Skip to main content

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

Metadata

Release files for sable 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sable 0.0.1
File Size Uploaded
sable-0.0.1.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sable 0.0.1
File Interpreter ABI Platform
sable-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.2 kB

Release files / sable-0.0.1.tar.gz

Download URL sable-0.0.1.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
44c4c8a2eb516875df45ab566cb348fd7d2ef53bdf0f5b11aff5d84330c6db28
BLAKE2b-256 checksum
How to use checksums
8f551eb73b086328de7faf40bbbfa6f303a7e2425a0c1b268b9d75b4568df599
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sable-0.0.1-py3-none-any.whl

Download URL sable-0.0.1-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3345578cc26921a9f4bb313f189e9d5c857df164d1614db3bab954cf70af7cc4
BLAKE2b-256 checksum
How to use checksums
6bc64d43a3fd58d125af8b819b88eea1c763d637d66871944d6fcbe26ca7577b
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page