Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Full Clean Factories

Full Clean Factories

Researching the model instance factories available for Django and how well they create valid objects for our tests.

In this talk I present my research into various Django factories. Full write-up is available at http://jamescooke.info/django-factory-audit.html

Avatar for James Cooke

James Cooke

October 11, 2016
Tweet

More Decks by James Cooke

Other Decks in Programming

Transcript

  1. Full Clean Factories James Cooke Licensed under the Creative Commons

    Attribution-ShareAlike 3.0 Unported License.
  2. Factories • Django Fakery • Factory Boy • Factory Djoy

    • Hypothesis[django] • Mixer • Model Mommy
  3. Grading factories: Test • Two models: User and Item •

    Two factories: UserFactory and ItemFactory • Create 10 instances class Item(models.Model): name = models.CharField( max_length=1, unique=True)
  4. Grading factories: Grades • RED: Creates invalid instances • YELLOW:

    Raises exception • GREEN: Creates valid instances
  5. Factories Factory ItemFactory UserFactory Django Fakery RED YELLOW Factory Boy

    RED RED Factory Djoy YELLOW GREEN Hypothesis[django] RED RED Mixer GREEN GREEN Model Mommy YELLOW GREEN
  6. Final points • Factories are made of two parts •

    Hypothesis could win • Test code on GitHub: https://github.com/jamescooke/factory_audit/ • Full write-up tomorrow http://jamescooke.info/
  7. Thanks! • @jamesfublo • Ask questions • Let’s talk more

    about testing • Thanks for listening! Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.