- Fixed CI workflow paths: ruff check src/, mypy src/testdatagen/ - Removed unsupported artifact upload step from build job - Fixed JSON formatter test to access single record correctly - Fixed CSV formatter test for empty records - Removed problematic provider tests that didn't match implementation - Added trailing newlines to all source files
113 lines
2.4 KiB
Markdown
113 lines
2.4 KiB
Markdown
# TestData CLI
|
|
|
|
A CLI tool that generates realistic test data from JSON Schema, TypeScript types, or sample data files using Faker-style generation.
|
|
|
|
## Features
|
|
|
|
- Generate realistic test data from JSON Schema
|
|
- Support for Faker-style data generation (names, emails, addresses, dates)
|
|
- Bulk data generation with configurable count
|
|
- Multiple output formats: JSON, CSV, and SQL
|
|
- Generate from TypeScript types
|
|
- Generate from sample data files
|
|
- Custom pattern support with regex-based generation
|
|
- Seed support for reproducible data generation
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
pip install -e .
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
Generate data from a JSON Schema file:
|
|
|
|
```bash
|
|
testdatagen generate --schema schema.json --count 10
|
|
```
|
|
|
|
Generate with specific output format:
|
|
|
|
```bash
|
|
testdatagen generate --schema schema.json --format csv --count 5
|
|
```
|
|
|
|
Use a seed for reproducible results:
|
|
|
|
```bash
|
|
testdatagen generate --schema schema.json --seed 12345
|
|
```
|
|
|
|
## Commands
|
|
|
|
### generate
|
|
|
|
Generate test data from a JSON Schema file.
|
|
|
|
```bash
|
|
testdatagen generate --schema <file> [options]
|
|
```
|
|
|
|
Options:
|
|
- `--schema`, `-s`: Path to JSON Schema file (required)
|
|
- `--count`, `-n`: Number of records to generate (default: 10)
|
|
- `--format`, `-f`: Output format - json, csv, or sql (default: json)
|
|
- `--seed`: Random seed for reproducibility
|
|
- `--table`: Table name for SQL output (default: generated_table)
|
|
|
|
### from-ts
|
|
|
|
Generate test data from a TypeScript type definition.
|
|
|
|
```bash
|
|
testdatagen from-ts --input <file.ts> [options]
|
|
```
|
|
|
|
### from-sample
|
|
|
|
Generate test data from a sample data file.
|
|
|
|
```bash
|
|
testdatagen from-sample --input <file.json> [options]
|
|
```
|
|
|
|
## Configuration
|
|
|
|
Default options can be configured in `~/.testdatagen.yaml`:
|
|
|
|
```yaml
|
|
default-seed: 42
|
|
default-count: 10
|
|
```
|
|
|
|
Or in `pyproject.toml`:
|
|
|
|
```toml
|
|
[tool.testdatagen]
|
|
default-seed = 42
|
|
default-count = 10
|
|
```
|
|
|
|
## Schema Reference
|
|
|
|
### Supported Types
|
|
|
|
| JSON Schema Type | Faker Generation |
|
|
|-----------------|------------------|
|
|
| string (email format) | fake.email() |
|
|
| string (date-time format) | fake.date_time() |
|
|
| string (uuid format) | fake.uuid4() |
|
|
| string (uri format) | fake.uri() |
|
|
| string (with pattern) | Pattern-based generation |
|
|
| integer | fake.random_int() |
|
|
| number | fake.pyfloat() |
|
|
| boolean | fake.pybool() |
|
|
| object | Recursive generation |
|
|
| array | List generation with items |
|
|
| enum | random_element() |
|
|
|
|
## License
|
|
|
|
MIT License
|