def mock_manager(self):
        manager = StackManager(None)
        manager._list = MagicMock()

        def mock_list(arg_url, arg_response_key):
            try:
                result = self.results[self.result_index]
            except IndexError:
                return []
            self.result_index = self.result_index + 1

            limit_string = 'limit=%s' % self.limit
            self.assertIn(limit_string, arg_url)

            offset = result[0]
            if offset > 0:
                offset_string = 'marker=abcd1234-%s' % offset
                self.assertIn(offset_string, arg_url)

            def results():

                for i in range(*result):
                    self.limit -= 1
                    stack_name = 'stack_%s' % (i + 1)
                    stack_id = 'abcd1234-%s' % (i + 1)
                    yield mock_stack(manager, stack_name, stack_id)

            return list(results())

        manager._list.side_effect = mock_list
        return manager
    def mock_manager(self):
        manager = StackManager(None)
        manager._list = MagicMock()

        def mock_list(arg_url, arg_response_key):
            try:
                result = self.results[self.result_index]
            except IndexError:
                return
            self.result_index = self.result_index + 1

            offset = result[0]
            url = '/stacks?'
            if offset > 0:
                url += 'marker=abcd1234-%s&' % offset
            url += 'limit=%s' % self.page_size
            self.assertEqual(url, arg_url)

            def results():

                for i in range(*result):
                    stack_name = 'stack_%s' % (i + 1)
                    stack_id = 'abcd1234-%s' % (i + 1)
                    yield mock_stack(manager, stack_name, stack_id)

            return list(results())

        manager._list.side_effect = mock_list
        return manager
    def mock_manager(self):
        manager = StackManager(None)
        manager._list = MagicMock()

        def mock_list(arg_url, arg_response_key):
            try:
                result = self.results[self.result_index]
            except IndexError:
                return []
            self.result_index = self.result_index + 1

            limit_string = 'limit=%s' % self.limit
            self.assertIn(limit_string, arg_url)

            offset = result[0]
            if offset > 0:
                offset_string = 'marker=abcd1234-%s' % offset
                self.assertIn(offset_string, arg_url)

            def results():

                for i in range(*result):
                    self.limit -= 1
                    stack_name = 'stack_%s' % (i + 1)
                    stack_id = 'abcd1234-%s' % (i + 1)
                    yield mock_stack(manager, stack_name, stack_id)

            return list(results())

        manager._list.side_effect = mock_list
        return manager
    def mock_manager(self):
        manager = StackManager(None)
        manager._list = MagicMock()

        def mock_list(*args, **kwargs):
            def results():
                for i in range(0, self.total):
                    stack_name = 'stack_%s' % (i + 1)
                    stack_id = 'abcd1234-%s' % (i + 1)
                    yield mock_stack(manager, stack_name, stack_id)

            return list(results())

        manager._list.side_effect = mock_list
        return manager
    def mock_manager(self):
        manager = StackManager(None)
        manager._list = MagicMock()

        def mock_list(*args, **kwargs):
            def results():
                for i in range(0, self.total):
                    stack_name = 'stack_%s' % (i + 1)
                    stack_id = 'abcd1234-%s' % (i + 1)
                    yield mock_stack(manager, stack_name, stack_id)

            return list(results())

        manager._list.side_effect = mock_list
        return manager
Beispiel #6
0
def data(TEST):
    TEST.stacks = TestDataContainer()
    TEST.stack_templates = TestDataContainer()

    # Stacks
    stack1 = {
        "description":
        "No description",
        "links": [{
            "href":
            "http://192.168.1.70:8004/v1/"
            "051c727ee67040d6a7b7812708485a97/"
            "stacks/stack-1211-38/"
            "05b4f39f-ea96-4d91-910c-e758c078a089",
            "rel":
            "self"
        }],
        "stack_status_reason":
        "Stack successfully created",
        "stack_name":
        "stack-test",
        "creation_time":
        "2013-04-22T00:11:39Z",
        "updated_time":
        "2013-04-22T00:11:39Z",
        "stack_status":
        "CREATE_COMPLETE",
        "id":
        "05b4f39f-ea96-4d91-910c-e758c078a089"
    }
    stack = Stack(StackManager(None), stack1)
    TEST.stacks.add(stack)

    TEST.stack_templates.add(Template(TEMPLATE, VALIDATE))