Releases: Scarvy/mockaroo-python
v3.0.0
v3.0.0
New release with some major changes and fixes.
Breaking Change
- Renamed API variable from
API_KEY
toMOCKAROO_API_KEY
Changed
- Using
poetry
for package management - Shortened
click
commandgenerate
togen
Fixed
Release v2.0.0
New
- ✨ New CLI using 🌈
rich-click
to easily execute Mockaroo API commands in the terminal:types
- See list of Mockaroo data types in arich
styled tableupload
anddelete
- datasets from Mockaroo 🦘
Added
- Additional unit tests for increase code coverage to ~98% 💪
Changed
- Switch linter to
ruff
Fixed
- Fix
types
method "Returns" docstring - Fix
types
method unit test
Release v1.1.0
Added
-
Add an attribute
last_response
to theClient
class. Help diagnose client requests to the API.-
self.last_reponse = { "method": method, "url": url, "request": kwargs, "error": None, }
-
-
Add two new unit tests for the
generate
method. Test for different formats (eg. ‘csv’, ‘txt’). -
Add more parameters to
test_get_url
. -
Add unit test
test_warning_for_no_api_key
forapi_key
property -
Add more detail to the "Usage" section of the README
Removed
- Remove the
count
key in the_get_url
method. - Remove
raise_for_status
function in__http_request
method. The function was preventingMockarooExceptions
from being raised properly.
Fixed
- Fix
__htttp_request
not raisingMockarooExceptions
. - Fix the mistake in the
generate
method when returning JSON data. Keyword argument using the wrong key “fields” instead of “fmt”.
Release v1.0.0
Mockaroo-Python v1.0.0 🦘+ 🐍
🎉 Initial Release 🎉
This Python package is designed to simplify your interactions with Mockaroo APIs, streamlining how you work with mock data.
Features
Retrieve Data Types
Use the types()
method to list all supported data types by Mockaroo.
# import package
from mockaroo import Client
# Pass your API key to the class
client = Client(api_key='YOUR_API_KEY')
# Or set an enviornment variable. `export API_KEY=your_api_key_here`
client = Client()
types = client.types()
List of available types here
Upload Datasets to Mockaroo
With the upload()
function, you can easily upload datasets to Mockaroo for later use.
result = client.upload(name='users', path='path/to/users_dataset.csv')
print(result)
{'success', True}
Remove Datasets from Mockaroo
You can also remove datasets that you've uploaded to Mockaroo using the delete()
function.
result = client.delete(name='users')
print(result)
{'success', True}
Generate Datasets
Generate mock datasets either with predefined schemas or with custom fields using the generate()
function.
# Using predefined schema
predefined_data = client.generate(schema='your_predefined_schema')
# Using custom fields
result = client.generate(
count=3,
fields=[
{"name": "id", "type": "Row Number"},
{"name": "first_name", "type": "First Name"},
{"name": "last_name", "type": "Last Name"},
{
"name": "job_title",
"type": "Custom List",
"values": ["Manager", "Instructor", "Helper"],
},
],
)
print(result)
[
{
'id': 1,
'first_name': 'Blondie',
'last_name': 'Elbourne',
'job_title': 'Helper'
},
{
'id': 2,
'first_name': 'Ferdinanda',
'last_name': 'Letherbury',
'job_title': 'Instructor'
},
{
'id': 3,
'first_name': 'Thomas',
'last_name': 'Wallen',
'job_title': 'Helper'
}
]
Installation
To install, you can use pip:
pip install mockaroo-python
Contributions
I welcome contributions from the community. If you'd like to contribute, please feel free to submit a pull request.
License
This project is licensed under the MIT License.