Skip to main content

Comprehensive realistic data generation library for testing and development

Project description

MockPy

🚀 Comprehensive Realistic Data Generation Library

PyPI version Python versions License

MockPy is a Python library for generating realistic and comprehensive mock data for testing, development, and demonstration purposes.

🌟 Features

  • 📊 Realistic Data: Based on real-world distributions
  • 🔄 Cross-Data Consistency: Related data fields maintain logical relationships
  • 🧩 Easy-to-Use API: Intuitive design for developer productivity
  • 🔌 Framework Integration: Works with Django, Flask, FastAPI, SQLAlchemy
  • 🚀 Performance Optimized: Fast generation with minimal resource usage
  • 🌍 Multi-Language Support: Built-in support for English and Turkish with translation capabilities

📦 Installation

pip install python-mockpy

🚀 Quick Start

from mockpy import MockPy

# Initialize the library
mock = MockPy(locale="en_US")

# Generate a person
person = mock.person.person()
print(f"Hello, my name is {person.full_name}")

# Generate an address
address = mock.address.address()
print(f"My address: {address.street}, {address.city}")

# Generate credit card
credit_card = mock.finance.credit_card()
print(f"My card: {credit_card.formatted_number}")

📋 Data Types

MockPy can generate a wide variety of data:

  • 👤 Personal Information: Names, addresses, phone numbers, emails
  • 💼 Business Data: Company names, job titles, departments
  • 💰 Financial Data: Bank accounts, credit cards, IBAN numbers
  • 🌐 Internet: URLs, IP addresses, usernames
  • 🏥 Healthcare: Patient records, diagnoses, medication names
  • 🗺️ Geographic: GPS coordinates, countries, cities
  • 🛒 E-commerce: Products, prices, orders
  • 📚 Education: Schools, courses, grades

And many more!

🛠️ Advanced Usage

Schema-Based Data Generation

schema = {
    "id": {"type": "integer", "min": 1000, "max": 9999},
    "user": "person.person",
    "subscription": {
        "plan": {"type": "choice", "choices": ["Basic", "Premium", "Enterprise"]},
        "start_date": {"type": "date", "start": "2022-01-01", "end": "2023-01-01"},
        "price": {"type": "float", "min": 9.99, "max": 99.99, "precision": 2},
    }
}

# Generate 100 records
dataset = mock.generate_dataset(schema, count=100)

JSON Schema/OpenAPI Integration

# Generate data from JSON Schema
from mockpy.integrations import from_json_schema

schema_file = "user_schema.json"
users = from_json_schema(schema_file, count=50)

Django Integration

from mockpy.integrations.django import generate_model_instances
from myapp.models import User

# Create 10 instances of your Django model
users = generate_model_instances(User, count=10)

🌍 Multi-Language Support

# English data generation
en_mock = MockPy(locale="en_US")
en_person = en_mock.person.person()

# Turkish data generation
tr_mock = MockPy(locale="tr_TR")
tr_person = tr_mock.person.person()

# Other languages (requires 'translators' package)
fr_mock = MockPy(locale="fr_FR")
fr_person = fr_mock.person.person()

🧪 Testing Use Cases

def test_user_registration():
    mock = MockPy()
    test_user = mock.person.person()
    
    response = client.post('/register', data={
        'email': test_user.email,
        'name': test_user.full_name,
        'phone': test_user.phone
    })
    
    assert response.status_code == 200

🔧 Performance Considerations

MockPy is designed to be fast and resource-efficient:

  • No external dependencies required for core functionality
  • Minimal memory footprint
  • Optimized for bulk data generation
  • Smart caching for frequently used data

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

Distributed under the MIT License. See LICENSE for more information.

💬 Contact

Project Link: https://github.com/burakozcn01/mockpy

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

python_mockpy-1.0.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

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

python_mockpy-1.0-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file python_mockpy-1.0.tar.gz.

File metadata

  • Download URL: python_mockpy-1.0.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for python_mockpy-1.0.tar.gz
Algorithm Hash digest
SHA256 c6153121bcb4048bc84d9980878dff15cf660a61257e527c94da297c22d62a8b
MD5 80a4b07318f8edfa3526324d8e9051ff
BLAKE2b-256 514727cfe9238a3d6d278ac1f41ce36ef873ebf97121d3ae234855393c03b992

See more details on using hashes here.

File details

Details for the file python_mockpy-1.0-py3-none-any.whl.

File metadata

  • Download URL: python_mockpy-1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for python_mockpy-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 161dcffbc0dd781b4cfa4b43d32f7edc0d524f9fb3ef6eb118940e5126c0873b
MD5 735baf43c2cf733485a5d23de3af6389
BLAKE2b-256 fa379f3ca70b39db4de37156c78c2ad1201f5931321fbf1658d3d35c5d288067

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