SlideShare a Scribd company logo
1 of 18
Download to read offline
Django	
                                	


                                      	
  
             @torufurukawa	
  (#bucho)
Django	
                  	

•  manage.py	
  test	
  
•  Fixtures	
  
•  Clinet
manage.py	
  test	
$	
  python	
  manage.py	
  test	
  -­‐-­‐help	
  
Usage:	
  manage.py	
  test	
  [options]	
  [appname	
  ...]	
  


Runs	
  the	
  test	
  suite	
  for	
  the	
  specified	
  
applications,	
  or	
  the	
  entire	
  site	
  if	
  no	
  
apps	
  are	
  specified.	
  
<app>/tests.py	
                                                 	
from	
  django.test	
  import	
  TestCase	
  
from	
  myapp	
  import	
  extract	
  

class	
  ExtractTest(TestCase):	
  
	
  	
  def	
  test	
  (self):	
  
	
  	
  	
  	
  self.assertEqual(	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  extract(u'       ',u'   '),	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  u'      ')	
  
manage.py	
  test	
                                                                            	
$	
  python	
  manage.py	
  test	
  
Creating	
  test	
  database	
  'default’…	
  
           	
  
...........	
  
-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐	
  
Ran	
  17	
  tests	
  in	
  0.419s	
  

OK	
  
$	
  
manage.py	
  test	
  myapp.MyTest	
   	
  
                                  	

$	
  python	
  manage.py	
  test	
  bucho	
  

                                                       	

$	
  python	
  manage.py	
  test	
  bucho.TestShow	

                                                	
  
$	
  cat	
  testdata.json	
  	
  
[	
  
	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "pk":	
  1,	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  "model":	
  "api.systemstatus",	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  "fields":	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "corner":	
  "2",	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "mode":	
  "1",	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "quesQon_id":	
  null	
  
	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  },	
  
                                   	
  
]	
  
manage.py	
  dumpdata	
   	
  
                                      	
$	
  python	
  manage.py	
  dumpdata	
  
[{"pk":	
  1,	
  "model":	
  "api.systemstatus",	
  "fields":	
  
     {"corner":	
  "0",	
  "mode":	
  "0",	
  "quesQon_id":	
  
     76}}	
  …..	
  ]	
  
                                   	
             .                	

$	
  python	
  manage.py	
  dumpdata	
  app	
  
$	
  python	
  manage.py	
  dumpdata	
  app.MyModel	
  
fixtures	
                         	
  
                                                             	
Class	
  MyTest(TestCase):	
  
	
  	
  	
  	
  fixtures	
  =	
  [‘mydata.json’]	
  
                                                      	
	
  	
  	
  	
  def	
  test_xxx(self):	
  
	
  	
  	
  	
  	
  	
  	
  	
  …	
  
SQLite	
  3	
                              	
  
                                                                  	
#	
  se_ngs_test.py	
  
DATABASES	
  =	
  {	
  
	
  	
  	
  	
  'default':	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  'ENGINE':	
  'sqlite3',	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  'NAME':	
  ':memory:',	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  …	
  
	
  	
  	
  	
  }	
  
}	
  
view	
                                                                                 	
  Client	
>>>	
  help(Client)	
  
Help	
  on	
  class	
  Client	
  in	
  module	
  django.test.client:	
  

class	
  Client(__builQn__.object)	
  
	
  |	
  	
  A	
  class	
  that	
  can	
  act	
  as	
  a	
  client	
  for	
  tesQng	
  purposes.	
  
	
  |	
  	
  	
  
	
  |	
  	
  It	
  allows	
  the	
  user	
  to	
  compose	
  GET	
  and	
  POST	
  requests,	
  and	
  
	
  |	
  	
  obtain	
  the	
  response	
  that	
  the	
  server	
  gave	
  to	
  those	
  requests.	
  
	
  …	
  
	
  |	
  	
  Client	
  objects	
  are	
  stateful	
  -­‐	
  they	
  will	
  retain	
  cookie	
  (and	
  
	
  |	
  	
  thus	
  session)	
  details	
  for	
  the	
  lifeQme	
  of	
  the	
  Client	
  instance.	
  
Client.get(	
  )	
                     client.post(	
  )	
class	
  MyTest(TestCase):	
  
	
  	
  def	
  test_get(self):	
  
	
  	
  	
  	
  res	
  =	
  self.client.get(‘/foo’)	
  
	
  	
  	
  	
  self.assertEqual(res.status_code,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  200)	
  
                                                                                         	
	
  	
  def	
  test_post(self):	
  
	
  	
  	
  	
  	
  res	
  =	
  self.client.post(	
  
       	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ‘/bar’,	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {‘key’:’value’})	
  
	
  	
  	
  	
  	
  …
 
                                                       	

Client.session	
                  Django	
                         	
  
                                                                     	
TestCase.assertTemplateUsed	
  
                                        	
  
TestCase.assertFormError	
                      	
  
                                                            	
  
TestCase.assertRedirects	
                                                	
  
Django	
                           	
•  manage.py	
  test	
                 	
  
•  Fixtures	
              	
  
•  Client	
   view	
  

More Related Content

What's hot

Js 单元测试框架介绍
Js 单元测试框架介绍Js 单元测试框架介绍
Js 单元测试框架介绍louieuser
 
Pytest: escreva menos, teste mais
Pytest: escreva menos, teste maisPytest: escreva menos, teste mais
Pytest: escreva menos, teste maisErick Wilder
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownpartsBastian Feder
 
購物車程式架構簡介
購物車程式架構簡介購物車程式架構簡介
購物車程式架構簡介Jace Ju
 
OPM Recipe designer notes
OPM Recipe designer notesOPM Recipe designer notes
OPM Recipe designer notested-xu
 
Testing My Patience
Testing My PatienceTesting My Patience
Testing My PatienceAdam Lowry
 
JavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineJavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineRaimonds Simanovskis
 
Mocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitMocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitmfrost503
 
Test-driven development for TYPO3 (T3DD11)
Test-driven development for TYPO3 (T3DD11)Test-driven development for TYPO3 (T3DD11)
Test-driven development for TYPO3 (T3DD11)Oliver Klee
 
Testing your javascript code with jasmine
Testing your javascript code with jasmineTesting your javascript code with jasmine
Testing your javascript code with jasmineRubyc Slides
 
Testing orm based code
Testing orm based codeTesting orm based code
Testing orm based codeViktor Turskyi
 
The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.10 book - Part 17 of 212The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.10 book - Part 17 of 212Mahmoud Samir Fayed
 
Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Juriy Zaytsev
 
Spock: A Highly Logical Way To Test
Spock: A Highly Logical Way To TestSpock: A Highly Logical Way To Test
Spock: A Highly Logical Way To TestHoward Lewis Ship
 
The Rule of 10,000 Spark Jobs: Learning From Exceptions and Serializing Your ...
The Rule of 10,000 Spark Jobs: Learning From Exceptions and Serializing Your ...The Rule of 10,000 Spark Jobs: Learning From Exceptions and Serializing Your ...
The Rule of 10,000 Spark Jobs: Learning From Exceptions and Serializing Your ...Databricks
 
The Rule of 10,000 Spark Jobs - Learning from Exceptions and Serializing Your...
The Rule of 10,000 Spark Jobs - Learning from Exceptions and Serializing Your...The Rule of 10,000 Spark Jobs - Learning from Exceptions and Serializing Your...
The Rule of 10,000 Spark Jobs - Learning from Exceptions and Serializing Your...Matthew Tovbin
 
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legione-Legion
 
Caching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingCaching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingErick Hitter
 

What's hot (20)

Js 单元测试框架介绍
Js 单元测试框架介绍Js 单元测试框架介绍
Js 单元测试框架介绍
 
Pytest: escreva menos, teste mais
Pytest: escreva menos, teste maisPytest: escreva menos, teste mais
Pytest: escreva menos, teste mais
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 
購物車程式架構簡介
購物車程式架構簡介購物車程式架構簡介
購物車程式架構簡介
 
OPM Recipe designer notes
OPM Recipe designer notesOPM Recipe designer notes
OPM Recipe designer notes
 
Testing My Patience
Testing My PatienceTesting My Patience
Testing My Patience
 
JavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineJavaScript Unit Testing with Jasmine
JavaScript Unit Testing with Jasmine
 
Mocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitMocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnit
 
Test-driven development for TYPO3 (T3DD11)
Test-driven development for TYPO3 (T3DD11)Test-driven development for TYPO3 (T3DD11)
Test-driven development for TYPO3 (T3DD11)
 
Testing your javascript code with jasmine
Testing your javascript code with jasmineTesting your javascript code with jasmine
Testing your javascript code with jasmine
 
Testing orm based code
Testing orm based codeTesting orm based code
Testing orm based code
 
PL/SQL Unit Testing Can Be Fun!
PL/SQL Unit Testing Can Be Fun!PL/SQL Unit Testing Can Be Fun!
PL/SQL Unit Testing Can Be Fun!
 
The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.10 book - Part 17 of 212The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.10 book - Part 17 of 212
 
Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Say Hello To Ecmascript 5
Say Hello To Ecmascript 5
 
Spock: A Highly Logical Way To Test
Spock: A Highly Logical Way To TestSpock: A Highly Logical Way To Test
Spock: A Highly Logical Way To Test
 
The Rule of 10,000 Spark Jobs: Learning From Exceptions and Serializing Your ...
The Rule of 10,000 Spark Jobs: Learning From Exceptions and Serializing Your ...The Rule of 10,000 Spark Jobs: Learning From Exceptions and Serializing Your ...
The Rule of 10,000 Spark Jobs: Learning From Exceptions and Serializing Your ...
 
The Rule of 10,000 Spark Jobs - Learning from Exceptions and Serializing Your...
The Rule of 10,000 Spark Jobs - Learning from Exceptions and Serializing Your...The Rule of 10,000 Spark Jobs - Learning from Exceptions and Serializing Your...
The Rule of 10,000 Spark Jobs - Learning from Exceptions and Serializing Your...
 
JUnit
JUnitJUnit
JUnit
 
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
 
Caching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingCaching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment Caching
 

Similar to Django

Django’s nasal passage
Django’s nasal passageDjango’s nasal passage
Django’s nasal passageErik Rose
 
Тестирование и Django
Тестирование и DjangoТестирование и Django
Тестирование и DjangoMoscowDjango
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdfHans Jones
 
Token Testing Slides
Token  Testing SlidesToken  Testing Slides
Token Testing Slidesericholscher
 
Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2Yi-Huan Chan
 
Pruebas unitarias con django
Pruebas unitarias con djangoPruebas unitarias con django
Pruebas unitarias con djangoTomás Henríquez
 
Intro to Testing in Zope, Plone
Intro to Testing in Zope, PloneIntro to Testing in Zope, Plone
Intro to Testing in Zope, PloneQuintagroup
 
E2E testing con nightwatch.js - Drupalcamp Spain 2018
E2E testing con nightwatch.js  - Drupalcamp Spain 2018E2E testing con nightwatch.js  - Drupalcamp Spain 2018
E2E testing con nightwatch.js - Drupalcamp Spain 2018Salvador Molina (Slv_)
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to ProtractorJie-Wei Wu
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java DevelopersYakov Fain
 
Slaven tomac unit testing in angular js
Slaven tomac   unit testing in angular jsSlaven tomac   unit testing in angular js
Slaven tomac unit testing in angular jsSlaven Tomac
 
Php Unit With Zend Framework Zendcon09
Php Unit With Zend Framework   Zendcon09Php Unit With Zend Framework   Zendcon09
Php Unit With Zend Framework Zendcon09Michelangelo van Dam
 
Testing for Pragmatic People
Testing for Pragmatic PeopleTesting for Pragmatic People
Testing for Pragmatic Peopledavismr
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksSelenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksLohika_Odessa_TechTalks
 

Similar to Django (20)

Django’s nasal passage
Django’s nasal passageDjango’s nasal passage
Django’s nasal passage
 
Тестирование и Django
Тестирование и DjangoТестирование и Django
Тестирование и Django
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdf
 
Token Testing Slides
Token  Testing SlidesToken  Testing Slides
Token Testing Slides
 
Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2
 
Pruebas unitarias con django
Pruebas unitarias con djangoPruebas unitarias con django
Pruebas unitarias con django
 
Intro to Testing in Zope, Plone
Intro to Testing in Zope, PloneIntro to Testing in Zope, Plone
Intro to Testing in Zope, Plone
 
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
JavaCro'14 - Unit testing in AngularJS – Slaven TomacJavaCro'14 - Unit testing in AngularJS – Slaven Tomac
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
 
What's new in Django 1.2?
What's new in Django 1.2?What's new in Django 1.2?
What's new in Django 1.2?
 
E2E testing con nightwatch.js - Drupalcamp Spain 2018
E2E testing con nightwatch.js  - Drupalcamp Spain 2018E2E testing con nightwatch.js  - Drupalcamp Spain 2018
E2E testing con nightwatch.js - Drupalcamp Spain 2018
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java Developers
 
Scala test
Scala testScala test
Scala test
 
Scala test
Scala testScala test
Scala test
 
How to fake_properly
How to fake_properlyHow to fake_properly
How to fake_properly
 
Slaven tomac unit testing in angular js
Slaven tomac   unit testing in angular jsSlaven tomac   unit testing in angular js
Slaven tomac unit testing in angular js
 
Php Unit With Zend Framework Zendcon09
Php Unit With Zend Framework   Zendcon09Php Unit With Zend Framework   Zendcon09
Php Unit With Zend Framework Zendcon09
 
Browser testing with nightwatch.js
Browser testing with nightwatch.jsBrowser testing with nightwatch.js
Browser testing with nightwatch.js
 
Testing for Pragmatic People
Testing for Pragmatic PeopleTesting for Pragmatic People
Testing for Pragmatic People
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksSelenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
 

More from Toru Furukawa

Twitter 広告と API を組み合わせたインタラクティブなキャンペーン
 Twitter 広告と API を組み合わせたインタラクティブなキャンペーン Twitter 広告と API を組み合わせたインタラクティブなキャンペーン
Twitter 広告と API を組み合わせたインタラクティブなキャンペーンToru Furukawa
 
My client wanted their apps synced, and I made it with Go
My client wanted their apps synced, and I made it with GoMy client wanted their apps synced, and I made it with Go
My client wanted their apps synced, and I made it with GoToru Furukawa
 
Introduction to Python 3.4 as of beta 1
Introduction to Python 3.4 as of beta 1Introduction to Python 3.4 as of beta 1
Introduction to Python 3.4 as of beta 1Toru Furukawa
 
Test Failed, Then...
Test Failed, Then...Test Failed, Then...
Test Failed, Then...Toru Furukawa
 
おまえらこのライブラリ使ってないの? m9 (2013-07)
おまえらこのライブラリ使ってないの? m9	(2013-07)おまえらこのライブラリ使ってないの? m9	(2013-07)
おまえらこのライブラリ使ってないの? m9 (2013-07)Toru Furukawa
 
Trying Continuous Delivery - pyconjp 2012
Trying Continuous Delivery - pyconjp 2012Trying Continuous Delivery - pyconjp 2012
Trying Continuous Delivery - pyconjp 2012Toru Furukawa
 
Python 3.3 チラ見
Python 3.3 チラ見Python 3.3 チラ見
Python 3.3 チラ見Toru Furukawa
 
Python32 pyhackathon-201011
Python32 pyhackathon-201011Python32 pyhackathon-201011
Python32 pyhackathon-201011Toru Furukawa
 

More from Toru Furukawa (11)

Twitter 広告と API を組み合わせたインタラクティブなキャンペーン
 Twitter 広告と API を組み合わせたインタラクティブなキャンペーン Twitter 広告と API を組み合わせたインタラクティブなキャンペーン
Twitter 広告と API を組み合わせたインタラクティブなキャンペーン
 
My client wanted their apps synced, and I made it with Go
My client wanted their apps synced, and I made it with GoMy client wanted their apps synced, and I made it with Go
My client wanted their apps synced, and I made it with Go
 
Introduction to Python 3.4 as of beta 1
Introduction to Python 3.4 as of beta 1Introduction to Python 3.4 as of beta 1
Introduction to Python 3.4 as of beta 1
 
Test Failed, Then...
Test Failed, Then...Test Failed, Then...
Test Failed, Then...
 
おまえらこのライブラリ使ってないの? m9 (2013-07)
おまえらこのライブラリ使ってないの? m9	(2013-07)おまえらこのライブラリ使ってないの? m9	(2013-07)
おまえらこのライブラリ使ってないの? m9 (2013-07)
 
Mock and patch
Mock and patchMock and patch
Mock and patch
 
Trying Continuous Delivery - pyconjp 2012
Trying Continuous Delivery - pyconjp 2012Trying Continuous Delivery - pyconjp 2012
Trying Continuous Delivery - pyconjp 2012
 
Python 3.3 チラ見
Python 3.3 チラ見Python 3.3 チラ見
Python 3.3 チラ見
 
Python32 pyhackathon-201011
Python32 pyhackathon-201011Python32 pyhackathon-201011
Python32 pyhackathon-201011
 
Python 2.7
Python 2.7Python 2.7
Python 2.7
 
BPStudy#34 導入
BPStudy#34 導入BPStudy#34 導入
BPStudy#34 導入
 

Recently uploaded

Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringWSO2
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaWSO2
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuidePixlogix Infotech
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceIES VE
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingWSO2
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxFIDO Alliance
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewDianaGray10
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseWSO2
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformWSO2
 

Recently uploaded (20)

Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 

Django

  • 1. Django     @torufurukawa  (#bucho)
  • 2.
  • 3.
  • 4.
  • 5.
  • 6. Django   •  manage.py  test   •  Fixtures   •  Clinet
  • 7. manage.py  test $  python  manage.py  test  -­‐-­‐help   Usage:  manage.py  test  [options]  [appname  ...]   Runs  the  test  suite  for  the  specified   applications,  or  the  entire  site  if  no   apps  are  specified.  
  • 8. <app>/tests.py   from  django.test  import  TestCase   from  myapp  import  extract   class  ExtractTest(TestCase):      def  test  (self):          self.assertEqual(                          extract(u' ',u' '),                            u' ')  
  • 9. manage.py  test   $  python  manage.py  test   Creating  test  database  'default’…     ...........   -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐   Ran  17  tests  in  0.419s   OK   $  
  • 10. manage.py  test  myapp.MyTest     $  python  manage.py  test  bucho   $  python  manage.py  test  bucho.TestShow  
  • 11. $  cat  testdata.json     [          {                  "pk":  1,                    "model":  "api.systemstatus",                    "fields":  {                          "corner":  "2",                            "mode":  "1",                            "quesQon_id":  null                  }          },     ]  
  • 12. manage.py  dumpdata     $  python  manage.py  dumpdata   [{"pk":  1,  "model":  "api.systemstatus",  "fields":   {"corner":  "0",  "mode":  "0",  "quesQon_id":   76}}  …..  ]   . $  python  manage.py  dumpdata  app   $  python  manage.py  dumpdata  app.MyModel  
  • 13. fixtures     Class  MyTest(TestCase):          fixtures  =  [‘mydata.json’]          def  test_xxx(self):                  …  
  • 14. SQLite  3     #  se_ngs_test.py   DATABASES  =  {          'default':  {                  'ENGINE':  'sqlite3',                    'NAME':  ':memory:',                    …          }   }  
  • 15. view    Client >>>  help(Client)   Help  on  class  Client  in  module  django.test.client:   class  Client(__builQn__.object)    |    A  class  that  can  act  as  a  client  for  tesQng  purposes.    |        |    It  allows  the  user  to  compose  GET  and  POST  requests,  and    |    obtain  the  response  that  the  server  gave  to  those  requests.    …    |    Client  objects  are  stateful  -­‐  they  will  retain  cookie  (and    |    thus  session)  details  for  the  lifeQme  of  the  Client  instance.  
  • 16. Client.get(  )   client.post(  ) class  MyTest(TestCase):      def  test_get(self):          res  =  self.client.get(‘/foo’)          self.assertEqual(res.status_code,                                            200)      def  test_post(self):            res  =  self.client.post(                        ‘/bar’,                              {‘key’:’value’})            …
  • 17.   Client.session Django     TestCase.assertTemplateUsed     TestCase.assertFormError       TestCase.assertRedirects    
  • 18. Django   •  manage.py  test     •  Fixtures     •  Client   view