예제 #1
0
    def test_stack_get_all_by_tenant(self):
        values = [
            {
                'tenant': UUID1
            },
            {
                'tenant': UUID1
            },
            {
                'tenant': UUID2
            },
            {
                'tenant': UUID2
            },
            {
                'tenant': UUID2
            },
        ]
        [
            create_stack(self.ctx, self.template, self.user_creds, **val)
            for val in values
        ]

        self.ctx.tenant_id = UUID1
        stacks = db_api.stack_get_all_by_tenant(self.ctx)
        self.assertEqual(2, len(stacks))

        self.ctx.tenant_id = UUID2
        stacks = db_api.stack_get_all_by_tenant(self.ctx)
        self.assertEqual(3, len(stacks))

        self.ctx.tenant_id = UUID3
        self.assertEqual([], db_api.stack_get_all_by_tenant(self.ctx))
예제 #2
0
    def test_stack_get_all_by_tenant(self):
        stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]

        st_db = db_api.stack_get_all_by_tenant(self.ctx)
        self.assertEqual(3, len(st_db))

        stacks[0].delete()
        st_db = db_api.stack_get_all_by_tenant(self.ctx)
        self.assertEqual(2, len(st_db))

        stacks[1].delete()
        st_db = db_api.stack_get_all_by_tenant(self.ctx)
        self.assertEqual(1, len(st_db))
예제 #3
0
    def test_stack_get_all_by_tenant(self):
        stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]

        st_db = db_api.stack_get_all_by_tenant(self.ctx)
        self.assertEqual(2, len(st_db))

        stacks[0].delete()
        st_db = db_api.stack_get_all_by_tenant(self.ctx)
        self.assertEqual(1, len(st_db))

        stacks[1].delete()
        st_db = db_api.stack_get_all_by_tenant(self.ctx)
        self.assertEqual(0, len(st_db))
예제 #4
0
    def test_stack_get_all_by_tenant_default_sort_dir(self):
        stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]

        st_db = db_api.stack_get_all_by_tenant(self.ctx, sort_dir='asc')
        self.assertEqual(3, len(st_db))
        self.assertEqual(stacks[0].id, st_db[0].id)
        self.assertEqual(stacks[1].id, st_db[1].id)
        self.assertEqual(stacks[2].id, st_db[2].id)
예제 #5
0
    def test_stack_get_all_by_tenant_default_sort_dir(self):
        stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]

        st_db = db_api.stack_get_all_by_tenant(self.ctx, sort_dir='asc')
        self.assertEqual(3, len(st_db))
        self.assertEqual(stacks[0].id, st_db[0].id)
        self.assertEqual(stacks[1].id, st_db[1].id)
        self.assertEqual(stacks[2].id, st_db[2].id)
예제 #6
0
    def test_stack_get_all_by_tenant_str_sort_keys(self):
        stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]

        st_db = db_api.stack_get_all_by_tenant(self.ctx,
                                               sort_keys='created_at')
        self.assertEqual(3, len(st_db))
        self.assertEqual(stacks[0].id, st_db[0].id)
        self.assertEqual(stacks[1].id, st_db[1].id)
        self.assertEqual(stacks[2].id, st_db[2].id)
예제 #7
0
    def test_stack_get_all_by_tenant_str_sort_keys(self):
        stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]

        st_db = db_api.stack_get_all_by_tenant(self.ctx,
                                               sort_keys='created_at')
        self.assertEqual(3, len(st_db))
        self.assertEqual(stacks[0].id, st_db[0].id)
        self.assertEqual(stacks[1].id, st_db[1].id)
        self.assertEqual(stacks[2].id, st_db[2].id)
예제 #8
0
    def test_stack_get_all_by_tenant_filters_sort_keys(self, mock_paginate):
        sort_keys = ['name', 'status', 'created_at', 'updated_at', 'username']
        st_db = db_api.stack_get_all_by_tenant(self.ctx,
                                               sort_keys=sort_keys)

        args, _ = mock_paginate.call_args
        used_sort_keys = set(args[3])
        expected_keys = set(['name', 'status', 'created_at',
                             'updated_at', 'id'])
        self.assertEqual(expected_keys, used_sort_keys)
예제 #9
0
    def test_stack_get_all_by_tenant_returns_all_if_no_filters(self):
        stack1 = self._setup_test_stack('foo', UUID1)
        stack2 = self._setup_test_stack('bar', UUID2)
        stacks = [stack1, stack2]

        filters = None
        results = db_api.stack_get_all_by_tenant(self.ctx,
                                                 filters=filters)

        self.assertEqual(2, len(results))
예제 #10
0
    def test_stack_get_all_by_tenant_filters_sort_keys(self, mock_paginate):
        sort_keys = ['name', 'status', 'created_at', 'updated_at', 'username']
        st_db = db_api.stack_get_all_by_tenant(self.ctx,
                                               sort_keys=sort_keys)

        args, _ = mock_paginate.call_args
        used_sort_keys = set(args[3])
        expected_keys = set(['name', 'status', 'created_at',
                             'updated_at', 'id'])
        self.assertEqual(expected_keys, used_sort_keys)
예제 #11
0
    def test_stack_get_all_by_tenant_returns_all_if_no_filters(self):
        stack1 = self._setup_test_stack('foo', UUID1)
        stack2 = self._setup_test_stack('bar', UUID2)
        stacks = [stack1, stack2]

        filters = None
        results = db_api.stack_get_all_by_tenant(self.ctx,
                                                 filters=filters)

        self.assertEqual(2, len(results))
예제 #12
0
    def test_stack_get_all_by_tenant_filter_matches_in_list(self):
        stack1 = self._setup_test_stack('foo', UUID1)
        stack2 = self._setup_test_stack('bar', UUID2)
        stacks = [stack1, stack2]

        filters = {'name': ['bar', 'quux']}
        results = db_api.stack_get_all_by_tenant(self.ctx,
                                                 filters=filters)

        self.assertEqual(1, len(results))
        self.assertEqual('bar', results[0]['name'])
예제 #13
0
    def test_stack_get_all_by_tenant_filter_matches_in_list(self):
        stack1 = self._setup_test_stack('foo', UUID1)
        stack2 = self._setup_test_stack('bar', UUID2)
        stacks = [stack1, stack2]

        filters = {'name': ['bar', 'quux']}
        results = db_api.stack_get_all_by_tenant(self.ctx,
                                                 filters=filters)

        self.assertEqual(1, len(results))
        self.assertEqual('bar', results[0]['name'])
예제 #14
0
    def test_stack_get_all_by_tenant(self):
        values = [
            {'tenant': UUID1},
            {'tenant': UUID1},
            {'tenant': UUID2},
            {'tenant': UUID2},
            {'tenant': UUID2},
        ]
        [create_stack(self.ctx, self.template, self.user_creds,
                      **val) for val in values]

        self.ctx.tenant_id = UUID1
        stacks = db_api.stack_get_all_by_tenant(self.ctx)
        self.assertEqual(2, len(stacks))

        self.ctx.tenant_id = UUID2
        stacks = db_api.stack_get_all_by_tenant(self.ctx)
        self.assertEqual(3, len(stacks))

        self.ctx.tenant_id = UUID3
        self.assertEqual([], db_api.stack_get_all_by_tenant(self.ctx))
예제 #15
0
    def test_stack_get_all_by_tenant_marker(self):
        stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]

        st_db = db_api.stack_get_all_by_tenant(self.ctx, marker=stacks[1].id)
        self.assertEqual(1, len(st_db))
        self.assertEqual(stacks[0].id, st_db[0].id)
예제 #16
0
    def test_stack_get_all_by_tenant_doesnt_mutate_sort_keys(self):
        stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]
        sort_keys = ['id']

        st_db = db_api.stack_get_all_by_tenant(self.ctx, sort_keys=sort_keys)
        self.assertEqual(['id'], sort_keys)
예제 #17
0
    def test_stack_get_all_by_tenant_non_existing_marker(self):
        stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]

        uuid = 'this stack doesnt exist'
        st_db = db_api.stack_get_all_by_tenant(self.ctx, marker=uuid)
        self.assertEqual(3, len(st_db))
예제 #18
0
    def test_stack_get_all_by_tenant_marker(self):
        stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]

        st_db = db_api.stack_get_all_by_tenant(self.ctx, marker=stacks[1].id)
        self.assertEqual(1, len(st_db))
        self.assertEqual(stacks[0].id, st_db[0].id)
예제 #19
0
    def test_stack_get_all_by_tenant_non_existing_marker(self):
        stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]

        uuid = 'this stack doesnt exist'
        st_db = db_api.stack_get_all_by_tenant(self.ctx, marker=uuid)
        self.assertEqual(3, len(st_db))
예제 #20
0
    def test_stack_get_all_by_tenant_doesnt_mutate_sort_keys(self):
        stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]
        sort_keys = ['id']

        st_db = db_api.stack_get_all_by_tenant(self.ctx, sort_keys=sort_keys)
        self.assertEqual(['id'], sort_keys)