LiveServerTestCase does not map Django Application to url

565 views Asked by At

Background:

I am trying to setup my first Selenium driven integration test for a Django app. I have developed the following simple code:

from django.test import LiveServerTestCase
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.common.keys import Keys

class DynamicFormsIntegrationTest(LiveServerTestCase):

    @classmethod
    def setUpClass(cls):
        cls.selenium = WebDriver()
        cls.selenium.implicitly_wait(3)
        super(DynamicFormsIntegrationTest, cls).setUpClass()


    @classmethod
    def tearDownClass(cls):
        super(DynamicFormsIntegrationTest, cls).tearDownClass()
        cls.selenium.quit()


    def test_basic(self):
        """ Uses get to open application page """

        self.selenium.get(self.live_server_url + '/woc/')


        #Force Test Fail
        self.fail("FAIL")

Now, when I run this test using the following command:

python manage.py test test2

I get the following output:

python manage.py test test2^JCreating test database for alias 'default'...
<QueryDict: {}>
F
======================================================================
FAIL: test_basic (test2.tests.test_forms.DynamicFormsIntegrationTest)
Adds a single set via Jquery/Javascript, Submits, and verifies it was rendered and added to Model.Sets
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/usr/path/to/app/test2/tests/test_forms.py", line 42, in test_basic
    self.fail("FAIL")
AssertionError: FAIL

----------------------------------------------------------------------
Ran 1 test in 8.901s

FAILED (failures=1)
Destroying test database for alias 'default'...

And when I run through my regular setup:

python manage.py runserver

I get the following output upon page request:

python manage.py runserver
Validating models...

0 errors found
September 01, 2013 - 14:42:34
Django version 1.5.1, using settings 'app.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
<QueryDict: {}>
[01/Sep/2013 14:42:39] "GET /test2/ HTTP/1.1" 200 9372

As you can see, the web page is not recognized when running the test (& no "GET" request is actually made, as is correctly done in the dev environment request). I actually believe the "GET" failure is an just an indicator of the problem that the Application is not correctly set up by the LiveServerTestCase.

Question:

Why is the LiveServerTestCase not recognizing my page urls and how can I resolve the issue?

0

There are 0 answers