This is a collection of sample code and directions for creating plugins and providers for Snowfakery.
Please Note: This does not work yet!
- Python 3 (generally recent-ish version)
- Snowfakery 1.4 or later
- Faker module for python (
pip3 install Faker
)- A Faker sample community provider like Microservice:
pip3 install faker-microservice
- A Faker sample community provider like Microservice:
- A recipe to work from (see recipes folder).
- Create a directory in your project to hold whatever providers you want to create, in my case
providers
. - Create a file named
__init__.py
in that directory to make a package. - Create directory for your new provider with the pattern
faker_[my_service_name]
, in my casefaker_nonprofit
. - In the directory create a file named
__init__.py
this defines the module. - Create your provider in that file (see example for details):
import faker.providers
to make sure you have required classes.- Define a series of dictionaries for providers creating text.
- Create a class that extends the base:
class Provider(faker.providers.BaseProvider):
- Define a method that returns the desired values:
def nonprofit_name(self):
- Add tests to make sure it works cause it helps keep life easy (see example):
$ python -m providers.test
- Open the basic recipe you want to use for testing (start with something simple you already know how to use).
- Add a new line at the top to load the new plugin:
- plugin: providers.faker_nonprofit
- Add/Update a field to use the new provider.