Revision c0124a81

b/README
9 9
    $ virtualenv --python=python2.6 synnefo --no-site-packages
10 10
    ...
11 11
    $ cd synnefo
12
    $ ./bin/pip install django django-piston pycurl simplejson
12
    $ ./bin/pip install django django-piston pycurl simplejson selenium
13 13
    ...
14 14
    ...
15 15
    $ cp settings.py.dist settings.py
b/db/tests.py
17 17
from django.conf import settings
18 18
from django.contrib.auth.models import User
19 19
from django.test import TestCase
20
import unittest
21 20

  
22 21
class CreditAllocatorTestCase(TestCase):
23 22
    fixtures = [ 'db_test_data' ]
b/ui/tests.py
1
"""
2
This file demonstrates two different styles of tests (one doctest and one
3
unittest). These will both pass when you run "manage.py test".
4

  
5
Replace these with more appropriate tests for your application.
6
"""
7

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

  
10
class SimpleTest(TestCase):
11
    def test_basic_addition(self):
12
        """
13
        Tests that 1 + 1 always equals 2.
14
        """
15
        self.failUnlessEqual(1 + 1, 2)
6
class FunctionalCase(TestCase):
7
    """
8
    Functional tests for synnefo.ui using Selenium
9
    """
16 10

  
17
__test__ = {"doctest": """
18
Another way to test that 1 + 1 is equal to 2.
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()
19 18

  
20
>>> 1 + 1 == 2
21
True
22
"""}
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))
23 53

  

Also available in: Unified diff