root / ui / tests.py @ c0124a81
History | View | Annotate | Download (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 |
sel.click("medium")
|
36 |
sleep(.5)
|
37 |
try: self.assertEqual("2048", sel.get_value("ram-indicator")) |
38 |
except AssertionError, e: self.verificationErrors.append(str(e)) |
39 |
try: self.assertEqual("2", sel.get_value("cpu-indicator")) |
40 |
except AssertionError, e: self.verificationErrors.append(str(e)) |
41 |
try: self.assertEqual("40", sel.get_value("storage-indicator")) |
42 |
except AssertionError, e: self.verificationErrors.append(str(e)) |
43 |
sel.click("//div[@id='wizard']/div/div[2]/button[2]")
|
44 |
sleep(.5)
|
45 |
self.assertEqual("2", sel.get_text("machine_cpu-label")) |
46 |
self.assertEqual("Debian Squeeze", sel.get_text("machine_image-label")) |
47 |
self.assertEqual("2048", sel.get_text("machine_ram-label")) |
48 |
self.assertEqual("40", sel.get_text("machine_storage-label")) |
49 |
sel.click("start")
|
50 |
sleep(.5)
|
51 |
try: self.failUnless(sel.is_text_present("Success")) |
52 |
except AssertionError, e: self.verificationErrors.append(str(e)) |
53 |
|