Statistics
| Branch: | Tag: | Revision:

root / ui / tests.py @ f533f224

History | View | Annotate | Download (2.3 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
    def tearDown(self):
20
        """Kill processes"""
21
        TestCase.tearDown(self)
22
        self.selenium.stop()
23
        self.assertEqual([], self.verificationErrors)
24

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

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