<commit_before># Copyright 2014 Hewlett-Packard Development Company, L.P
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from tempest.api.identity import base
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators

CONF = config.CONF


class BaseListProjectsTestJSON(base.BaseIdentityV3AdminTest):

    def _list_projects_with_params(self, included, excluded, params, key):
        # Validate that projects in ``included`` belongs to the projects
        # returned that match ``params`` but not projects in ``excluded``
        body = self.projects_client.list_projects(params)['projects']
        for p in included:
            self.assertIn(p[key], map(lambda x: x[key], body))
        for p in excluded:
            self.assertNotIn(p[key], map(lambda x: x[key], body))


class ListProjectsTestJSON(BaseListProjectsTestJSON):

    @classmethod
    def resource_setup(cls):
        super(ListProjectsTestJSON, cls).resource_setup()
        cls.project_ids = list()
        # Create a domain
        cls.domain = cls.create_domain()
        # Create project with domain
        cls.p1_name = data_utils.rand_name('project')
        cls.p1 = cls.projects_client.create_project(
            cls.p1_name, enabled=False,
            domain_id=cls.domain['id'])['project']
        cls.addClassResourceCleanup(cls.projects_client.delete_project,
                                    cls.p1['id'])<commit_msg>Use credentials domain instead of creating new one<commit_after># Copyright 2014 Hewlett-Packard Development Company, L.P
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from oslo_log import log as logging

from tempest.api.identity import base
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators

LOG = logging.getLogger(__name__)
CONF = config.CONF


class BaseListProjectsTestJSON(base.BaseIdentityV3AdminTest):

    def _list_projects_with_params(self, included, excluded, params, key):
        # Validate that projects in ``included`` belongs to the projects
        # returned that match ``params`` but not projects in ``excluded``
        all_projects = self.projects_client.list_projects()['projects']
        LOG.debug("Complete list of projects available in keystone: %s",
                  all_projects)
        body = self.projects_client.list_projects(params)['projects']
        for p in included:
            self.assertIn(p[key], map(lambda x: x[key], body))
        for p in excluded:
            self.assertNotIn(p[key], map(lambda x: x[key], body))


class ListProjectsTestJSON(BaseListProjectsTestJSON):

    @classmethod
    def resource_setup(cls):
        super(ListProjectsTestJSON, cls).resource_setup()
        cls.project_ids = list()
        cls.domain_id = cls.os_admin.credentials.domain_id
        # Create project with domain
        cls.p1_name = data_utils.rand_name('project')
        cls.p1 = cls.projects_client.create_project(
            cls.p1_name, enabled=False,
            domain_id=cls.domain_id)['project']
        cls.addClassResourceCleanup(cls.projects_client.delete_project,
                                    cls.p1['id'])
{'fraction_non_alphanumeric': 0.08531468531468532, 'fraction_numerical': 0.006060606060606061, 'mean_word_length': 3.1904296875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5320016', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1163, 'n_words': 380}