Using BFET with Django

Two of the modules more usefull for Django are DjangoTestingModel and DataCreator.


DataCreator - Use different modules included with python like datetime to create values

  1. Import from the bfet library DataCreator:

    from bfet import DataCreator
  2. Once imported you can use the different methods of DataCreator to cerate values:

    string = DataCreator.create_random_string()
    dict = DataCreator.create_random_json()
    email_string = DataCreator.create_random_email()
    datetime = DataCreator.create_random_datetime()


DjangoTestingModel - Is based on the Django _default_manager’s methods create, bulk_create and get_or_create

To use this with your project you need to follow these steps:

  1. Import from the bfet library DjangoTestingModel:

    from bfet import DjangoTestingModel
  2. Once imported you can start to create models for testing:

    from foo.models import BarModel
    bar_model = DjangoTestingModel.create(BarModel)

You can either include manually the fields with the values or let bfet create the values randomly. Under the hood DjangoTestingModel uses DataCreator to populate the values for the fields.