<commit_before># Copyright 2013 Mirantis, Inc.
# 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.

import time
import json
import logging
import traceback
import fuel_health.nmanager

LOG = logging.getLogger(__name__)


class MuranoTest(fuel_health.nmanager.OfficialClientTest):
    """
    Manager that provides access to the Murano python client for
    calling Murano API.
    """

    def tearDown(self):
        """
            This method allows to clean up the OpenStack environment
            after the Murano OSTF tests
        """
        super(MuranoTest, self).tearDown()
        if self.manager.clients_initialized:
            for env in self.list_environments():
                if 'ost1_test-Murano_env' in env.name:
                    try:
                        self.delete_environment(env.id)
                    except:
                        LOG.warning(traceback.format_exc())

    def find_murano_image(self, image_type):
        """
            This method allows to find Windows images with Murano tag.

            Returns the image object or None

            image_type should be in [linux, windows.2012, cirros.demo]
        """
        for image in self.compute_client.images.list():<commit_msg>Add tests failure when murano not available<commit_after># Copyright 2013 Mirantis, Inc.
# 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.

import json
import logging
import time
import traceback

import muranoclient.common.exceptions as exceptions

import fuel_health.nmanager

LOG = logging.getLogger(__name__)


class MuranoTest(fuel_health.nmanager.OfficialClientTest):
    """
    Manager that provides access to the Murano python client for
    calling Murano API.
    """
    def setUp(self):
        super(MuranoTest, self).setUp()
        self.check_clients_state()
        self.murano_available = True
        try:
            self.murano_client.environments.list()
        except exceptions.CommunicationError:
            self.murano_available = False
            self.fail("Murano service is not available")

    def tearDown(self):
        """
            This method allows to clean up the OpenStack environment
            after the Murano OSTF tests
        """
        super(MuranoTest, self).tearDown()
        if self.murano_available:
            for env in self.list_environments():
                if 'ost1_test-Murano_env' in env.name:
                    try:
                        self.delete_environment(env.id)
                    except:
                        LOG.warning(traceback.format_exc())

    def find_murano_image(self, image_type):
        """
            This method allows to find Windows images with Murano tag.

            Returns the image object or None

            image_type should be in [linux, windows.2012, cirros.demo]
        """
        for image in self.compute_client.images.list():
{'fraction_non_alphanumeric': 0.06960907944514502, 'fraction_numerical': 0.006557377049180328, 'mean_word_length': 2.3810741687979537, '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': '1318264', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1007, 'n_words': 377}