2 # -*- coding: utf-8 -*-
4 # Copyright (c) 2010-2012 Cidadania S. Coop. Galega
6 # This file is part of e-cidadania.
8 # e-cidadania is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # e-cidadania is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with e-cidadania. If not, see <http://www.gnu.org/licenses/>.
23 from selenium
import webdriver
24 from selenium
.webdriver
.common
.keys
import Keys
26 from django
.test
import LiveServerTestCase
28 from tests
.test_utils
import ECDTestCase
32 class FunctionalTestCase(ECDTestCase
, LiveServerTestCase
):
34 Class which provides functional testing capabilities. It subclasses both
35 our custom ECDTestCase and django's LiveServerTestCase. LiveServerTestCase
36 was introduced in Django 1.4 to support functional testing.
40 ECDTestCase
.init(self
)
41 self
.browser
= webdriver
.Firefox()
45 Setup done prior to a test run.
51 Actions taken after a test run.
57 Halts script execution for `sec` seconds.
59 This is necessary because the script executes faster than the browser.
64 def login(self
, browser
, username
='test_user', password
='test_password'):
66 Logs into e-cidadania.
68 username_field
= browser
.find_element_by_name('username')
69 username_field
.send_keys(username
)
71 password_field
= browser
.find_element_by_name('password')
72 password_field
.send_keys(password
)
74 password_field
.send_keys(Keys
.RETURN
)