Skip to main content

Reusable test data factory for CSV and FIDE XML archives.

Project description

sample_data_factory


Short description

sample_data_factory is a reusable Python helper for generating deterministic ZIP archives used in test flows, including URS CSV exports and FIDE players XML exports.


Module Overview

Key Features

  • Builds URS publication ZIP archives containing CSV payloads.
  • Builds FIDE players-list ZIP archives containing XML payloads.
  • Supports either local byte output or upload to Google Drive.
  • Can create nested Google Drive sub-folders when uploading files.
  • Includes unit tests for archive generation and constructor validation.

Project Structure

  • src/sdf/: Core package implementation (sample_data_factory.py).
  • tests/unit/: Unit tests for archive builders and helper methods.
  • scripts/: SQL/bootstrap assets (legacy resources have been removed).
  • legacy/: Archived resources excluded from normal test runs.
  • *.ps1: Environment and dependency setup scripts.

Getting Started

Prerequisites

  • Python 3.12+
  • Poetry

Setup

# 1) Generate .env values from environment variables
.\SetupDotEnv.ps1

# 2) Configure private Poetry sources when required
.\SetupPrivateRepoAccess.ps1

# 3) Optional: configure GitHub CLI access
.\SetupGitHubAccess.ps1

# 4) Install and sync project dependencies
.\InstallDevEnv.ps1

# 5) Run tests
poetry run pytest

Usage Example

from datetime import date

from sdf.sample_data_factory import SampleDataFactory

factory = SampleDataFactory(
    data_structure={
        "headers": ["PlayerID", "PlayerName"],
        "rows": [["1", "Player One"], ["2", "Player Two"]],
    },
    drive=None,
    file_prefix="Players",
    out_file_date=date(2026, 1, 1),
    target_folder_id=None,
    sub_folder_name=None,
)

archive_bytes = factory.build_urs_rating_pub_zip()

Common Commands

poetry install
poetry run pytest
poetry run pytest --cov=src --cov=tests --cov-report=term-missing
poetry run black src tests
poetry run isort src tests
poetry run flake8 src tests
poetry run pre-commit run --all-files

Automation Scripts

  • InstallPy.ps1: Bootstraps Python/Poetry setup.
  • InstallDevEnv.ps1: Installs development dependencies and pre-commit hooks.
  • SetupDotEnv.ps1: Generates .env from required environment variables.
  • SetupPrivateRepoAccess.ps1: Configures private package source credentials.
  • SetupGitHubAccess.ps1: Configures GitHub authentication for local automation.

Active Workflows

  • .github/workflows/py-temp-pr-pub-no_docker-def.yaml: Pull request validation workflow.
  • .github/workflows/py-temp-publish-pub-build_release_notify_after_merge-def.yaml: Post-merge release and publish workflow.

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

sample_data_factory-0.7.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

sample_data_factory-0.7.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file sample_data_factory-0.7.0.tar.gz.

File metadata

  • Download URL: sample_data_factory-0.7.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.12 Linux/6.14.0-1017-azure

File hashes

Hashes for sample_data_factory-0.7.0.tar.gz
Algorithm Hash digest
SHA256 62bc3970f03e3dbf4bf8b02aa07432d58cd77bb7e185f041bd3b2ed91c8479bd
MD5 a3be2099f30dea739064980d6ff82911
BLAKE2b-256 40cf4f6ebcc9e23548468baa0fa66e173bd6e0f3e74d2dd16070fbc3acc0b030

See more details on using hashes here.

File details

Details for the file sample_data_factory-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: sample_data_factory-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.12 Linux/6.14.0-1017-azure

File hashes

Hashes for sample_data_factory-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3c01da2b663aea16bc91ac3796e64d4ab08ef37e9690b30797eaa780028138a
MD5 cce8e291d9796d6b317c729328420a14
BLAKE2b-256 52d2a5561cf661a4a4bd991d954d2459f99c625af065b1a8c8e7f07653bc66c9

See more details on using hashes here.

Supported by

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