Skip to main content

dtest

CircleCI Requirements Status

A library to facilitate the testing of data inside data pipelines. Results are pushed to a messaging queue of some sort for consumption by applications, persistence, etc.

Supported messaging queues / streaming platforms

  • RabbitMQ
  • MQTT
  • Redis
  • Kafka
  • Kinesis

Supported secrets managers

  • AWS Secrets Manager
  • Hashicorp Vault

Installation

pip3 install dtest-framework

Unit Tests

Testing is set up using Pytest

Install Pytest with pip3 install -U pytest

Run the tests with pytest in the root directory.

Quick Start

from dtest.dtest import Dtest
from hamcrest import *


# If publishing to a RabbitMQ queue, specify 'queue' \
# If publishing to a key-value store, specify 'kv-store' \
# Or specify both

connectionConfig = {
    "queue": {
        "host": "localhost",
        "username": "guest",
        "password": "guest",
        "exchange": "test.dtest",
        "exchange_type": "fanout"
    },
    "kv-store": {
        "api_url": "localhost:8080/api/",
        "retrieve_path": "getKeyValue/",
        "publish_path": "postKeyValue/"
    }
}
metadata = {
    "description": "This is a test of the assertCondition",
    "topic": "test.dtest",
    "ruleSet": "Testing some random data",
    "dataSet": "random_data_set_123912731.csv"
}

dt = Dtest(connectionConfig, metadata)

dsQubert = [0,1]

dt.assert_that(dsQubert, has_length(2))
// True

dt.publish()
// Publishes test suite to MQ server


////////////////////////////////////////
// Store value in KV store for later use
dt.publishKeyValue('some-descriptor-dsQubert-length', len(dqQubert))

// Retrieve value from KV store to compare other files against
count = dt.retrieveKeyValue('some-descriptor-dsQubert-length')

dt.assert_that(dsQubert, has_length(count))

Connection configuration

There are two options for providing the connection configuration for the publisher - the default way described above and by storing your configuration in a secrets manager. To utilize a secrets manager, use a connectionConfig similar to:

connectionConfig = {
    "queue": {
        "vault": {
                    "provider": "aws_secrets_manager",
                    "secret_name": "secret_name_here",
                    "region": "us-east-1"
                }
    }
}

Here we are giving the provider name aws_secrets_manager, the key to use to retrieve the secret secret_name, and the region in which Secrets Manager is hosted. secret_name and region are passed to boto3 directly. region_name is provided when initializing the boto3 session and secret_name is provided to the boto3.secretsmanager.get_secret_value() function as SecretId.

Custom handlers

It is possible to create custom message queue and key value store handlers. Implement a class that inherits from dtest.handler.MqHandler or dtest.handler.KvHandler depending on your needs.


class MqHandler:

    @classmethod
    def version(self): return "1.0"

    @abstractmethod
    def connect(self): raise NotImplementedError

    @abstractmethod
    def publishResults(self): raise NotImplementedError

    @abstractmethod
    def closeConnection(self): raise NotImplementedError


class KvHandler:

    @classmethod
    def version(self): return "1.0"

    @abstractmethod
    def retrieve(self): raise NotImplementedError

    @abstractmethod
    def publish(self): raise NotImplementedError

Package dependencies

I did not want to require that all dependencies of every module need to be installed. As such, the following packages need to be installed via pip if you would like to utilize the specified functionality

Package Dependent module/functionality
pandas Local testing with pytest

CI/CD

  • Use the standard ecs labeled Jenkins agent
  • Performs tests on master commits and PRs
  • Does not deploy to PyPI automatically

Metadata

Release files for dtest-framework 0.1.23

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

Source distribution (sdist)

Source distribution for dtest-framework 0.1.23
File Size Uploaded Provenance Actions
dtest-framework-0.1.23.tar.gz 11.2 kB Without provenance Details for dtest-framework-0.1.23.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dtest-framework 0.1.23
File Interpreter ABI Platform Actions
dtest_framework-0.1.23-py3-none-any.whl Python 3 none any Details for dtest_framework-0.1.23-py3-none-any.whl

Total release size: 23.9 kB

Release files / dtest-framework-0.1.23.tar.gz

Download URL dtest-framework-0.1.23.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
59b073ed1cdbd96112c0a50385cf0389e411649e8c33bd579c615f124ffaab93
BLAKE2b-256 checksum
How to use checksums
af5396296b69a9e8104f2ef05121469fcdce14c2e6ca2e5e2295ad51c6d87561
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release files / dtest_framework-0.1.23-py3-none-any.whl

Download URL dtest_framework-0.1.23-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17bf678f56b53ef479b1921e883fbe9ff9d9f6d5e7d18a63d9c4eb6ca2fff085
BLAKE2b-256 checksum
How to use checksums
f803d871cc6925d7459be429db721c1b607a918b06668de27aea8a6a3aae9c9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Security for dtest-framework 0.1.23

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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