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

Chapter Overview

There’s lots of stuff in this chapter, so here’s an overview to help you keep your bearings:

1. Adapt our FTs so they can run against a staging server.

2. Spin up a server, install all the required software on it, and point our staging and

live domains at it.

3. Upload our code to the server using Git.

4. Try and get a quick & dirty version of our site running on the staging domain using

the Django dev server.

5. Learn how to use a virtualenv to manage our project’s Python dependencies on the

server.

6. As we go, we’ll keep running our FT, to tell us what’s working and what’s not.

7. Move from our quick & dirty version to a production-ready configuration, using

Gunicorn, Upstart, and domain sockets.

8. Once we have a working config, we’ll write a script to automate the process we’ve

just been through manually, so that we can deploy our site automatically in future.

9. Finally we’ll use this script to deploy the production version of our site on its real

domain.

As Always, Start with a Test

Let’s adapt our functional tests slightly so that it can be run against a staging site. We’ll

do it by slightly hacking an argument that is normally used to change the address which

the test’s temporary server gets run on:

functional_tests/tests.py (ch08l001).

import

sys

[

...

]

class

NewVisitorTest

(

StaticLiveServerCase

):

@classmethod

def

setUpClass

(

cls

):

#

for

arg

in

sys

.

argv

:

#

if

'liveserver'

in

arg

:

#

cls

.

server_url

=

'http://'

+

arg

.

split

(

'='

)[

1

]

#

return

#

super

()

.

setUpClass

()

cls

.

server_url

=

cls

.

live_server_url

@classmethod

def

tearDownClass

(

cls

):

As Always, Start with a Test

|

133