Example #1
0
    def test_delete_bad_name(self):
        identity = identifier.HeatIdentifier(self.tenant, 'wibble', '6')
        template = {u'Foo': u'bar'}
        json_template = json.dumps(template)
        parameters = {u'InstanceType': u'm1.xlarge'}
        body = {
            'template': template,
            'parameters': parameters,
            'timeout_mins': 30
        }

        req = self._delete('/stacks/%(stack_name)s/%(stack_id)s' % identity)

        self.m.StubOutWithMock(rpc, 'call')
        # Engine returns None when delete successful
        rpc.call(
            req.context, self.topic, {
                'method': 'delete_stack',
                'args': {
                    'stack_identity': dict(identity)
                },
                'version': self.api_version
            }, None).AndRaise(rpc_common.RemoteError("AttributeError"))
        self.m.ReplayAll()

        self.assertRaises(webob.exc.HTTPNotFound,
                          self.controller.delete,
                          req,
                          tenant_id=identity.tenant,
                          stack_name=identity.stack_name,
                          stack_id=identity.stack_id)
        self.m.VerifyAll()
Example #2
0
    def test_index_rmt_interr(self):
        req = self._get('/stacks')

        self.m.StubOutWithMock(rpc, 'call')
        rpc.call(
            req.context, self.topic, {
                'method': 'show_stack',
                'args': {
                    'stack_identity': None
                },
                'version': self.api_version
            }, None).AndRaise(rpc_common.RemoteError("Exception"))
        self.m.ReplayAll()

        self.assertRaises(webob.exc.HTTPInternalServerError,
                          self.controller.index,
                          req,
                          tenant_id=self.tenant)
        self.m.VerifyAll()
Example #3
0
    def test_lookup_nonexistant(self):
        stack_name = 'wibble'

        req = self._get('/stacks/%(stack_name)s' % locals())

        self.m.StubOutWithMock(rpc, 'call')
        rpc.call(
            req.context, self.topic, {
                'method': 'identify_stack',
                'args': {
                    'stack_name': stack_name
                },
                'version': self.api_version
            }, None).AndRaise(rpc_common.RemoteError("AttributeError"))
        self.m.ReplayAll()

        self.assertRaises(webob.exc.HTTPNotFound,
                          self.controller.lookup,
                          req,
                          tenant_id=self.tenant,
                          stack_name=stack_name)
        self.m.VerifyAll()
Example #4
0
    def test_show_aterr(self):
        identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '6')

        req = self._get('/stacks/%(stack_name)s/%(stack_id)s' % identity)

        self.m.StubOutWithMock(rpc, 'call')
        rpc.call(
            req.context, self.topic, {
                'method': 'show_stack',
                'args': {
                    'stack_identity': dict(identity)
                },
                'version': self.api_version
            }, None).AndRaise(rpc_common.RemoteError("AttributeError"))
        self.m.ReplayAll()

        self.assertRaises(webob.exc.HTTPNotFound,
                          self.controller.show,
                          req,
                          tenant_id=identity.tenant,
                          stack_name=identity.stack_name,
                          stack_id=identity.stack_id)
        self.m.VerifyAll()
Example #5
0
    def test_create_err_rpcerr(self):
        stack_name = "wordpress"
        template = {u'Foo': u'bar'}
        parameters = {u'InstanceType': u'm1.xlarge'}
        json_template = json.dumps(template)
        body = {
            'template': template,
            'stack_name': stack_name,
            'parameters': parameters,
            'timeout_mins': 30
        }

        req = self._post('/stacks', json.dumps(body))

        self.m.StubOutWithMock(rpc, 'call')
        rpc.call(
            req.context, self.topic, {
                'method': 'create_stack',
                'args': {
                    'stack_name': stack_name,
                    'template': template,
                    'params': parameters,
                    'args': {
                        'timeout_mins': 30
                    }
                },
                'version': self.api_version
            }, None).AndRaise(rpc_common.RemoteError("AttributeError"))
        self.m.ReplayAll()

        self.assertRaises(webob.exc.HTTPBadRequest,
                          self.controller.create,
                          req,
                          tenant_id=self.tenant,
                          body=body)
        self.m.VerifyAll()