Book Image

Test-Driven Development with Django

By : Kevin Harvey
Book Image

Test-Driven Development with Django

By: Kevin Harvey

Overview of this book

<p>Test-Driven Development (TDD) simplifies the trickiest of software tasks with its unique ability to peel back problems into layers. The testing tools available in Python and Django make test writing a joy, and the full coverage test suite that results from TDD is a boon to any project.</p> <p>This guide to developing with Django takes a test-first approach: write a test, then write enough production code to get it to pass. You'll quickly get hands-on experience, writing tests for a database-driven application with the TDD methodology. Use this book to build the skills and habits that make testing a regular part of your workflow.</p>
Table of Contents (15 chapters)
Test-Driven Development with Django
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

A new view


With this in mind, let's take a stab at adding a 'track' view. We can start by updating the functional test with what we expect to see on a Track page. We will totally replace the On the solo page section of the test method. Open jmad/test.py from the repository, and replace from line 67 to the end of the file with the following code:

        # On the solo page...
        self.assertEqual(
            self.browser.current_url,
            self.live_server_url +
            '/recordings/kind-of-blue/all-blues/cannonball-adderley/'
        )

        # he sees the artist...
        self.assertEqual(
            self.browser.find_element_by_css_selector(
                '#jmad-artist').text,
                'Cannonball Adderley'
        )
        # the track title (with a count of solos)...
        self.assertEqual(
            self.browser.find_element_by_css_selector(
                '#jmad-track').text,
                'All Blues [2 solos]'
        )

        # and the album title...