Skip to main content

bg-test-data

CI PyPI License: MIT

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, postal code, oblast and its ISO 3166-2 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": "София-град", "oblast_code": "BG-22",
#               "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()

Oblasts and ISO 3166-2 codes

E-commerce platforms such as Magento identify Bulgarian regions by their ISO 3166-2 code, not by the Bulgarian name. Every address includes oblast_code, and you can filter by it:

bg.address(oblast_code="BG-02")
# {"city": "Бургас", "oblast": "Бургас", "oblast_code": "BG-02", ...}

bg.oblasts()
# [{"name": "Благоевград", "code": "BG-01"}, ..., {"name": "Ямбол", "code": "BG-28"}]

Note that "София" is Sofia Province (BG-23); the capital is "София-град" (BG-22).

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

# Generate an address in Sofia City
bg-test-data address --oblast-code BG-22

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, oblast and ISO 3166-2 code София, ул. Витоша 15, 1000 (BG-22)
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, oblast, oblast_code
oblasts() list[dict] All 28 oblasts with name and ISO 3166-2 code
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.

Metadata

Release files for bg-test-data 0.2.0

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

Source distribution (sdist)

Source distribution for bg-test-data 0.2.0
File Size Uploaded
bg_test_data-0.2.0.tar.gz 32.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bg-test-data 0.2.0
File Interpreter ABI Platform
bg_test_data-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 61.8 kB

Release files / bg_test_data-0.2.0.tar.gz

Download URL bg_test_data-0.2.0.tar.gz
Size 32.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fbf7998ed0e71c8ebf9146cca834bd673b5d0a5d2b6dfb8ab9d0ff0c7d2e4f8d
BLAKE2b-256 checksum
How to use checksums
669866583431c4701f230364b0eb1c212f19d4a3e1ce3bf0daba81f6d711887b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / bg_test_data-0.2.0-py3-none-any.whl

Download URL bg_test_data-0.2.0-py3-none-any.whl
Size 29.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe0276647c61c6825cb76b76f6a398b7d656c2dcc8a113d04df4ee86e9c62390
BLAKE2b-256 checksum
How to use checksums
efd1759e54c6a0a651d904bed16d16592bea222f4dfb24390936ec6eef6019b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release 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