Skip to content

Releases: Scarvy/mockaroo-python

v3.0.0

17 Apr 05:04
Compare
Choose a tag to compare

v3.0.0

New release with some major changes and fixes.

Breaking Change

  • Renamed API variable from API_KEY to MOCKAROO_API_KEY

Changed

  • Using poetry for package management
  • Shortened click command generate to gen

Fixed

  • Can now generate xml and sql mock data. Discussion here
  • Issue with POST request in upload method sending weird data with file. Pointed out in the community form 🙏

Release v2.0.0

18 Oct 03:01
Compare
Choose a tag to compare

New

  • ✨ New CLI using 🌈 rich-click to easily execute Mockaroo API commands in the terminal:
    • types - See list of Mockaroo data types in a rich styled table
    • upload and delete - 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

15 Oct 23:09
Compare
Choose a tag to compare

Added

  • Add an attribute last_response to the Client 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 for api_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 preventing MockarooExceptions from being raised properly.

Fixed

  • Fix __htttp_request not raising MockarooExceptions.
  • 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

12 Oct 01:05
Compare
Choose a tag to compare

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.