Statistics
| Branch: | Tag: | Revision:

root / ui / tests.py @ 0ad5737e

History | View | Annotate | Download (2.2 kB)

1
from django.test import TestCase
2
from selenium import selenium
3
from multiprocessing import Process
4
from time import sleep
5

    
6
class FunctionalCase(TestCase):
7
    """
8
    Functional tests for synnefo.ui using Selenium
9
    """
10

    
11
    def setUp(self):
12
        """Make the selenium connection"""
13
        TestCase.setUp(self)
14
        self.verificationErrors = []
15
        self.selenium = selenium("localhost", 4444, "*firefox",
16
                                 "http://localhost:8000/")
17
        self.selenium.start()
18

    
19
        
20
    def tearDown(self):
21
        """Kill processes"""
22
        TestCase.tearDown(self)
23
        self.selenium.stop()
24
        self.assertEqual([], self.verificationErrors)
25
        
26
    def test_wizard(self):
27
        sel = self.selenium
28
        sel.open("/")
29
        sel.wait_for_page_to_load("10000")
30
        self.failUnless(sel.is_text_present("machines"))
31
        sleep(2)
32
        sel.click("create")
33
        sel.click("small")
34
        sel.click("//div[@id='wizard']/div/div[1]/button[2]")
35
        sleep(2)
36
        sel.click("medium")
37
        sleep(2)
38
        try: self.assertEqual("2048", sel.get_value("ram-indicator"))
39
        except AssertionError, e: self.verificationErrors.append(str(e))
40
        try: self.assertEqual("2", sel.get_value("cpu-indicator"))
41
        except AssertionError, e: self.verificationErrors.append(str(e))
42
        try: self.assertEqual("40", sel.get_value("storage-indicator"))
43
        except AssertionError, e: self.verificationErrors.append(str(e))
44
        sleep(2)
45
        sel.click("//div[@id='wizard']/div/div[2]/button[2]")
46
        sleep(2)
47
        self.assertEqual("2", sel.get_text("machine_cpu-label"))
48
        self.assertEqual("2048", sel.get_text("machine_ram-label"))
49
        self.assertEqual("40", sel.get_text("machine_storage-label"))
50
        sel.click("start")
51
        sleep(2)
52
        try: self.failUnless(sel.is_text_present("Success"))
53
        except AssertionError, e: self.verificationErrors.append(str(e))
54

    
55
        #self.assertEqual("Success!", sel.get_text("//div[@id='error-success']/h3"))
56
        #sel.click("//div[@id='error-success']/a")
57
        #try: self.failUnless(sel.is_text_present("My Debian Unstable server"))
58
        #except AssertionError, e: self.verificationErrors.append(str(e))
59