Comprehensive Bulgarian test data generator with valid checksums
Project description
bg-test-data
Comprehensive Bulgarian test data generator with valid checksums. Generate realistic EGN (national ID), EIK (company ID), IBAN, names, addresses, phone numbers, persons, and companies -- all with mathematically correct check digits.
Features
- EGN -- valid 10-digit personal identification numbers with correct checksum, gender, and birth date encoding
- EIK/BULSTAT -- valid 9- or 13-digit company identification numbers
- IBAN -- valid Bulgarian IBANs (BG prefix, real bank codes, correct mod-97 check digits)
- Names -- authentic Bulgarian first, middle, and last names in Cyrillic
- Addresses -- realistic Bulgarian addresses with city, street, and postal code
- Phone numbers -- Bulgarian mobile and landline numbers
- Persons -- complete person records combining EGN, name, address, phone, and IBAN
- Companies -- complete company records with EIK, name, address, phone, and IBAN
- Reproducible -- seed-based generation for deterministic test data
- Zero dependencies -- pure Python, nothing to install beyond the package itself
- Export -- built-in JSON and CSV serialization
- CLI -- command-line interface for quick data generation
Installation
pip install bg-test-data
Quick Start
Python API
from bg_test_data import BgTestData
bg = BgTestData(seed=42)
# Generate a complete person
person = bg.person()
# {
# "first_name": "Георги", "middle_name": "Иванов", "last_name": "Петров",
# "full_name": "Георги Иванов Петров",
# "gender": "male", "birth_date": "1975-09-18",
# "egn": "7524189245",
# "phone": "+359 88 123 4567",
# "email": "georgi.petrov@gmail.com",
# "address": {"street": "Витоша", "number": "15", "city": "София",
# "postal_code": "1000", "oblast": "София-град", "full_address": "..."}
# }
# Generate a company
company = bg.company()
# {
# "name": "Технологии ООД", "eik": "831650349", "vat_number": "BG831650349",
# "iban": "BG28UNCR70001522345678",
# "address": {...}, "phone": "+359 32 654 321",
# "manager": {<person dict>}
# }
# Generate individual data types
egn = bg.egn(gender="female")
eik = bg.eik(length=13)
iban = bg.iban()
phone = bg.phone(phone_type="mobile")
name = bg.name(gender="male")
address = bg.address()
Batch Generation
bg = BgTestData(seed=42)
persons = bg.persons(count=100)
companies = bg.companies(count=50)
Export
from bg_test_data import to_json, to_csv, to_csv_file
# JSON string
print(to_json(person))
# CSV string
print(to_csv(persons))
# Write CSV to file
to_csv_file(persons, "test_persons.csv")
CLI
# Generate a person (JSON output)
bg-test-data person
# Generate 10 persons as CSV
bg-test-data -n 10 -f csv person
# Generate an EGN for a female
bg-test-data egn --gender female
# Generate a company with a 13-digit EIK
bg-test-data company --eik-length 13
# Generate with a fixed seed for reproducibility
bg-test-data --seed 42 person
# Generate an IBAN
bg-test-data iban
# Generate a phone number
bg-test-data phone --type mobile
# Generate a name
bg-test-data name --gender male
# Generate an address
bg-test-data address --city Sofia
Data Types
| Type | Description | Example |
|---|---|---|
| EGN | 10-digit personal ID with valid checksum | 7524189245 |
| EIK | 9- or 13-digit company ID with valid checksum | 831650349 |
| IBAN | Bulgarian IBAN with valid mod-97 check | BG80BNBG96611020345678 |
| Name | First, middle, and last name in Cyrillic | Георги Иванов Петров |
| Address | City, street, postal code | София, ул. Витоша 15, 1000 |
| Phone | Mobile or landline number | +359 88 123 4567 |
| Person | Full person record (EGN + name + address + phone + IBAN) | see above |
| Company | Full company record (EIK + name + address + phone + IBAN) | see above |
API Reference
BgTestData class
| Method | Returns | Description |
|---|---|---|
egn(**kwargs) |
str |
Generate a valid EGN. Options: gender |
eik(**kwargs) |
str |
Generate a valid EIK. Options: length (9 or 13) |
iban(**kwargs) |
str |
Generate a valid Bulgarian IBAN |
phone(**kwargs) |
str |
Generate a phone number. Options: phone_type |
name(**kwargs) |
dict |
Generate a name. Options: gender |
address(**kwargs) |
dict |
Generate an address. Options: city |
person(**kwargs) |
dict |
Generate a full person. Options: gender, min_age, max_age |
company(**kwargs) |
dict |
Generate a full company. Options: eik_length |
persons(count, **kwargs) |
list[dict] |
Generate multiple persons |
companies(count, **kwargs) |
list[dict] |
Generate multiple companies |
Validation
| Function | Description |
|---|---|
validate_egn(egn) |
Returns True if the EGN has a valid checksum |
validate_eik(eik) |
Returns True if the EIK has a valid checksum |
validate_iban(iban) |
Returns True if the IBAN has a valid mod-97 check |
parse_egn(egn) |
Extract birth date, gender, and region from an EGN |
Export
| Function | Description |
|---|---|
to_json(data) |
Serialize to a JSON string |
to_csv(data) |
Serialize to a CSV string |
to_csv_file(data, path) |
Write CSV to a file |
to_dict(data) |
Identity normalizer (returns the same dict/list) |
Development
# Clone the repository
git clone https://github.com/Nikolay-Chillev/bg-test-data.git
cd bg-test-data
# Install dev dependencies
make install
# Run tests
make test
# Run tests with coverage
make coverage
# Run linter
make lint
# Format code
make format
# Type checking
make typecheck
Project Structure
bg-test-data/
src/
bg_test_data/
__init__.py # Public API exports
providers.py # BgTestData facade class
egn.py # EGN generator and validator
eik.py # EIK generator and validator
iban.py # IBAN generator and validator
names.py # Bulgarian name generator
address.py # Address generator
phone.py # Phone number generator
person.py # Person record generator
company.py # Company record generator
export.py # JSON/CSV export utilities
cli.py # Command-line interface
_random.py # Seeded random number generator
_data/ # Static data files (names, cities, etc.)
tests/ # Test suite
pyproject.toml # Project metadata and tool config
Makefile # Development shortcuts
LICENSE # MIT License
License
MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bg_test_data-0.1.0.tar.gz.
File metadata
- Download URL: bg_test_data-0.1.0.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d64d21ac013ec81d3e9b0bd89a5b4885b3d0486e662cba63142d77fc3440544b
|
|
| MD5 |
30ce18f7b9ab510fb7cf695acb437a7a
|
|
| BLAKE2b-256 |
de72cfc926ef022834769a315b57f9a2d1446e27d17f729cbe89de6adff01dc0
|
Provenance
The following attestation bundles were made for bg_test_data-0.1.0.tar.gz:
Publisher:
publish.yml on Nikolay-Chillev/bg-test-data
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bg_test_data-0.1.0.tar.gz -
Subject digest:
d64d21ac013ec81d3e9b0bd89a5b4885b3d0486e662cba63142d77fc3440544b - Sigstore transparency entry: 1185768486
- Sigstore integration time:
-
Permalink:
Nikolay-Chillev/bg-test-data@01ec934eb776fee0a64b09084e7bb44668db5b65 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Nikolay-Chillev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01ec934eb776fee0a64b09084e7bb44668db5b65 -
Trigger Event:
release
-
Statement type:
File details
Details for the file bg_test_data-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bg_test_data-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca712aad021065cfd32cfd3560b57d4c912d825919dff4fda2b48497f7374914
|
|
| MD5 |
e555bfe9662e73b3f92c727eb8578931
|
|
| BLAKE2b-256 |
1a176190f6ea22e3d10888c6fd7d3bc1faa75877f8f2c237c064f2fd5670a02c
|
Provenance
The following attestation bundles were made for bg_test_data-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Nikolay-Chillev/bg-test-data
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bg_test_data-0.1.0-py3-none-any.whl -
Subject digest:
ca712aad021065cfd32cfd3560b57d4c912d825919dff4fda2b48497f7374914 - Sigstore transparency entry: 1185768489
- Sigstore integration time:
-
Permalink:
Nikolay-Chillev/bg-test-data@01ec934eb776fee0a64b09084e7bb44668db5b65 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Nikolay-Chillev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01ec934eb776fee0a64b09084e7bb44668db5b65 -
Trigger Event:
release
-
Statement type: