1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import
from django import http
from django.conf import settings
from django.test.utils import override_settings
from mox import IsA
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
import openstack_dashboard.dashboards.infrastructure.models as dummymodels
class TuskarApiTests(test.APITestCase):
def test_resource_class_list(self):
rcs = self.tuskar_resource_classes.list()
tuskarclient = self.stub_tuskarclient()
tuskarclient.resource_classes = self.mox.CreateMockAnything()
tuskarclient.resource_classes.list().AndReturn(rcs)
self.mox.ReplayAll()
ret_val = api.tuskar.ResourceClass.list(self.request)
for rc in ret_val:
self.assertIsInstance(rc, api.tuskar.ResourceClass)
def test_resource_class_get(self):
rc = self.tuskar_resource_classes.first()
tuskarclient = self.stub_tuskarclient()
tuskarclient.resource_classes = self.mox.CreateMockAnything()
tuskarclient.resource_classes.get(rc.id).AndReturn(rc)
self.mox.ReplayAll()
ret_val = api.tuskar.ResourceClass.get(self.request, rc.id)
self.assertIsInstance(ret_val, api.tuskar.ResourceClass)
def test_resource_class_flavor_counts(self):
rc = self.tuskar_resource_classes.first()
for f in rc.resource_class_flavors:
self.assertIsInstance(f, api.tuskar.ResourceClassFlavor)
self.assertEquals(7, len(rc.resource_class_flavors))
def test_resource_class_racks(self):
rc = self.tuskar_resource_classes.first()
for rack in rc.list_racks:
self.assertIsInstance(rack, api.tuskar.Rack)
self.assertEquals(2, len(rc.list_racks))
def test_resource_class_nodes(self):
rc = self.tuskar_resource_classes.first()
for node in rc.nodes:
self.assertIsInstance(node, api.tuskar.Node)
self.assertEquals(4, len(rc.nodes))
# TODO: create, delete operations
def test_flavor_list(self):
flist = api.tuskar.Flavor.list(self.request)
self.assertEquals(7, len(flist))
for f in flist:
self.assertIsInstance(f, api.tuskar.Flavor)
def test_flavor_get(self):
test_flavor = self.tuskar_flavors.first()
flavor = api.tuskar.Flavor.get(self.request, test_flavor.id)
self.assertIsInstance(flavor, api.tuskar.Flavor)
self.assertEquals(flavor.name, test_flavor.name)
|