Background Image
Table of Contents Table of Contents
Previous Page  279 / 478 Next Page
Information
Show Menu
Previous Page 279 / 478 Next Page
Page Background

},

},

'loggers'

: {

'django'

: {

'handlers'

: [

'console'

],

},

},

'root'

: {

'level'

:

'INFO'

},

}

Django uses the rather “enterprisey” logging module from the Python standard library,

which, although very fully featured, does suffer from a fairly steep learning curve. It’s

covered a little more in

Chapter 17

, and in the

Django docs .

But we now have a working solution! Let’s commit it on our spike branch:

$

git status

$

git add accounts

$

git commit -am"spiked in custom auth backend with persona"

Time to de-spike!

De-spiking

De-spiking means rewriting your prototype code using TDD. We now have enough

information to “do it properly”. So what’s the first step? An FT of course!

We’ll stay on the spike branch for now, to see our FT pass against our spiked code. Then

we’ll go back to master, and commit just the FT.

Here’s the basic outline:

functional_tests/test_login.py.

from

.base

import

FunctionalTest

class

LoginTest

(

FunctionalTest

):

def

test_login_with_persona

(

self

):

# Edith goes to the awesome superlists site

# and notices a "Sign in" link for the first time.

self

.

browser

.

get

(

self

.

server_url

)

self

.

browser

.

find_element_by_id

(

'login'

)

.

click

()

# A Persona login box appears

self

.

switch_to_new_window

(

'Mozilla Persona'

)

#

# Edith logs in with her email address

## Use mockmyid.com for test email

self

.

browser

.

find_element_by_id

(

'authentication_email'

#

)

.

send_keys

(

'edith@mockmyid.com

'

)

#

De-spiking

|

251