Commit 2d02d1fd authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

helpdesk: Update tests

use existing cyclades db factories instead of json fixtures which are painful
to maintain
parent 3dcf4a73
[
{
"model": "db.VirtualMachine",
"pk": 1001,
"fields": {
"userid": "5edcb5aa-1111-4146-a8ed-2b6287824353",
"name": "user1 vm",
"created": "2011-02-06 00:00:00",
"updated": "2011-02-06 00:00:00",
"imageid": "1",
"hostid": "HAL-9000",
"flavor": 1,
"operstate": "STOPPED"
}
},
{
"model": "db.VirtualMachine",
"pk": 1002,
"fields": {
"userid": "5edcb5aa-2222-4146-a8ed-2b6287824353",
"name": "user2 vm1",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"imageid": "1",
"hostid": "HAL-9000",
"flavor": 1,
"operstate": "BUILD"
}
},
{
"model": "db.VirtualMachine",
"pk": 1003,
"fields": {
"userid": "5edcb5aa-2222-4146-a8ed-2b6287824353",
"name": "user2 vm2",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"imageid": "1",
"hostid": "HAL-9000",
"flavor": 1,
"operstate": "BUILD"
}
},
{
"model": "db.VirtualMachineMetadata",
"pk": 1,
"fields": {
"meta_key": "OS",
"meta_value": "debian",
"vm": 1001
}
},
{
"model": "db.Flavor",
"pk": 1,
"fields": {
"cpu": 1,
"ram": 1024,
"disk": 20
}
},
{
"model": "db.Network",
"pk": 1,
"fields": {
"name": "public",
"created": "2011-04-01",
"updated": "2011-04-01",
"state": "ACTIVE",
"public": 1,
"link": 1
}
},
{
"model": "db.NetworkInterface",
"pk": 2,
"fields": {
"index": 0,
"ipv4": "195.251.222.211",
"network": 2,
"machine": 1002
}
},
{
"model": "db.Network",
"pk": 2,
"fields": {
"name": "public",
"created": "2011-04-01",
"updated": "2011-04-01",
"state": "ACTIVE",
"public": 0,
"link": 1,
"userid": "5edcb5aa-1111-4146-a8ed-2b6287824353"
}
},
{
"model": "db.NetworkInterface",
"pk": 1,
"fields": {
"index": 0,
"machine": 1,
"network": 1,
"mac": "00:11"
}
}
]
......@@ -98,13 +98,26 @@ class HelpdeskTests(TestCase):
Helpdesk tests. Test correctness of permissions and returned data.
"""
fixtures = ['helpdesk_test']
def setUp(self):
settings.SKIP_SSH_VALIDATION = True
settings.HELPDESK_ENABLED = True
self.client = AuthClient()
# init models
vm1u1 = mfactory.VirtualMachineFactory(userid=USER1, name="user1 vm",
pk=1001)
vm1u2 = mfactory.VirtualMachineFactory(userid=USER2, name="user2 vm1",
pk=1002)
vm2u2 = mfactory.VirtualMachineFactory(userid=USER2, name="user2 vm2",
pk=1003)
netpub = mfactory.NetworkFactory(public=True)
net1u1 = mfactory.NetworkFactory(public=False, userid=USER1)
nic1 = mfactory.NetworkInterfaceFactory(machine=vm1u2, network=net1u1)
nic2 = mfactory.NetworkInterfaceFactory(machine=vm1u1, network=netpub,
ipv4="195.251.222.211")
def test_enabled_setting(self):
settings.HELPDESK_ENABLED = False
......@@ -125,7 +138,7 @@ class HelpdeskTests(TestCase):
# ip exists, 'test' account discovered
r = self.client.get(reverse('helpdesk-details',
args=["195.251.222.211"]), user_token='0001')
self.assertEqual(r.context['account'], USER2)
self.assertEqual(r.context['account'], USER1)
def test_vm_lookup(self):
# vm id does not exist
......@@ -224,7 +237,7 @@ class HelpdeskTests(TestCase):
self.assertEqual(account, USER1)
self.assertEqual(vms[0].name, "user1 vm")
self.assertEqual(vms.count(), 1)
self.assertEqual(len(nets), 1)
self.assertEqual(len(nets), 2)
self.assertEqual(r.context['account_exists'], True)
# 'testuser2@test.com' details, see helpdesk
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment