SlideShare a Scribd company logo
20. Testing Stinks and Is a Waste of Money!
&
21. Documentation: Be Obsessed
2015/02/24
Eric
1
Self-introduction
• Eric
• 勇敢吧!智慧科技 (BraveBot Intelligent)
• iOS + Android APP Customization
• Backend Engineer
• 1 year experience with Django
2
Outline
• 20. Testing Stinks and Is a Waste of Money!
• Why Tests?
• How to Structure Tests?
• How to Write Unit Tests?
• The Game of Test Coverage
• 21. Documentation: Be Obsessed
• Sphinx & reStructuredText
• What Docs Should Django Project Contains?
• Other Documentation Methods
3
20. Testing Stinks and Is a
Waste of Money!
4
Why Tests
• Testing Saves Money, Jobs, and Lives
• Handling medical information
• Works with other people’s money now or will at some point in
the future
• Providing life-critical resources to people in need
• Testing Saves Time
• Refactoring
• Upgrading Django version
5
How to Structure Tests?
• Delete the default and useless tests.py
module
• Create a tests directory and create
__init__.py, test_models.py, …
• Must prefix modules with test_
• So we can config discover runner to
discover just test files.
6
How to Write Unit Tests?
• Each Test Method Tests One Thing
7
How to Write Unit Tests?
8
How to Write Unit Tests?
• Don’t Write Tests That Have to Be Tested
• DRY Doesn’t Apply to Writing Tests
• Don’t Rely on Fixtures
• Fixtures are hard to maintain as a project’s data change over time
• Modify JSON-formatted files to match your last migration is hard
• It’s easier to write code that relies on the ORM
• Tools to generate test data
• factory_boy : http://factoryboy.readthedocs.org/en/latest/
• model_mommy : http://model-mommy.readthedocs.org/en/latest/basic_usage.html
• mock : http://mock.readthedocs.org/en/latest/
9
How to Write Unit Tests?
• Things that should be tested
• Views, Models, Forms, Validators, Signals, Filters,
Template Tags, …
• Things that shouldn’t be tested
• Django core, third-party packages
10
The Game of Test Coverage
• Mandate that no commit can lower test coverage
11
The Game of Test Coverage
• Step 1: set up a test runner
• create settings/test.py
• Step 2 : run tests and generate
coverage report
• install coverage module
• coverage run manage.py test —
settings=project_name.settings.
test
12
The Game of Test Coverage
• Step 3 : generate the report !
• coverage html —include=`pwd`/*—omit=‘env/lib/*.py,*/tests/*.py,*/
migrations/*.py’
• automatically create the htmlcov/ directory containing the index.html
13
21. Documentation:
Be Obsessed
14
reStructuredText & Sphinx
• reStructuredText(RST)
• Most common markup language used for documenting Python
projects
• Sphinx
• Generating docs from .rst files
• Output formats
• HTML, LaTeX, manual pages, and plain text
• pip install Sphinx
15
RST Example
Sphinx
16
What Docs Should Django
Projects Contain?
17
Other Documentation
Methods
• Wikis
• Online document stores
• Google Drive, Dropbox, box.net, …
• They are better than no documents
18
Web API Documentation
• Django REST Framework + Django REST Swagger
19
Sample Code
• https://github.com/guyuanlin/two_scope_of_django
20
Thank You!
21

More Related Content

Viewers also liked

Famous places in Haskovo region_ by Viktor Mollov 5b class
Famous places in Haskovo region_ by Viktor Mollov 5b classFamous places in Haskovo region_ by Viktor Mollov 5b class
Famous places in Haskovo region_ by Viktor Mollov 5b class
iliyana_panayotova
 
Concert _March_2014_ English
Concert _March_2014_ EnglishConcert _March_2014_ English
Concert _March_2014_ English
iliyana_panayotova
 
Secondary school vasil levski_haskovo_bulgaria_seminar_report_comenius projec...
Secondary school vasil levski_haskovo_bulgaria_seminar_report_comenius projec...Secondary school vasil levski_haskovo_bulgaria_seminar_report_comenius projec...
Secondary school vasil levski_haskovo_bulgaria_seminar_report_comenius projec...
iliyana_panayotova
 
Dynamic Reactor Pattern for Distributed Systems in Control and Monitoring
Dynamic Reactor Pattern for Distributed Systems in Control and MonitoringDynamic Reactor Pattern for Distributed Systems in Control and Monitoring
Dynamic Reactor Pattern for Distributed Systems in Control and Monitoring
Jordan McBain
 
Condition Monitoring Of Unsteadily Operating Equipment
Condition Monitoring Of Unsteadily Operating EquipmentCondition Monitoring Of Unsteadily Operating Equipment
Condition Monitoring Of Unsteadily Operating Equipment
Jordan McBain
 
Redaccion de un parrafo
Redaccion de un parrafoRedaccion de un parrafo
Redaccion de un parrafo
Julian Osorio
 
Christmas celebration by Petya_5a class_2012 - 2013 school year
Christmas celebration by Petya_5a class_2012 - 2013 school yearChristmas celebration by Petya_5a class_2012 - 2013 school year
Christmas celebration by Petya_5a class_2012 - 2013 school year
iliyana_panayotova
 
Object oriented design patterns for distributed systems
Object oriented design patterns for distributed systemsObject oriented design patterns for distributed systems
Object oriented design patterns for distributed systems
Jordan McBain
 
Condition Monitoring of Variable State Machinery
Condition Monitoring of Variable State MachineryCondition Monitoring of Variable State Machinery
Condition Monitoring of Variable State Machinery
Jordan McBain
 

Viewers also liked (9)

Famous places in Haskovo region_ by Viktor Mollov 5b class
Famous places in Haskovo region_ by Viktor Mollov 5b classFamous places in Haskovo region_ by Viktor Mollov 5b class
Famous places in Haskovo region_ by Viktor Mollov 5b class
 
Concert _March_2014_ English
Concert _March_2014_ EnglishConcert _March_2014_ English
Concert _March_2014_ English
 
Secondary school vasil levski_haskovo_bulgaria_seminar_report_comenius projec...
Secondary school vasil levski_haskovo_bulgaria_seminar_report_comenius projec...Secondary school vasil levski_haskovo_bulgaria_seminar_report_comenius projec...
Secondary school vasil levski_haskovo_bulgaria_seminar_report_comenius projec...
 
Dynamic Reactor Pattern for Distributed Systems in Control and Monitoring
Dynamic Reactor Pattern for Distributed Systems in Control and MonitoringDynamic Reactor Pattern for Distributed Systems in Control and Monitoring
Dynamic Reactor Pattern for Distributed Systems in Control and Monitoring
 
Condition Monitoring Of Unsteadily Operating Equipment
Condition Monitoring Of Unsteadily Operating EquipmentCondition Monitoring Of Unsteadily Operating Equipment
Condition Monitoring Of Unsteadily Operating Equipment
 
Redaccion de un parrafo
Redaccion de un parrafoRedaccion de un parrafo
Redaccion de un parrafo
 
Christmas celebration by Petya_5a class_2012 - 2013 school year
Christmas celebration by Petya_5a class_2012 - 2013 school yearChristmas celebration by Petya_5a class_2012 - 2013 school year
Christmas celebration by Petya_5a class_2012 - 2013 school year
 
Object oriented design patterns for distributed systems
Object oriented design patterns for distributed systemsObject oriented design patterns for distributed systems
Object oriented design patterns for distributed systems
 
Condition Monitoring of Variable State Machinery
Condition Monitoring of Variable State MachineryCondition Monitoring of Variable State Machinery
Condition Monitoring of Variable State Machinery
 

Similar to Two Scope of Django 1.6 Chapter 20 and 21

TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)
Peter Kofler
 
Building a custom cms with django
Building a custom cms with djangoBuilding a custom cms with django
Building a custom cms with django
Yann Malet
 
Introduction to Unit Tests and TDD
Introduction to Unit Tests and TDDIntroduction to Unit Tests and TDD
Introduction to Unit Tests and TDD
Betclic Everest Group Tech Team
 
TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)
Nacho Cougil
 
The Cowardly Test-o-Phobe's Guide To Testing
The Cowardly Test-o-Phobe's Guide To TestingThe Cowardly Test-o-Phobe's Guide To Testing
The Cowardly Test-o-Phobe's Guide To Testing
Tim Duckett
 
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
ssusercaf6c1
 
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
Nacho Cougil
 
An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1
Blue Elephant Consulting
 
Software Engineering in Startups
Software Engineering in StartupsSoftware Engineering in Startups
Software Engineering in Startups
Dusan Omercevic
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
Einar Ingebrigtsen
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Ortus Solutions, Corp
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Uma Ghotikar
 
TDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech WeekTDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech Week
Nacho Cougil
 
Testing on Android
Testing on AndroidTesting on Android
Testing on Android
Ari Lacenski
 
Hour of Code_13-16_StoreTraining
Hour of Code_13-16_StoreTrainingHour of Code_13-16_StoreTraining
Hour of Code_13-16_StoreTraining
Stephanie McMahon
 
[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?
European Collaboration Summit
 
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug JavaWriting better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
idrsolutions
 
Lean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersLean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill Ayers
SPC Adriatics
 
Overview of Testing Talks at Pycon
Overview of Testing Talks at PyconOverview of Testing Talks at Pycon
Overview of Testing Talks at Pycon
Jacqueline Kazil
 
Developers Testing - Girl Code at bloomon
Developers Testing - Girl Code at bloomonDevelopers Testing - Girl Code at bloomon
Developers Testing - Girl Code at bloomon
Ineke Scheffers
 

Similar to Two Scope of Django 1.6 Chapter 20 and 21 (20)

TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)
 
Building a custom cms with django
Building a custom cms with djangoBuilding a custom cms with django
Building a custom cms with django
 
Introduction to Unit Tests and TDD
Introduction to Unit Tests and TDDIntroduction to Unit Tests and TDD
Introduction to Unit Tests and TDD
 
TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)
 
The Cowardly Test-o-Phobe's Guide To Testing
The Cowardly Test-o-Phobe's Guide To TestingThe Cowardly Test-o-Phobe's Guide To Testing
The Cowardly Test-o-Phobe's Guide To Testing
 
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
 
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
 
An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1
 
Software Engineering in Startups
Software Engineering in StartupsSoftware Engineering in Startups
Software Engineering in Startups
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
 
TDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech WeekTDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech Week
 
Testing on Android
Testing on AndroidTesting on Android
Testing on Android
 
Hour of Code_13-16_StoreTraining
Hour of Code_13-16_StoreTrainingHour of Code_13-16_StoreTraining
Hour of Code_13-16_StoreTraining
 
[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?
 
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug JavaWriting better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
 
Lean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersLean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill Ayers
 
Overview of Testing Talks at Pycon
Overview of Testing Talks at PyconOverview of Testing Talks at Pycon
Overview of Testing Talks at Pycon
 
Developers Testing - Girl Code at bloomon
Developers Testing - Girl Code at bloomonDevelopers Testing - Girl Code at bloomon
Developers Testing - Girl Code at bloomon
 

Recently uploaded

SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
Top 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptxTop 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptx
devvsandy
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Envertis Software Solutions
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
Rakesh Kumar R
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 

Recently uploaded (20)

SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
Top 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptxTop 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptx
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 

Two Scope of Django 1.6 Chapter 20 and 21

  • 1. 20. Testing Stinks and Is a Waste of Money! & 21. Documentation: Be Obsessed 2015/02/24 Eric 1
  • 2. Self-introduction • Eric • 勇敢吧!智慧科技 (BraveBot Intelligent) • iOS + Android APP Customization • Backend Engineer • 1 year experience with Django 2
  • 3. Outline • 20. Testing Stinks and Is a Waste of Money! • Why Tests? • How to Structure Tests? • How to Write Unit Tests? • The Game of Test Coverage • 21. Documentation: Be Obsessed • Sphinx & reStructuredText • What Docs Should Django Project Contains? • Other Documentation Methods 3
  • 4. 20. Testing Stinks and Is a Waste of Money! 4
  • 5. Why Tests • Testing Saves Money, Jobs, and Lives • Handling medical information • Works with other people’s money now or will at some point in the future • Providing life-critical resources to people in need • Testing Saves Time • Refactoring • Upgrading Django version 5
  • 6. How to Structure Tests? • Delete the default and useless tests.py module • Create a tests directory and create __init__.py, test_models.py, … • Must prefix modules with test_ • So we can config discover runner to discover just test files. 6
  • 7. How to Write Unit Tests? • Each Test Method Tests One Thing 7
  • 8. How to Write Unit Tests? 8
  • 9. How to Write Unit Tests? • Don’t Write Tests That Have to Be Tested • DRY Doesn’t Apply to Writing Tests • Don’t Rely on Fixtures • Fixtures are hard to maintain as a project’s data change over time • Modify JSON-formatted files to match your last migration is hard • It’s easier to write code that relies on the ORM • Tools to generate test data • factory_boy : http://factoryboy.readthedocs.org/en/latest/ • model_mommy : http://model-mommy.readthedocs.org/en/latest/basic_usage.html • mock : http://mock.readthedocs.org/en/latest/ 9
  • 10. How to Write Unit Tests? • Things that should be tested • Views, Models, Forms, Validators, Signals, Filters, Template Tags, … • Things that shouldn’t be tested • Django core, third-party packages 10
  • 11. The Game of Test Coverage • Mandate that no commit can lower test coverage 11
  • 12. The Game of Test Coverage • Step 1: set up a test runner • create settings/test.py • Step 2 : run tests and generate coverage report • install coverage module • coverage run manage.py test — settings=project_name.settings. test 12
  • 13. The Game of Test Coverage • Step 3 : generate the report ! • coverage html —include=`pwd`/*—omit=‘env/lib/*.py,*/tests/*.py,*/ migrations/*.py’ • automatically create the htmlcov/ directory containing the index.html 13
  • 15. reStructuredText & Sphinx • reStructuredText(RST) • Most common markup language used for documenting Python projects • Sphinx • Generating docs from .rst files • Output formats • HTML, LaTeX, manual pages, and plain text • pip install Sphinx 15
  • 17. What Docs Should Django Projects Contain? 17
  • 18. Other Documentation Methods • Wikis • Online document stores • Google Drive, Dropbox, box.net, … • They are better than no documents 18
  • 19. Web API Documentation • Django REST Framework + Django REST Swagger 19