Statistics
| Branch: | Tag: | Revision:

root / ui / tests.py @ 2ab5aa9a

History | View | Annotate | Download (3.8 kB)

1 a5bc3755 Vangelis Koukis
# Copyright 2011 GRNET S.A. All rights reserved.
2 a5bc3755 Vangelis Koukis
# 
3 a5bc3755 Vangelis Koukis
# Redistribution and use in source and binary forms, with or
4 a5bc3755 Vangelis Koukis
# without modification, are permitted provided that the following
5 a5bc3755 Vangelis Koukis
# conditions are met:
6 a5bc3755 Vangelis Koukis
# 
7 a5bc3755 Vangelis Koukis
#   1. Redistributions of source code must retain the above
8 a5bc3755 Vangelis Koukis
#      copyright notice, this list of conditions and the following
9 a5bc3755 Vangelis Koukis
#      disclaimer.
10 a5bc3755 Vangelis Koukis
# 
11 a5bc3755 Vangelis Koukis
#   2. Redistributions in binary form must reproduce the above
12 a5bc3755 Vangelis Koukis
#      copyright notice, this list of conditions and the following
13 a5bc3755 Vangelis Koukis
#      disclaimer in the documentation and/or other materials
14 a5bc3755 Vangelis Koukis
#      provided with the distribution.
15 a5bc3755 Vangelis Koukis
# 
16 a5bc3755 Vangelis Koukis
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 a5bc3755 Vangelis Koukis
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 a5bc3755 Vangelis Koukis
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 a5bc3755 Vangelis Koukis
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 a5bc3755 Vangelis Koukis
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 a5bc3755 Vangelis Koukis
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 a5bc3755 Vangelis Koukis
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 a5bc3755 Vangelis Koukis
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 a5bc3755 Vangelis Koukis
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 a5bc3755 Vangelis Koukis
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 a5bc3755 Vangelis Koukis
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 a5bc3755 Vangelis Koukis
# POSSIBILITY OF SUCH DAMAGE.
28 a5bc3755 Vangelis Koukis
# 
29 a5bc3755 Vangelis Koukis
# The views and conclusions contained in the software and
30 a5bc3755 Vangelis Koukis
# documentation are those of the authors and should not be
31 a5bc3755 Vangelis Koukis
# interpreted as representing official policies, either expressed
32 a5bc3755 Vangelis Koukis
# or implied, of GRNET S.A.
33 a5bc3755 Vangelis Koukis
# 
34 ce124269 Dimitris Moraitis
from django.test import TestCase
35 c0124a81 Dimitris Moraitis
from selenium import selenium
36 c0124a81 Dimitris Moraitis
from multiprocessing import Process
37 c0124a81 Dimitris Moraitis
from time import sleep
38 ce124269 Dimitris Moraitis
39 c0124a81 Dimitris Moraitis
class FunctionalCase(TestCase):
40 c0124a81 Dimitris Moraitis
    """
41 c0124a81 Dimitris Moraitis
    Functional tests for synnefo.ui using Selenium
42 c0124a81 Dimitris Moraitis
    """
43 ce124269 Dimitris Moraitis
44 c0124a81 Dimitris Moraitis
    def setUp(self):
45 c0124a81 Dimitris Moraitis
        """Make the selenium connection"""
46 c0124a81 Dimitris Moraitis
        TestCase.setUp(self)
47 c0124a81 Dimitris Moraitis
        self.verificationErrors = []
48 c0124a81 Dimitris Moraitis
        self.selenium = selenium("localhost", 4444, "*firefox",
49 c0124a81 Dimitris Moraitis
                                 "http://localhost:8000/")
50 c0124a81 Dimitris Moraitis
        self.selenium.start()
51 ce124269 Dimitris Moraitis
52 c0124a81 Dimitris Moraitis
    def tearDown(self):
53 c0124a81 Dimitris Moraitis
        """Kill processes"""
54 c0124a81 Dimitris Moraitis
        TestCase.tearDown(self)
55 c0124a81 Dimitris Moraitis
        self.selenium.stop()
56 c0124a81 Dimitris Moraitis
        self.assertEqual([], self.verificationErrors)
57 e646ebe5 Dimitris Moraitis
58 c0124a81 Dimitris Moraitis
    def test_wizard(self):
59 c0124a81 Dimitris Moraitis
        sel = self.selenium
60 c0124a81 Dimitris Moraitis
        sel.open("/")
61 c0124a81 Dimitris Moraitis
        sel.wait_for_page_to_load("10000")
62 c0124a81 Dimitris Moraitis
        self.failUnless(sel.is_text_present("machines"))
63 c0124a81 Dimitris Moraitis
        sleep(2)
64 c0124a81 Dimitris Moraitis
        sel.click("create")
65 c0124a81 Dimitris Moraitis
        sel.click("small")
66 c0124a81 Dimitris Moraitis
        sel.click("//div[@id='wizard']/div/div[1]/button[2]")
67 0ad5737e Dimitris Moraitis
        sleep(2)
68 c0124a81 Dimitris Moraitis
        sel.click("medium")
69 0ad5737e Dimitris Moraitis
        sleep(2)
70 e646ebe5 Dimitris Moraitis
        try:
71 e646ebe5 Dimitris Moraitis
            self.assertEqual("2048", sel.get_value("ram-indicator"))
72 e646ebe5 Dimitris Moraitis
        except AssertionError, e:
73 e646ebe5 Dimitris Moraitis
            self.verificationErrors.append(str(e))
74 e646ebe5 Dimitris Moraitis
        try:
75 e646ebe5 Dimitris Moraitis
            self.assertEqual("2", sel.get_value("cpu-indicator"))
76 e646ebe5 Dimitris Moraitis
        except AssertionError, e:
77 e646ebe5 Dimitris Moraitis
            self.verificationErrors.append(str(e))
78 e646ebe5 Dimitris Moraitis
        try:
79 e646ebe5 Dimitris Moraitis
            self.assertEqual("40", sel.get_value("storage-indicator"))
80 e646ebe5 Dimitris Moraitis
        except AssertionError, e:
81 e646ebe5 Dimitris Moraitis
            self.verificationErrors.append(str(e))
82 0ad5737e Dimitris Moraitis
        sleep(2)
83 c0124a81 Dimitris Moraitis
        sel.click("//div[@id='wizard']/div/div[2]/button[2]")
84 0ad5737e Dimitris Moraitis
        sleep(2)
85 c0124a81 Dimitris Moraitis
        self.assertEqual("2", sel.get_text("machine_cpu-label"))
86 c0124a81 Dimitris Moraitis
        self.assertEqual("2048", sel.get_text("machine_ram-label"))
87 c0124a81 Dimitris Moraitis
        self.assertEqual("40", sel.get_text("machine_storage-label"))
88 c0124a81 Dimitris Moraitis
        sel.click("start")
89 0ad5737e Dimitris Moraitis
        sleep(2)
90 e646ebe5 Dimitris Moraitis
        try:
91 e646ebe5 Dimitris Moraitis
            self.failUnless(sel.is_text_present("Success"))
92 e646ebe5 Dimitris Moraitis
        except AssertionError, e:
93 e646ebe5 Dimitris Moraitis
            self.verificationErrors.append(str(e))
94 ce124269 Dimitris Moraitis
95 e646ebe5 Dimitris Moraitis
        #self.assertEqual("Success!",
96 e646ebe5 Dimitris Moraitis
        #                 sel.get_text("//div[@id='error-success']/h3"))
97 0ad5737e Dimitris Moraitis
        #sel.click("//div[@id='error-success']/a")
98 0ad5737e Dimitris Moraitis
        #try: self.failUnless(sel.is_text_present("My Debian Unstable server"))
99 0ad5737e Dimitris Moraitis
        #except AssertionError, e: self.verificationErrors.append(str(e))