1
|
|
|
from pyvirtualdisplay import Display |
2
|
|
|
from selenium import webdriver |
3
|
|
|
from django.core.urlresolvers import reverse |
4
|
|
|
from django.contrib.staticfiles.testing import StaticLiveServerTestCase |
5
|
|
|
from django.utils import formats |
6
|
|
|
from ..testing_utilities import populate_test_db |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
class FunctionalTest(StaticLiveServerTestCase): |
10
|
|
|
def setUp(self): |
11
|
|
|
display = Display(visible=0, size=(800, 600)) |
12
|
|
|
display.start() |
13
|
|
|
|
14
|
|
|
self.selenium = webdriver.Firefox() |
15
|
|
|
self.selenium.implicitly_wait(3) |
16
|
|
|
populate_test_db() |
17
|
|
|
|
18
|
|
|
def tearDown(self): |
19
|
|
|
self.selenium.quit() |
20
|
|
|
|
21
|
|
|
# Auxiliary function to add view subdir to URL |
22
|
|
|
def _get_full_url(self, namespace): |
23
|
|
|
return self.live_server_url + namespace |
24
|
|
|
|
25
|
|
|
def _is_text_present(self, text): |
26
|
|
|
try: |
27
|
|
|
body = self.selenium.find_element_by_tag_name("body") # find body tag element |
28
|
|
|
except NoSuchElementException, e: |
29
|
|
|
return False |
30
|
|
|
return text in body.text # check if the text is in body's text |
31
|
|
|
|
32
|
|
|
def test_home_title(self): |
33
|
|
|
""" |
34
|
|
|
Tests that Home is loading properly |
35
|
|
|
""" |
36
|
|
|
self.selenium.get(self._get_full_url("/")) |
37
|
|
|
self.assertIn(u'Metadata Explorer Tool', self.selenium.title) |
38
|
|
|
|
39
|
|
|
def test_home_sections(self): |
40
|
|
|
""" |
41
|
|
|
Tests that Home is showing the right sections |
42
|
|
|
""" |
43
|
|
|
self.selenium.get(self._get_full_url("/")) |
44
|
|
|
self.assertTrue(self._is_text_present("Entities summary")) |
45
|
|
|
|