万本电子书0元读

万本电子书0元读

顶部广告

Test-Driven Development with Django电子书

售       价:¥

14人正在读 | 0人评论 9.8

作       者:Kevin Harvey

出  版  社:Packt Publishing

出版时间:2015-07-30

字       数:105.7万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:此类商品不支持退换货,不支持下载打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
This book is for Django developers with little or no knowledge of test-driven development or testing in general. Familiarity with the command line, setting up a Python virtual environment, and starting a Django project are assumed.
目录展开

Test-Driven Development with Django

Table of Contents

Test-Driven Development with Django

Credits

About the Author

About the Reviewers

www.PacktPub.com

Support files, eBooks, discount offers, and more

Why subscribe?

Free access for Packt account holders

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

1. Keeping Your Promises

What is Test-Driven Development?

A simple example

Red/green/refactor

Testing is a pillar of professional software development

Version control

Documentation

Testing

Continuous Integration

How does TDD help in building better software?

Doesn't it take longer?

Can't I just write the tests later?

Summary

2. Your First Test-Driven Application

Where do we begin?

Functional versus unit tests

User versus developer experience

Size

Breadth

The project – jmad.us

Setting up your environment

Starting the project

Getting the sample code

Starting a functional test

Introducing LiveServerTestCase

Introducing Selenium

Fleshing out the user story

Getting the test to fail

Opening a page with WebDriver

Finding elements with WebDriver

Reading test output

Setting up a Django app for unit tests

Planning our unit tests

Finally writing application code

Testing views with RequestFactory

Continuing through the functional test

Adding search to the view

Summary

3. Ironclad Code

Using the Python Debugger in tests

Using RequestFactory

Running a single test with dot notation

Managing test data

Refactoring

setUpClass versus setUp

DRY testing

RequestFactory versus TestClient

Testing URLs

Does that seem like overkill?

Displaying search results

Selenium tail-chasing

Building the Solo detail page

Summary

4. Building Out and Refactoring

Improving the application

A new view

Pretty URLs

Back into the TDD cycle

Skipping ahead a bit

Starting a new app

Much ado about migrations

Updating the functional test

Refactoring the index view

Summary

5. User Stories As Code

A second user story

Activating the Django admin site

Signing in with Selenium

Configuring the Django admin model list display

Adding content via the Django admin

Finishing up

Summary

6. No App Is an Island

What is a mock?

MusicBrainz

Digging around in the MusicBrainz sandbox

Using the API in our application

Mocking – when and why

Adding the MB API to search

Encapsulating the API call

Our first mock

Hacking what's returned from a mocked method

Implementing the API calls

Moving back up the chain

Dealing with change

This is just one method

Summary

7. Share and Share Alike

It's an API world, we're just coding in it

Deceptive simplicity

Writing documentation first

Documentation-Driven testing

More developers, more problems

Building an API with Django REST framework

Initial documentation

Introducing Django REST framework

Writing tests for API endpoints

API routing with DRF's SimpleRouter

Automatic APIs with DRF viewsets

Converting Django models with serializers

Finishing up with RetrieveModelMixin

Adding data via the API

POSTing data in a test

Validating inbound data with a serializer

Summary

8. Promises Kept

How far we've come

So, how did it go?

We kept ourselves on track

Our application can check itself

We kept our thinking clear

Our code is testable

We can take big risks

We look like pros

Did we do more work than necessary?

Did it take longer than it should have?

What haven't we done?

Production optimization

An actual frontend design

Quality assurance

Load testing

What shall we build next?

Authentication for creating solos

Tagging solos

Haystack search

Celery for caching MusicBrainz data

An errant data interaction for MusicBrainz

Exposing API documentation with Django REST framework

To tend or not to tend?

Fight through the gotchas

"No module named" errors when using dotted paths to tests

When error messages get weird, Google is your friend

Thanks!

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部