~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to heat/tests/test_engine_api_utils.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Yolanda Robla, Chuck Short
  • Date: 2013-07-22 16:22:29 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130722162229-zzvfu40id94ii0hc
Tags: 2013.2~b2-0ubuntu1
[ Yolanda Robla ]
* debian/tests: added autopkg tests

[ Chuck Short ]
* New upstream release
* debian/control:
  - Add python-pbr to build-depends.
  - Add python-d2to to build-depends.
  - Dropped python-argparse.
  - Add python-six to build-depends.
  - Dropped python-sendfile.
  - Dropped python-nose.
  - Added testrepository.
  - Added python-testtools.
* debian/rules: Run testrepository instead of nosetets.
* debian/patches/removes-lxml-version-limitation-from-pip-requires.patch: Dropped
  no longer needed.
* debian/patches/fix-package-version-detection-when-building-doc.patch: Dropped
  no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#    License for the specific language governing permissions and limitations
13
13
#    under the License.
14
14
 
15
 
 
16
 
import unittest
17
 
from nose.plugins.attrib import attr
18
 
 
 
15
from heat.common import context
19
16
import heat.engine.api as api
20
 
 
21
 
 
22
 
@attr(tag=['unit', 'engine-api'])
23
 
@attr(speed='fast')
24
 
class EngineApiTest(unittest.TestCase):
 
17
from heat.engine import parser
 
18
from heat.engine import resource
 
19
from heat.openstack.common import uuidutils
 
20
from heat.rpc import api as rpc_api
 
21
from heat.tests.common import HeatTestCase
 
22
from heat.tests import generic_resource as generic_rsrc
 
23
from heat.tests.utils import setup_dummy_db
 
24
 
 
25
 
 
26
class EngineApiTest(HeatTestCase):
25
27
    def test_timeout_extract(self):
26
28
        p = {'timeout_mins': '5'}
27
29
        args = api.extract_args(p)
75
77
    def test_disable_rollback_extract_bad(self):
76
78
        self.assertRaises(ValueError, api.extract_args,
77
79
                          {'disable_rollback': 'bad'})
 
80
 
 
81
 
 
82
class FormatTest(HeatTestCase):
 
83
 
 
84
    def setUp(self):
 
85
        super(FormatTest, self).setUp()
 
86
        setup_dummy_db()
 
87
        ctx = context.get_admin_context()
 
88
        self.m.StubOutWithMock(ctx, 'user')
 
89
        ctx.user = 'test_user'
 
90
        ctx.tenant_id = 'test_tenant'
 
91
 
 
92
        template = parser.Template({
 
93
            'Resources': {
 
94
                'generic1': {'Type': 'GenericResourceType'},
 
95
                'generic2': {
 
96
                    'Type': 'GenericResourceType',
 
97
                    'DependsOn': 'generic1'}
 
98
            }
 
99
        })
 
100
        resource._register_class('GenericResourceType',
 
101
                                 generic_rsrc.GenericResource)
 
102
        self.stack = parser.Stack(ctx, 'test_stack', template,
 
103
                                  stack_id=uuidutils.generate_uuid())
 
104
 
 
105
    def test_format_stack_resource(self):
 
106
        res = self.stack['generic1']
 
107
 
 
108
        resource_keys = set((
 
109
            rpc_api.RES_UPDATED_TIME,
 
110
            rpc_api.RES_NAME,
 
111
            rpc_api.RES_PHYSICAL_ID,
 
112
            rpc_api.RES_METADATA,
 
113
            rpc_api.RES_ACTION,
 
114
            rpc_api.RES_STATUS,
 
115
            rpc_api.RES_STATUS_DATA,
 
116
            rpc_api.RES_TYPE,
 
117
            rpc_api.RES_ID,
 
118
            rpc_api.RES_STACK_ID,
 
119
            rpc_api.RES_STACK_NAME,
 
120
            rpc_api.RES_REQUIRED_BY))
 
121
 
 
122
        resource_details_keys = resource_keys.union(set(
 
123
            (rpc_api.RES_DESCRIPTION, rpc_api.RES_METADATA)))
 
124
 
 
125
        formatted = api.format_stack_resource(res, True)
 
126
        self.assertEqual(resource_details_keys, set(formatted.keys()))
 
127
 
 
128
        formatted = api.format_stack_resource(res, False)
 
129
        self.assertEqual(resource_keys, set(formatted.keys()))
 
130
 
 
131
    def test_format_stack_resource_required_by(self):
 
132
        res1 = api.format_stack_resource(self.stack['generic1'])
 
133
        res2 = api.format_stack_resource(self.stack['generic2'])
 
134
        self.assertEqual(res1['required_by'], ['generic2'])
 
135
        self.assertEqual(res2['required_by'], [])