Skip to main content

A pytest plugin to report test results to tinybird

Project description

pytest-tinybird

A pytest plugin to report test results to Tinybird. At the end of every run, this plugin posts results using the Tinybird Events API.

PyPI version Passed Top test passed

Requirements

Installation

pypi install package: https://pypi.org/project/pytest-tinybird/

You can install the plugin with the following bash command:

  $ pip install pytest-tinybird

Usage

You just need your Tinybird account and a Token with append permissions

Set these env variables:

export TINYBIRD_URL=<https://api.tinybird.co|https://api.us-east.tinybird.co>   # depends on your region
export TINYBIRD_DATASOURCE=<datasource_name>  # will be created with first results posted
export TINYBIRD_TOKEN=<token_with_append_permissions>

Then run pytest with --report-to-tinybird.

$ pytest tests --report-to-tinybird

CI execution info can also be set using some env variables. These are from GitLab:

CI_COMMIT_SHA
CI_COMMIT_BRANCH
CI_JOB_ID
CI_JOB_NAME
CI_JOB_URL

If you are not using GitLab, you will need to set them manually. For instance, for GitHub actions you can check our current GitHub actions workflow.

Data Source details

The pytest-tinybird plugin creates and sends report objects via the Events API with this structure:

{
	'date': now,
	'commit': self.commit,
	'branch': self.branch,
	'job_id': self.job_id,
	'job_url': self.job_url,
	'job_name': self.job_name,
	'test_nodeid': test.nodeid,
	'test_name': test.head_line,
	'test_part': test.when,
	'duration': test.duration,
	'outcome': test.outcome
}

When a report object is first sent to Tinybird, a Data Source with the following definition and schema is created:

TOKEN "pytest-executor-write" APPEND

SCHEMA >
    `commit` String `json:$.commit`,
    `branch` String `json:$.branch`,
    `date` DateTime `json:$.date`,
    `duration` Float32 `json:$.duration`,
    `job_id` String `json:$.job_id`,
    `job_name` String `json:$.job_name`,
    `job_url` String `json:$.job_url`,
    `outcome` LowCardinality(String) `json:$.outcome`,
    `test_name` String `json:$.test_name`,
    `test_nodeid` String `json:$.test_nodeid`,
    `test_part` LowCardinality(String) `json:$.test_part`

ENGINE MergeTree
ENGINE_PARTITION_KEY toYYYYMM(date)

You can also see the Data Source schema with this data sample from an API Endpoint created from the Data Source the pytest-tinybird plugin populates.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_tinybird-0.3.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

pytest_tinybird-0.3.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file pytest_tinybird-0.3.0.tar.gz.

File metadata

  • Download URL: pytest_tinybird-0.3.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for pytest_tinybird-0.3.0.tar.gz
Algorithm Hash digest
SHA256 bbf5f6d3453c13af8413412585fc5bc3062c630762fdc03c3b2eb31ad597e7d4
MD5 44f5c4da72da33cc3a94e7994b03f4ca
BLAKE2b-256 004236a33bc6df217dfd05092ad797a06db77a6838a0abba78b0d9fa94a795ca

See more details on using hashes here.

File details

Details for the file pytest_tinybird-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_tinybird-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 539f23b4a55fff647ad9727cae41941bde8c958c4b305d57d4f47b06bdcf8868
MD5 80630bb938602be909e35b2aeaede9f6
BLAKE2b-256 a4f286065684bb62ee1f671e37e49c3fd904821656fe7339942847d71bcd5a28

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page