Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
tdd with django
Search
chrisramon
November 27, 2012
Programming
250
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
tdd with django
chrisramon
November 27, 2012
Other Decks in Programming
See All in Programming
残高管理から台帳サービスへの進化
artoy
1
200
The Rails Doctrine Decade
koic
2
590
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
150
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
270
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
310
golang-bob.pdf
iwatsukayura
0
130
phperだってパンチカードでコーディングしたい
o0h
PRO
0
330
AWSに止められる覚悟してますか?
morizo_1984
2
530
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
190
Agents on Rails - Rails at Scale 2026
irinanazarova
0
560
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
4
3.5k
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
310
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
600
The Mindset for Success: Future Career Progression
greggifford
PRO
0
540
Color Theory Basics | Prateek | Gurzu
gurzu
1
490
Believing is Seeing
oripsolob
1
240
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Amusing Abliteration
ianozsvald
1
350
Code Review Best Practice
trishagee
74
20k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Transcript
Let’s TDD in Django @cramonn
TDD • Primero: assertEqual(sum(7,2), 9) • Luego:
def sum(x, y): return x + y
TestCase -‐ Structure from django.test import TestCase
class BuyersTestCase(TestCase): def setUp(self): pass def tearDown(self): pass def test_buyer_detail(self): pass
class ManufacturerModelsTestCase(TestCase): def setUp(self):
manufacturer_data = { 'name' : 'Manufacturer Test', } self.manufacturer = Manufacturer.objects.create(**manufacturer_data) def test_manufacturer_is_unique_in_air_transport(self): data = { 'manufacturer' : self.manufacturer } with self.assertRaises(IntegrityError): ManufacturerAirTransport.objects.create(**data)
Running TestCase’s Path: some_app/tests/__init__.py Add:
from apps.rp.tests.buyer.registraTon import BuyerRegistraTonTestCase > ./manage.py test rp. BuyerRegistraTonTestCase
Possible Errors
None
None
Built In – Test Clients • Client: •
Dummy web browser, simulate GET – POST request’s from django.test.client import Client class AgentRegistraConTestCase(TestCase): def setUp(self): self.client = Client()
Detail View class BuyerDetailView(LoginRequiredMixin, DetailView):
model = Buyer template_name = 'administrator/buyer/show.html' context_object_name = 'buyer' def get_buyer(self): buyer_pk = self.kwargs.get('pk', None) return Buyer.objects.get(pk=buyer_pk)
Test -‐ Detail View def test_buyer_detail_view(self):
user = User() user.email = '
[email protected]
' user.set_password('my_very_secure_pwd') user.save() self.buyer = Buyer.objects.create() self.client.login(username=user.email, password='my_very_secure_pwd') response = self.client.get( reverse( 'admin_buyer_show', kwargs={'pk’ : self.buyer.id}) ) self.assertEqual(response.status_code, 200) self.assertTrue(response.context_data.has_key('buyer'))
Client + Post + Asserts