<commit_before># Copyright (c) 2014 Mirantis, Inc.
#
# 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.

import os

from tempest import clients
from tempest.common import rest_client
import testtools

from mistralclient.api import base
from mistralclient.api.v1 import client as mclient


class ClientAuth(rest_client.RestClient):
    def __init__(self, auth_provider, url):
        super(ClientAuth, self).__init__(auth_provider)

        self.mistral_client = mclient.Client(
            auth_token=self.auth_provider.get_token(),
            mistral_url=url)


class MistralBase(testtools.TestCase):

    _mistral_url = None

    @classmethod
    def setUpClass(cls):
        super(MistralBase, cls).setUpClass()

        if 'WITHOUT_AUTH' in os.environ:
            cls.mistral_client = mclient.Client(
                mistral_url=cls._mistral_url)
        else:
            mgr = clients.Manager()
            cls.mistral_client = ClientAuth(
                mgr.auth_provider, cls._mistral_url).mistral_client

        cls.definition = open(os.path.relpath(
            'functionaltests/resources/v1/wb_v1.yaml',
            os.getcwd()), 'rb').read()

        cls.wb = cls.mistral_client.workbooks.create(<commit_msg>Fix client initialization in the integration tests<commit_after># Copyright (c) 2014 Mirantis, Inc.
#
# 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.

import os

from tempest import clients
from tempest.common import rest_client
from tempest import config
import testtools

from mistralclient.api import base
from mistralclient.api.v1 import client as mclient

CONF = config.CONF


class ClientAuth(rest_client.RestClient):
    def __init__(self, auth_provider, url):
        super(ClientAuth, self).__init__(
            auth_provider=auth_provider,
            service='workflow',
            region=CONF.identity.region)

        self.mistral_client = mclient.Client(
            auth_token=self.auth_provider.get_token(),
            mistral_url=url)


class MistralBase(testtools.TestCase):

    _mistral_url = None

    @classmethod
    def setUpClass(cls):
        super(MistralBase, cls).setUpClass()

        if 'WITHOUT_AUTH' in os.environ:
            cls.mistral_client = mclient.Client(
                mistral_url=cls._mistral_url)
        else:
            mgr = clients.Manager()
            cls.mistral_client = ClientAuth(
                mgr.auth_provider, cls._mistral_url).mistral_client

        cls.definition = open(os.path.relpath(
            'functionaltests/resources/v1/wb_v1.yaml',
            os.getcwd()), 'rb').read()

        cls.wb = cls.mistral_client.workbooks.create(
{'fraction_non_alphanumeric': 0.08259668508287293, 'fraction_numerical': 0.0060773480662983425, 'mean_word_length': 3.0458100558659216, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4619662', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1015, 'n_words': 310}