Melhorando Testes No Django Com O Model Mommy

B
Bernardo FontesSoftware Developer at Innvent
Melhores Testes no Django
Apresentado o Model Mommy
Bernardo Fontes
@bbfontes
@bbfontes – bernardofontes.net – falecomigo@bernardofontes.net
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Por que testar?
https://github.com/MrMEEE/bumblebee-Old-and-abbandoned/comm
it/a047be85247755cdbe0acce6f1dafc8beb84f2ac
Organização básica de um
método de teste
1 – Configuração inicial
do cenário de teste
2 – Chamada para execução
da feature
3 – Asserções sobre os
valores retornados
Tópico do dia: configuração
inicial do cenário de teste
com a criação de modelos
no Django
Criação dos objetos na mão
com o método create
Uso de fixtures para
popular o banco previamente
Model Mommy
https://github.com/vandersonmota/model_mommy
pip install model_mommy
https://pypi.python.org/pypi/model_mommy
API para criar instâncias
de models de maneira rápida
baseada em valores
aleatórios
Model core.Person
Método make básico
Método make básico
Método make com
sobreescrita
Método prepare
Criando vários objetos
Model core.Dog
Método make para FK
Método make com
sobreescrita de FK
Método make com FK lookup
Método prepare com FK
Model core.Store
Objetos com relações
ManyToMany
API para criar instâncias
de models de maneira rápida
baseada em valores
definidos por você
evitando repetição de
código
mommy_recipes.py da app
Definição de um Recipe
Criando objetos com o
make_recipe
Sobreescrita com o
make_recipe
Vários objetos com o
make_recipe
Sem persistência com o
prepare_recipe
Recipes com FK
Recipes com callables
Suporte a Custom Fields
Sequences para campos
unique
Ajude-nos a matar todas as
issues!!!
Dê sua opinião e mande
dúvidas da lista
http://bit.ly/12MU9Pv
Melhorando Testes No Django Com O Model Mommy
Obrigado!!!
Bernardo Fontes
falecomigo@bernardofontes.net
http://bernardofontes.net
http://github.com/berinhard
http://twitter.com/bbfontes
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
Melhorando Testes No Django Com O Model Mommy
1 of 69

Recommended

Flask e a sua primeira app web com python! by
Flask e a sua primeira app web com python!Flask e a sua primeira app web com python!
Flask e a sua primeira app web com python!Ana Paula Gomes
589 views19 slides
BigData - ElasticSearch + PHP by
BigData - ElasticSearch + PHPBigData - ElasticSearch + PHP
BigData - ElasticSearch + PHPFelipe Weckx
1.4K views22 slides
Customizando Admin do Django by
Customizando Admin do DjangoCustomizando Admin do Django
Customizando Admin do DjangoGustavo Carvalho
6.9K views35 slides
Testes pythonicos com pytest by
Testes pythonicos com pytestTestes pythonicos com pytest
Testes pythonicos com pytestviniciusban
5.1K views13 slides
Tdd Com Mock e Orientação a Objetos (PyNE 2015) by
Tdd Com Mock e Orientação a Objetos (PyNE 2015)Tdd Com Mock e Orientação a Objetos (PyNE 2015)
Tdd Com Mock e Orientação a Objetos (PyNE 2015)Bernardo Fontes
894 views47 slides
Crawleando a web feito gente grande com o scrapy by
Crawleando a web feito gente grande com o scrapyCrawleando a web feito gente grande com o scrapy
Crawleando a web feito gente grande com o scrapyBernardo Fontes
6.3K views45 slides

More Related Content

Featured

ChatGPT and the Future of Work - Clark Boyd by
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
23.4K views69 slides
Getting into the tech field. what next by
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
5.6K views22 slides
Google's Just Not That Into You: Understanding Core Updates & Search Intent by
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
6.3K views99 slides
How to have difficult conversations by
How to have difficult conversations How to have difficult conversations
How to have difficult conversations Rajiv Jayarajah, MAppComm, ACC
4.9K views19 slides
Introduction to Data Science by
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data ScienceChristy Abraham Joy
82.2K views51 slides
Time Management & Productivity - Best Practices by
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
169.7K views42 slides

Featured(20)

ChatGPT and the Future of Work - Clark Boyd by Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd23.4K views
Getting into the tech field. what next by Tessa Mero
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero5.6K views
Google's Just Not That Into You: Understanding Core Updates & Search Intent by Lily Ray
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray6.3K views
Time Management & Productivity - Best Practices by Vit Horky
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky169.7K views
The six step guide to practical project management by MindGenius
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius36.6K views
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright... by RachelPearson36
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson3612.6K views
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present... by Applitools
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools55.5K views
12 Ways to Increase Your Influence at Work by GetSmarter
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter401.7K views
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G... by DevGAMM Conference
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference3.6K views
Barbie - Brand Strategy Presentation by Erica Santiago
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago25.1K views
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well by Saba Software
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software25.2K views
Introduction to C Programming Language by Simplilearn
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
Simplilearn8.4K views
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr... by Palo Alto Software
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
Palo Alto Software88.4K views
9 Tips for a Work-free Vacation by Weekdone.com
9 Tips for a Work-free Vacation9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation
Weekdone.com7.2K views
How to Map Your Future by SlideShop.com
How to Map Your FutureHow to Map Your Future
How to Map Your Future
SlideShop.com275.1K views

Melhorando Testes No Django Com O Model Mommy