SlideShare uma empresa Scribd logo
1 de 69
Baixar para ler offline
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

Mais conteúdo relacionado

Destaque

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - 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 Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
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
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
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...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
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...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destaque (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - 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
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
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
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
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...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
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...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Melhorando Testes No Django Com O Model Mommy