Statistics
| Branch: | Tag: | Revision:

root / ui / tests.py @ 2ab5aa9a

History | View | Annotate | Download (3.8 kB)

1
# Copyright 2011 GRNET S.A. All rights reserved.
2
# 
3
# Redistribution and use in source and binary forms, with or
4
# without modification, are permitted provided that the following
5
# conditions are met:
6
# 
7
#   1. Redistributions of source code must retain the above
8
#      copyright notice, this list of conditions and the following
9
#      disclaimer.
10
# 
11
#   2. Redistributions in binary form must reproduce the above
12
#      copyright notice, this list of conditions and the following
13
#      disclaimer in the documentation and/or other materials
14
#      provided with the distribution.
15
# 
16
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
# POSSIBILITY OF SUCH DAMAGE.
28
# 
29
# The views and conclusions contained in the software and
30
# documentation are those of the authors and should not be
31
# interpreted as representing official policies, either expressed
32
# or implied, of GRNET S.A.
33
# 
34
from django.test import TestCase
35
from selenium import selenium
36
from multiprocessing import Process
37
from time import sleep
38

    
39
class FunctionalCase(TestCase):
40
    """
41
    Functional tests for synnefo.ui using Selenium
42
    """
43

    
44
    def setUp(self):
45
        """Make the selenium connection"""
46
        TestCase.setUp(self)
47
        self.verificationErrors = []
48
        self.selenium = selenium("localhost", 4444, "*firefox",
49
                                 "http://localhost:8000/")
50
        self.selenium.start()
51

    
52
    def tearDown(self):
53
        """Kill processes"""
54
        TestCase.tearDown(self)
55
        self.selenium.stop()
56
        self.assertEqual([], self.verificationErrors)
57

    
58
    def test_wizard(self):
59
        sel = self.selenium
60
        sel.open("/")
61
        sel.wait_for_page_to_load("10000")
62
        self.failUnless(sel.is_text_present("machines"))
63
        sleep(2)
64
        sel.click("create")
65
        sel.click("small")
66
        sel.click("//div[@id='wizard']/div/div[1]/button[2]")
67
        sleep(2)
68
        sel.click("medium")
69
        sleep(2)
70
        try:
71
            self.assertEqual("2048", sel.get_value("ram-indicator"))
72
        except AssertionError, e:
73
            self.verificationErrors.append(str(e))
74
        try:
75
            self.assertEqual("2", sel.get_value("cpu-indicator"))
76
        except AssertionError, e:
77
            self.verificationErrors.append(str(e))
78
        try:
79
            self.assertEqual("40", sel.get_value("storage-indicator"))
80
        except AssertionError, e:
81
            self.verificationErrors.append(str(e))
82
        sleep(2)
83
        sel.click("//div[@id='wizard']/div/div[2]/button[2]")
84
        sleep(2)
85
        self.assertEqual("2", sel.get_text("machine_cpu-label"))
86
        self.assertEqual("2048", sel.get_text("machine_ram-label"))
87
        self.assertEqual("40", sel.get_text("machine_storage-label"))
88
        sel.click("start")
89
        sleep(2)
90
        try:
91
            self.failUnless(sel.is_text_present("Success"))
92
        except AssertionError, e:
93
            self.verificationErrors.append(str(e))
94

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