Example #1
0
    def test_check_stack_with_stack_object(self, mock_check):
        stk = stack.Stack(id='FAKE_ID')

        res = self.proxy.check_stack(stk)

        self.assertIsNone(res)
        mock_check.assert_called_once_with(self.proxy.session)
Example #2
0
    def test_create(self, mock_create):
        sess = mock.Mock()
        sot = stack.Stack(FAKE)

        res = sot.create(sess)

        mock_create.assert_called_once_with(sess, prepend_key=False)
        self.assertEqual(mock_create.return_value, res)
Example #3
0
    def test_check(self):
        sess = mock.Mock()
        sot = stack.Stack(**FAKE)
        sot._action = mock.Mock()
        body = {'check': ''}

        sot.check(sess)

        sot._action.assert_called_with(sess, body)
Example #4
0
 def test_basic(self):
     sot = stack.Stack()
     self.assertEqual('stack', sot.resource_key)
     self.assertEqual('stacks', sot.resources_key)
     self.assertEqual('/stacks', sot.base_path)
     self.assertEqual('orchestration', sot.service.service_type)
     self.assertTrue(sot.allow_create)
     self.assertTrue(sot.allow_get)
     self.assertTrue(sot.allow_update)
     self.assertTrue(sot.allow_delete)
     self.assertTrue(sot.allow_list)
Example #5
0
    def test_resources_with_stack_object(self, mock_find):
        stack_id = '1234'
        stack_name = 'test_stack'
        stk = stack.Stack(id=stack_id, name=stack_name)

        self.verify_list(self.proxy.resources, resource.Resource,
                         paginated=False, method_args=[stk],
                         expected_kwargs={'stack_name': stack_name,
                                          'stack_id': stack_id})

        self.assertEqual(0, mock_find.call_count)
Example #6
0
    def test_resources_with_stack_name(self, mock_find):
        stack_id = '1234'
        stack_name = 'test_stack'
        stk = stack.Stack(id=stack_id, name=stack_name)
        mock_find.return_value = stk

        self.verify_list(self.proxy.resources, resource.Resource,
                         paginated=False, method_args=[stack_id],
                         expected_kwargs={'stack_name': stack_name,
                                          'stack_id': stack_id})

        mock_find.assert_called_once_with(mock.ANY, stack_id,
                                          ignore_missing=True)
Example #7
0
    def test_get(self, mock_get):
        sess = mock.Mock()
        sot = stack.Stack(**FAKE)
        deleted_stack = mock.Mock(id=FAKE_ID, status='DELETE_COMPLETE')
        normal_stack = mock.Mock(status='CREATE_COMPLETE')
        mock_get.side_effect = [
            normal_stack,
            exceptions.NotFoundException(message='oops'),
            deleted_stack,
        ]

        self.assertEqual(normal_stack, sot.get(sess))
        ex = self.assertRaises(exceptions.NotFoundException, sot.get, sess)
        self.assertEqual('NotFoundException: oops', six.text_type(ex))
        ex = self.assertRaises(exceptions.NotFoundException, sot.get, sess)
        self.assertEqual('NotFoundException: No stack found for %s' % FAKE_ID,
                         six.text_type(ex))
Example #8
0
 def test_make_it(self):
     sot = stack.Stack(**FAKE)
     self.assertEqual(FAKE['capabilities'], sot.capabilities)
     self.assertEqual(FAKE['creation_time'], sot.created_at)
     self.assertEqual(FAKE['description'], sot.description)
     self.assertTrue(sot.is_rollback_disabled)
     self.assertEqual(FAKE['id'], sot.id)
     self.assertEqual(FAKE['links'], sot.links)
     self.assertEqual(FAKE['notification_topics'], sot.notification_topics)
     self.assertEqual(FAKE['outputs'], sot.outputs)
     self.assertEqual(FAKE['parameters'], sot.parameters)
     self.assertEqual(FAKE['name'], sot.name)
     self.assertEqual(FAKE['status'], sot.status)
     self.assertEqual(FAKE['status_reason'], sot.status_reason)
     self.assertEqual(FAKE['template_description'],
                      sot.template_description)
     self.assertEqual(FAKE['template_url'], sot.template_url)
     self.assertEqual(FAKE['timeout_mins'], sot.timeout_mins)
     self.assertEqual(FAKE['updated_time'], sot.updated_at)