~matsubara/maas/packaging.quantal-remove-adt-header

« back to all changes in this revision

Viewing changes to debian/tests/maas-integration.py

  • Committer: Diogo Matsubara
  • Date: 2013-02-14 18:30:53 UTC
  • Revision ID: diogo.matsubara@canonical.com-20130214183053-19ykdcq2cauhjfjk
remove old integration tests from packaging branch. The tests are maintained outside of the packaging branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# TODO
2
 
#  - send ipmi commands to turn on/off nodes
3
 
#  - run import pxe files
4
 
#  - check node states once they're on/off
5
 
#  - check node state changes (declared -> commissionig -> ready)
6
 
import os
7
 
from subprocess import check_output
8
 
import sys
9
 
from unittest import TestCase
10
 
 
11
 
from pyvirtualdisplay import Display
12
 
from sst.actions import (
13
 
    assert_url, assert_text_contains, assert_title_contains, click_button,
14
 
    get_element, go_to, write_textfield)
15
 
 
16
 
 
17
 
sys.path.insert(0, "/usr/share/maas")
18
 
os.environ['DJANGO_SETTINGS_MODULE'] = 'maas.settings'
19
 
from maasserver.models import User
20
 
 
21
 
MAAS_URL = "http://10.98.0.13/MAAS"
22
 
ADMIN_USER = "admin"
23
 
PASSWORD = "test"
24
 
 
25
 
 
26
 
class TestMAASIntegration(TestCase):
27
 
 
28
 
    def setUp(self):
29
 
        self.display = Display(visible=0, size=(1280, 1024))
30
 
        self.display.start()
31
 
 
32
 
    def tearDown(self):
33
 
        self.display.stop()
34
 
 
35
 
    def createadmin(self):
36
 
        """Run sudo maas createsuperuser."""
37
 
        cmd_output = check_output(
38
 
            ["sudo", "maas", "createsuperuser", "--username=%s" % ADMIN_USER,
39
 
            "--email=example@canonical.com", "--noinput"])
40
 
        ## Set password for admin user.
41
 
        try:
42
 
            admin = User.objects.get(username=ADMIN_USER)
43
 
        except User.DoesNotExist:
44
 
            admin = User(username=ADMIN_USER)
45
 
        admin.set_password(PASSWORD)
46
 
        admin.save()
47
 
        return cmd_output
48
 
 
49
 
    def installation(self):
50
 
        # Check the installation worked.
51
 
        go_to(MAAS_URL)
52
 
        assert_text_contains(
53
 
            get_element(tag="body"), "No admin user has been created yet")
54
 
 
55
 
    def createadmin_and_login(self):
56
 
        ## Creates the admin user.
57
 
        output = self.createadmin()
58
 
        self.assertEqual(output, 'Superuser created successfully.')
59
 
        ## Login with the newly created admin user
60
 
        go_to(MAAS_URL)
61
 
        assert_text_contains(
62
 
            get_element(tag="body"), "Login to lenovo-RD230-01 MAAS")
63
 
        write_textfield("id_username", ADMIN_USER)
64
 
        write_textfield("id_password", PASSWORD)
65
 
        click_button("Login")
66
 
        assert_url("MAAS/")
67
 
        assert_title_contains("Dashboard")
68
 
 
69
 
    def test_integration(self):
70
 
        # Run the integration tests in order.
71
 
        self.installation()
72
 
        self.createadmin_and_login()