FunctionalTest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
c 2
b 0
f 0
dl 0
loc 36
rs 10

6 Methods

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