Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niedbalski/peewee-fake_fixtures
Fake fixtures generator for peewee
https://github.com/niedbalski/peewee-fake_fixtures
Last synced: about 1 month ago
JSON representation
Fake fixtures generator for peewee
- Host: GitHub
- URL: https://github.com/niedbalski/peewee-fake_fixtures
- Owner: niedbalski
- Created: 2013-06-25T14:18:56.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2019-03-14T17:53:27.000Z (almost 6 years ago)
- Last Synced: 2024-10-15T08:32:58.488Z (3 months ago)
- Language: Python
- Size: 7.81 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
peewee_fake_fixtures
====================Fake fixtures generator for peewee, it populates the models with
random data depending on the field type.Useful for auto-generate fixtures and other testing tools.
Usage
=====* Install from pip
```
pip install peewee-fake-fixtures
```Just load your model classes and call ``fake_fixture`` method to load
randomly auto-generate fixtures on the database```python
from model import User, Pet
added_objects = fake_fixture({
User,
field_name_map={
'name': 'fjl', "password": '123456'
}, #you can override default values
custom_field_type_map={
IntegerField: 100 # override default field,
},
Reservation: {
'status': ('PENDING', 'pending')
},
PhoneNumber: {
'status': ('CONFIRMED', 'confirmed'),
'value': faker.phoneNumber
}},
skip_id=True, #don't generate ID fields
on_failure=lambda x,y,z: fake_fixture_drop(z) #On failure callback
)
fake_fixture_drop(added_objects) #Remove fixtures from database```