Skip to main content

snapline-core

Declarative test orchestration for Snapline — configure auth, API calls, and cross-system comparisons as data.

Install

pip install snapline-core

Quick start

import asyncio
from snapline.core import auth, test_suite

async def main():
    result = await test_suite("My API test", {
        "baseUrl": "https://api.example.com",
        "auth": auth.oauth2({
            "tokenUrl": "https://api.example.com/oauth/token",
            "clientId": "client-id",
            "clientSecret": "client-secret",
        }),
        "api": {
            "endpoint": "/users/me",
            "method": "GET",
            "expectedFile": "fixtures/expected.json",
            "ignoreFields": ["traceId"],
        },
    })
    print(result)

asyncio.run(main())

Fixture-case runners

import asyncio
from snapline.core import fixtures_dir, run_api_fixture_cases, resolve_report_config, write_test_report

async def main():
    result = await run_api_fixture_cases({
        "suiteName": "Customer account — GraphQL fixture cases",
        "fixturesRoot": str(fixtures_dir(__file__, {"relativePath": "fixtures"})),
        "baseUrl": "https://api.example.com",
        "defaults": {
            "endpoint": "/graphql",
            "protocol": "graphql",
            "dataPath": "customerAccount",
            "ignoreFields": ["metadata.traceId"],
        },
    })

    report_config = resolve_report_config({"defaultOutputPath": "./reports/run.json"})
    if report_config:
        write_test_report([result], report_config)

asyncio.run(main())

Database connections (DbConnectionLike)

Published snapline-core does not ship SQL drivers (runtime dependency: httpx only). Implement DbConnectionLike with your Postgres/MySQL client, or copy examples/in_memory_db.py for a minimal in-memory stub.

from snapline.core.types import DbConnectionLike

class AppDb(DbConnectionLike):
    async def query(self, sql: str, params: dict | None = None) -> list[dict]:
        # your driver here
        return rows

Demos use snapline.demo_shared for SQLite and stub postgres/mysql (create_sqlite_connection, seed_db).

Warehouse comparison (run_warehouse_comparison)

Chunked SQL → document-store consistency for data-warehouse ETL (26–30 tables in production). Streams a JSONL report so large datasets never load fully into memory.

import asyncio
from snapline.core import nosql, run_warehouse_comparison

async def main():
    # source_db: your Postgres/MySQL client implementing DbConnectionLike
    class SourceDb:
        async def query(self, sql, params=None):
            return [{"customerId": "1", "email": "alice@example.com", "status": "ACTIVE"}]

    result = await run_warehouse_comparison({
        "suiteName": "Warehouse sync",
        "sourceDb": SourceDb(),
        "targetDb": nosql.memory(),  # production: MongoDB DocumentStoreLike adapter
        "tables": [{
            "id": "wh_customers",
            "sourceQuery": "SELECT customer_id AS customerId, email, status FROM wh_customers",
            "targetCollection": "customers",
            "linkKeys": {"customerId": "customerId"},
            "dataMapping": {"status": {"ACTIVE": "ACTV"}},
        }],
        "chunkSize": 100,
        "maxRowsPerTable": 10_000,
        "maxTotalRows": 50_000,
        "report": {"outputPath": "./reports/warehouse.jsonl", "format": "jsonl"},
    })

asyncio.run(main())

See demo project-db for a full SQLite → in-memory example via snapline.demo_shared.

Documentation

https://vaagatech.github.io/snapline-python/

Repository: https://github.com/vaagatech/snapline-python

Download files

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

Source Distribution

snapline_core-0.2.1.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snapline_core-0.2.1-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

Details for the file snapline_core-0.2.1.tar.gz.

File metadata

  • Download URL: snapline_core-0.2.1.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for snapline_core-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3d6f771745ded7e074c8e0e766ae0a1c8d270fe080af24b749e28b77d8538f64
MD5 509058e5b1087e341da4e1dba63942a0
BLAKE2b-256 44809276d9203b34c84058f1c9bac2ba4259df0655c2a36b8d76f8c00a66f915

See more details on using hashes here.

File details

Details for the file snapline_core-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: snapline_core-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for snapline_core-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7309d5ff144964e0a2fa95e763628b4d9745a24fd6a83f037b94ccd4413bf691
MD5 8f3d24533cdc06ef606c2e78a96e29eb
BLAKE2b-256 3b96d3762757f2ecb65465093f50fe6ba4fdc2c373a06ab842eca84dbb978bc8

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.10

2 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