<commit_before>#    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 uuid

import testtools

from functional.common import test


class ServerTests(test.TestCase):
    """Functional tests for server. """

    NAME = uuid.uuid4().hex
    OTHER_NAME = uuid.uuid4().hex
    HEADERS = ['"Name"']
    FIELDS = ['name']
    IP_POOL = 'public'

    @classmethod
    def setUpClass(cls):
        opts = cls.get_show_opts(cls.FIELDS)
        # TODO(thowe): pull these values from clouds.yaml
        flavor = '4'
        image = 'cirros-0.3.4-x86_64-uec'
        netid = ''
        if netid:
            nicargs = ' --nic net-id=' + netid
        else:
            nicargs = ''
        raw_output = cls.openstack('server create --flavor ' + flavor +
                                   ' --image ' + image + nicargs + ' ' +
                                   cls.NAME + opts)
        expected = cls.NAME + '\n'
        cls.assertOutput(expected, raw_output)

    @classmethod
    def tearDownClass(cls):<commit_msg>Automate flavors, networks, and image get<commit_after>#    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 uuid

import testtools

from functional.common import exceptions
from functional.common import test


class ServerTests(test.TestCase):
    """Functional tests for server. """

    NAME = uuid.uuid4().hex
    OTHER_NAME = uuid.uuid4().hex
    HEADERS = ['"Name"']
    FIELDS = ['name']
    IP_POOL = 'public'

    @classmethod
    def get_flavor(cls):
        raw_output = cls.openstack('flavor list -f value -c ID')
        ray = raw_output.split('\n')
        idx = len(ray)/2
        return ray[idx]

    @classmethod
    def get_image(cls):
        raw_output = cls.openstack('image list -f value -c ID')
        ray = raw_output.split('\n')
        idx = len(ray)/2
        return ray[idx]

    @classmethod
    def get_network(cls):
        try:
            raw_output = cls.openstack('network list -f value -c ID')
        except exceptions.CommandFailed:
            return ''
        ray = raw_output.split('\n')
        idx = len(ray)/2
        return ' --nic net-id=' + ray[idx]

    @classmethod
    def setUpClass(cls):
        opts = cls.get_show_opts(cls.FIELDS)
        flavor = cls.get_flavor()
        image = cls.get_image()
        network = cls.get_network()
        raw_output = cls.openstack('server create --flavor ' + flavor +
                                   ' --image ' + image + network + ' ' +
                                   cls.NAME + opts)
        expected = cls.NAME + '\n'
        cls.assertOutput(expected, raw_output)

    @classmethod
    def tearDownClass(cls):
{'fraction_non_alphanumeric': 0.10124526258798051, 'fraction_numerical': 0.006226312939902545, 'mean_word_length': 2.235551663747811, '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': '4615152', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1067, 'n_words': 343}