Added hacking checks to tox

Fixed all places where hacking rules (v0.7) was failing
Replaced ''' with """ to make them consistent

Change-Id: I9c1c20f910df696056d2a6a91c33ff7bad266b9f
Related-Bug: #1404892
Closes-Bug: #1408240
This commit is contained in:
Sebastian Kalinowski 2015-01-14 13:55:28 +01:00 committed by Sebastian Kalinowski
parent 92ad9f8e4c
commit cbe0ea30d9
62 changed files with 354 additions and 387 deletions

21
fabfile.py vendored
View File

@ -1,3 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2015 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.
from fabric.api import local
@ -46,10 +62,9 @@ def startnailgunmimic():
def createmigration(comment):
'''
Supply comment for new alembic revision as a value
"""Supply comment for new alembic revision as a value
for comment argument
'''
"""
config_path = 'fuel_plugin/ostf_adapter/storage/alembic.ini'
local(
'alembic --config {0} revision --autogenerate -m \"{1}\"'

View File

@ -89,9 +89,7 @@ class CeilometerBaseTest(fuel_health.nmanager.PlatformServicesBaseClass):
self.skipTest('There are no compute nodes')
def create_alarm(self, **kwargs):
"""
This method provides creation of alarm
"""
"""This method provides creation of alarm."""
if 'name' in kwargs:
kwargs['name'] = rand_name(kwargs['name'])
alarm = self.ceilometer_client.alarms.create(**kwargs)
@ -100,15 +98,11 @@ class CeilometerBaseTest(fuel_health.nmanager.PlatformServicesBaseClass):
return alarm
def get_state(self, alarm_id):
"""
This method provides getting state
"""
"""This method provides getting state."""
return self.ceilometer_client.alarms.get_state(alarm_id=alarm_id)
def verify_state(self, alarm_id, state):
"""
This method provides getting state
"""
"""This method provides getting state."""
alarm_state_resp = self.get_state(alarm_id)
if not alarm_state_resp == state:
self.fail('State was not setted')
@ -117,9 +111,7 @@ class CeilometerBaseTest(fuel_health.nmanager.PlatformServicesBaseClass):
self.status_timeout(self.compute_client.servers, server.id, status)
def wait_for_alarm_status(self, alarm_id, status=None):
"""
The method is a customization of test.status_timeout().
"""
"""The method is a customization of test.status_timeout()."""
def check_status():
alarm_state_resp = self.get_state(alarm_id)
@ -140,8 +132,7 @@ class CeilometerBaseTest(fuel_health.nmanager.PlatformServicesBaseClass):
act_status=actual_status))
def wait_for_sample_of_metric(self, metric, query=None, limit=100):
"""
This method is to wait for sample to add it to database.
"""This method is to wait for sample to add it to database.
query example:
query=[
{'field':'resource',
@ -166,9 +157,7 @@ class CeilometerBaseTest(fuel_health.nmanager.PlatformServicesBaseClass):
def wait_for_statistic_of_metric(self, meter_name, query=None,
period=None):
"""
The method is a customization of test.status_timeout().
"""
"""The method is a customization of test.status_timeout()."""
def check_status():
stat_state_resp = self.ceilometer_client.statistics.list(

View File

@ -32,8 +32,7 @@ LOG = logging.getLogger(__name__)
class CleanUpClientManager(fuel_health.nmanager.OfficialClientManager):
"""
Manager that provides access to the official python clients for
"""Manager that provides access to the official python clients for
calling various OpenStack APIs.
"""
@ -57,8 +56,7 @@ class CleanUpClientManager(fuel_health.nmanager.OfficialClientManager):
def cleanup(cluster_deployment_info):
'''
Function performs cleaning up for current cluster.
"""Function performs cleaning up for current cluster.
Because clusters can be deployed in different way
function uses cluster_deployment_info argument which
@ -71,7 +69,7 @@ def cleanup(cluster_deployment_info):
More better way is to create separate functions for each
set of tests so refactoring of this chunk of code is higly
appreciated.
'''
"""
manager = CleanUpClientManager()
if 'sahara' in cluster_deployment_info:
@ -120,7 +118,7 @@ def cleanup(cluster_deployment_info):
try:
LOG.info('Start flavor deletion.')
compute_client.flavors.delete(flavor.id)
except:
except Exception:
LOG.warning('Failed to delete flavor')
LOG.debug(traceback.format_exc())

View File

@ -55,7 +55,7 @@ def _load_log_config():
log_config = os.path.join(conf_dir, conf_file)
try:
logging.config.fileConfig(log_config)
except ConfigParser.Error, exc:
except ConfigParser.Error as exc:
raise cfg.ConfigFileParseError(log_config, str(exc))
return True

View File

@ -88,8 +88,7 @@ class Client(object):
return ssh
def exec_longrun_command(self, cmd):
"""
Execute the specified command on the server.
"""Execute the specified command on the server.
Unlike exec_command and exec_command_on_vm, this method allows
to start a process on VM in background and leave it alive
@ -123,8 +122,7 @@ class Client(object):
return
def exec_command(self, cmd):
"""
Execute the specified command on the server.
"""Execute the specified command on the server.
Note that this method is reading whole command outputs to memory, thus
shouldn't be used for large outputs.
@ -187,7 +185,8 @@ class Client(object):
:returns: data read from standard output of the command.
:raises: SSHExecCommandFailed if command returns nonzero
status. The exception contains command status stderr content."""
status. The exception contains command status stderr content.
"""
ssh = self._get_ssh_connection()
_intermediate_transport = ssh.get_transport()
_intermediate_channel = \

View File

@ -23,16 +23,13 @@ LOG = logging.getLogger(__name__)
class FuelTestAssertMixin(object):
"""
Mixin class with a set of assert methods created to abstract
"""Mixin class with a set of assert methods created to abstract
from unittest assertion methods and provide human
readable descriptions where possible
"""
def verify_response_status(self, status,
appl='Application', msg='', failed_step=''):
"""
Method provides human readable message
"""Method provides human readable message
for the HTTP response status verification
:param appl: the name of application requested
@ -82,8 +79,7 @@ class FuelTestAssertMixin(object):
status=status), status_msg, '\n', msg)))
def verify_response_body(self, body, content='', msg='', failed_step=''):
"""
Method provides human readable message for the verification if
"""Method provides human readable message for the verification if
HTTP response body contains desired keyword
:param body: response body
@ -98,8 +94,7 @@ class FuelTestAssertMixin(object):
def verify_response_body_value(self, body_structure, value='', msg='',
failed_step=''):
"""
Method provides human readable message for verification if
"""Method provides human readable message for verification if
HTTP response body element contains desired keyword.
:param body_structure: body element value (e.g. body['name'], body);
@ -134,8 +129,7 @@ class FuelTestAssertMixin(object):
actual_content=act_content), '\n', msg))
def verify_elements_list(self, elements, attrs, msg='', failed_step=''):
"""
Method provides human readable message for the verification of
"""Method provides human readable message for the verification of
list of elements with specific parameters
:param elements: the list of elements from response
:param attrs: required attributes for each element
@ -173,8 +167,7 @@ class FuelTestAssertMixin(object):
self.fail(message.format(failed_step_msg, msg))
def verify(self, secs, func, step='', msg='', action='', *args, **kwargs):
"""
Arguments:
"""Arguments:
:secs: timeout time;
:func: function to be verified;
:step: number of test step;
@ -204,8 +197,7 @@ def _raise_TimeOut(sig, stack):
class timeout(object):
"""
Timeout context that will stop code running within context
"""Timeout context that will stop code running within context
if timeout is reached
>>with timeout(2):

View File

@ -63,9 +63,8 @@ def build_url(host, port, api_version=None, path=None,
def arbitrary_string(size=4, base_text=None):
"""
Return size characters from base_text, repeating the base_text infinitely
if needed.
"""Return size characters from base_text, repeating
the base_text infinitely if needed.
"""
if not base_text:
base_text = 'ost1_test-'

View File

@ -15,6 +15,7 @@
# 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 __future__ import print_function
import os
import sys
@ -390,7 +391,7 @@ def register_heat_opts(conf):
def process_singleton(cls):
"""Wrapper for classes... To be instantiated only one time per process"""
"""Wrapper for classes... To be instantiated only one time per process."""
instances = {}
def wrapper(*args, **kwargs):
@ -438,8 +439,8 @@ class FileConfig(object):
LOG.info("Using fuel config file %s" % path)
if not os.path.exists(path):
msg = "Config file %(path)s not found" % locals()
print >> sys.stderr, RuntimeError(msg)
msg = "Config file {0} not found".format(path)
print(RuntimeError(msg), file=sys.stderr)
else:
config_files.append(path)
@ -670,9 +671,6 @@ class NailgunConfig(object):
self.volume.ceph_exist = storage
def _parse_ostf_api(self):
"""
will leave this
"""
api_url = '/api/ostf/%s' % self.cluster_id
response = self.req_session.get(self.nailgun_url + api_url)
data = response.json()

View File

@ -19,8 +19,7 @@ import unittest2
class FuelException(Exception):
"""
Base Exception
"""Base Exception
To correctly use this class, inherit from it and define
a 'message' property. That message will get printf'd

View File

@ -19,8 +19,8 @@
import logging
import os
from fuel_health.common.utils.data_utils import rand_name
import fuel_health.common.ssh
from fuel_health.common.utils.data_utils import rand_name
import fuel_health.nmanager
import fuel_health.test
@ -29,9 +29,7 @@ LOG = logging.getLogger(__name__)
class HeatBaseTest(fuel_health.nmanager.NovaNetworkScenarioTest):
"""
Base class for Heat openstack sanity and smoke tests.
"""
"""Base class for Heat openstack sanity and smoke tests."""
@classmethod
def setUpClass(cls):
@ -93,8 +91,7 @@ class HeatBaseTest(fuel_health.nmanager.NovaNetworkScenarioTest):
def _wait_for_stack_status(self, stack_id, expected_status,
timeout=None, interval=None):
"""
The method is a customization of test.status_timeout().
"""The method is a customization of test.status_timeout().
It addresses `stack_status` instead of `status` field and
checks for FAILED instead of ERROR status.
The rest is the same.
@ -148,8 +145,7 @@ class HeatBaseTest(fuel_health.nmanager.NovaNetworkScenarioTest):
count_instances, timeout, interval, reduced_stack_name)
def _wait_for_vm_ready_for_load(self, conn_string, timeout, interval):
"""
Wait for fake file to be created on the instance
"""Wait for fake file to be created on the instance
to make sure that vm is ready.
"""
cmd = (conn_string +
@ -219,9 +215,7 @@ class HeatBaseTest(fuel_health.nmanager.NovaNetworkScenarioTest):
@staticmethod
def _load_template(file_name):
"""
Load specified template file from etc directory.
"""
"""Load specified template file from etc directory."""
filepath = os.path.join(
os.path.dirname(os.path.realpath(__file__)), "etc", file_name)
with open(filepath) as f:
@ -229,8 +223,7 @@ class HeatBaseTest(fuel_health.nmanager.NovaNetworkScenarioTest):
@staticmethod
def _customize_template(template):
"""
By default, heat templates expect neutron subnets to be available.
"""By default, heat templates expect neutron subnets to be available.
But if nova-network is used instead of neutron then
subnet usage should be removed from the template.
"""

View File

@ -24,9 +24,7 @@ LOG = logging.getLogger(__name__)
class Manager(object):
"""
Base manager class
"""Base manager class
Manager objects are responsible for providing a configuration object
and a client object for a test case to use in performing actions.

View File

@ -15,11 +15,12 @@
import json
import logging
import requests
import time
import traceback
import muranoclient.common.exceptions as exceptions
import requests
from fuel_health.common.utils.data_utils import rand_name
import fuel_health.nmanager
@ -27,8 +28,7 @@ LOG = logging.getLogger(__name__)
class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
"""
Manager that provides access to the Murano python client for
"""Manager that provides access to the Murano python client for
calling Murano API.
"""
@ -56,9 +56,8 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
self.skipTest("Murano service is not available")
def tearDown(self):
"""
This method allows to clean up the OpenStack environment
after the Murano OSTF tests.
"""This method allows to clean up the OpenStack environment
after the Murano OSTF tests.
"""
if self.murano_available:
@ -66,18 +65,17 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
if self.env_name in env["name"]:
try:
self.delete_environment(env["id"])
except:
except Exception:
LOG.warning(traceback.format_exc())
super(MuranoTest, self).tearDown()
def find_murano_image(self, image_type):
"""
This method allows to find Windows images with Murano tag.
"""This method allows to find Windows images with Murano tag.
Returns the image object or None
Returns the image object or None
image_type should be in [linux, windows.2012, cirros.demo]
image_type should be in [linux, windows.2012, cirros.demo]
"""
tag = 'murano_image_info'
@ -89,10 +87,9 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return image
def list_environments(self):
"""
This method allows to get the list of environments.
"""This method allows to get the list of environments.
Returns the list of environments.
Returns the list of environments.
"""
resp = requests.get(self.endpoint + 'environments',
@ -100,13 +97,12 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return resp.json()
def create_environment(self, name):
"""
This method allows to create environment.
"""This method allows to create environment.
Input parameters:
name - Name of new environment
Input parameters:
name - Name of new environment
Returns new environment.
Returns new environment.
"""
post_body = {'name': name}
@ -116,14 +112,13 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return resp.json()
def get_environment(self, environment_id):
"""
This method allows to get specific environment by ID.
"""This method allows to get specific environment by ID.
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment (optional)
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment (optional)
Returns specific environment.
Returns specific environment.
"""
return requests.get('{0}environments/{1}'.format(self.endpoint,
@ -131,26 +126,24 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
headers=self.headers).json()
def update_environment(self, environment_id, new_name):
"""
This method allows to update specific environment by ID.
"""This method allows to update specific environment by ID.
Input parameters:
environment_id - ID of environment
new_name - New name for environment
Input parameters:
environment_id - ID of environment
new_name - New name for environment
Returns new environment.
Returns new environment.
"""
return self.murano_client.environments.update(environment_id, new_name)
def delete_environment(self, environment_id):
"""
This method allows to delete specific environment by ID.
"""This method allows to delete specific environment by ID.
Input parameters:
environment_id - ID of environment
Input parameters:
environment_id - ID of environment
Returns None.
Returns None.
"""
endpoint = '{0}environments/{1}'.format(self.endpoint, environment_id)
@ -158,13 +151,12 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return resp
def create_session(self, environment_id):
"""
This method allows to create session for environment.
"""This method allows to create session for environment.
Input parameters:
environment_id - ID of environment
Input parameters:
environment_id - ID of environment
Returns new session.
Returns new session.
"""
post_body = None
@ -174,40 +166,37 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
headers=self.headers).json()
def get_session(self, environment_id, session_id):
"""
This method allows to get specific session.
"""This method allows to get specific session.
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment
Returns specific session.
Returns specific session.
"""
return self.murano_client.sessions.get(environment_id, session_id)
def delete_session(self, environment_id, session_id):
"""
This method allows to delete session for environment.
"""This method allows to delete session for environment.
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment
Returns None.
Returns None.
"""
return self.murano_client.sessions.delete(environment_id, session_id)
def deploy_session(self, environment_id, session_id):
"""
This method allows to deploy session for environment.
"""This method allows to deploy session for environment.
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment
Returns specific session.
Returns specific session.
"""
endpoint = '{0}environments/{1}/sessions/{2}/deploy'.format(
@ -215,15 +204,14 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return requests.post(endpoint, data=None, headers=self.headers)
def create_service(self, environment_id, session_id, json_data):
"""
This method allows to create service.
"""This method allows to create service.
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment
json_data - JSON with service description
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment
json_data - JSON with service description
Returns specific service.
Returns specific service.
"""
headers = self.headers.copy()
headers.update({'x-configuration-session': session_id})
@ -233,28 +221,26 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
headers=headers).json()
def list_services(self, environment_id, session_id=None):
"""
This method allows to get list of services.
"""This method allows to get list of services.
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment (optional)
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment (optional)
Returns list of services.
Returns list of services.
"""
return self.murano_client.services.get(environment_id, '/', session_id)
def get_service(self, environment_id, session_id, service_id):
"""
This method allows to get service by ID.
"""This method allows to get service by ID.
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment
service_id - ID of service in this environment
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment
service_id - ID of service in this environment
Returns specific service.
Returns specific service.
"""
return self.murano_client.services.get(environment_id,
@ -262,15 +248,14 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
session_id)
def delete_service(self, environment_id, session_id, service_id):
"""
This method allows to delete specific service.
"""This method allows to delete specific service.
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment
service_id - ID of service in this environment
Input parameters:
environment_id - ID of environment
session_id - ID of session for this environment
service_id - ID of service in this environment
Returns None.
Returns None.
"""
return self.murano_client.services.delete(environment_id,
@ -278,13 +263,12 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
session_id)
def deploy_check(self, environment_id):
"""
This method allows to wait for deployment of Murano evironments.
"""This method allows to wait for deployment of Murano evironments.
Input parameters:
environment_id - ID of environment
Input parameters:
environment_id - ID of environment
Returns environment.
Returns environment.
"""
environment = self.get_environment(environment_id)
@ -301,13 +285,12 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return environment
def deployments_status_check(self, environment_id):
"""
This method allows to check that deployment status is 'success'.
"""This method allows to check that deployment status is 'success'.
Input parameters:
environment_id - ID of environment
Input parameters:
environment_id - ID of environment
Returns 'OK'.
Returns 'OK'.
"""
endpoint = '{0}environments/{1}/deployments'.format(self.endpoint,
@ -325,14 +308,13 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return 'OK'
def ports_check(self, environment, ports):
"""
This method allows to check that needed ports are opened.
"""This method allows to check that needed ports are opened.
Input parameters:
environment - Murano environment
ports - list of needed ports
Input parameters:
environment - Murano environment
ports - list of needed ports
Returns 'OK'.
Returns 'OK'.
"""
check_ip = environment['services'][0]['instance']['floatingIpAddress']

View File

@ -25,25 +25,25 @@ LOG = logging.getLogger(__name__)
# Default client libs
try:
import heatclient.v1.client
except:
except Exception:
LOG.warning('Heatclient could not be imported.')
try:
import muranoclient.v1.client
except:
except Exception:
LOG.debug(traceback.format_exc())
LOG.warning('Muranoclient could not be imported.')
try:
import saharaclient.client
except:
except Exception:
LOG.debug(traceback.format_exc())
LOG.warning('Sahara client could not be imported.')
try:
import ceilometerclient.v2.client
except:
except Exception:
LOG.warning('Ceilometer client could not be imported.')
try:
import neutronclient.neutron.client
except:
except Exception:
LOG.warning('Neutron client could not be imported.')
import cinderclient.client
@ -51,16 +51,15 @@ import keystoneclient
import novaclient.client
from fuel_health.common.ssh import Client as SSHClient
from fuel_health.common.utils.data_utils import rand_name
from fuel_health.common.utils.data_utils import rand_int_id
from fuel_health.common.utils.data_utils import rand_name
from fuel_health import exceptions
import fuel_health.manager
import fuel_health.test
class OfficialClientManager(fuel_health.manager.Manager):
"""
Manager that provides access to the official python clients for
"""Manager that provides access to the official python clients for
calling various OpenStack APIs.
"""
@ -120,9 +119,13 @@ class OfficialClientManager(fuel_health.manager.Manager):
tenant_name = self.config.identity.admin_tenant_name
if None in (username, password, tenant_name):
msg = ("Missing required credentials for compute client. "
"username: %(username)s, password: %(password)s, "
"tenant_name: %(tenant_name)s") % locals()
msg = ("Missing required credentials for identity client. "
"username: {username}, password: {password}, "
"tenant_name: {tenant_name}").format(
username=username,
password=password,
tenant_name=tenant_name,
)
raise exceptions.InvalidConfiguration(msg)
auth_url = self.config.identity.uri
@ -165,8 +168,12 @@ class OfficialClientManager(fuel_health.manager.Manager):
if None in (username, password, tenant_name):
msg = ("Missing required credentials for identity client. "
"username: %(username)s, password: %(password)s, "
"tenant_name: %(tenant_name)s") % locals()
"username: {username}, password: {password}, "
"tenant_name: {tenant_name}").format(
username=username,
password=password,
tenant_name=tenant_name,
)
raise exceptions.InvalidConfiguration(msg)
auth_url = self.config.identity.uri
@ -215,8 +222,7 @@ class OfficialClientManager(fuel_health.manager.Manager):
password=password)
def _get_murano_client(self):
"""
This method returns Murano API client
"""This method returns Murano API client
"""
# Get xAuth token from Keystone
self.token_id = self._get_identity_client(
@ -433,9 +439,7 @@ class OfficialClientTest(fuel_health.test.TestCase):
class NovaNetworkScenarioTest(OfficialClientTest):
"""
Base class for nova network scenario tests
"""
"""Base class for nova network scenario tests."""
@classmethod
def setUpClass(cls):
@ -461,9 +465,7 @@ class NovaNetworkScenarioTest(OfficialClientTest):
self.check_clients_state()
def _run_ssh_cmd(self, cmd):
"""
Open SSH session with Controller and and execute command.
"""
"""Open SSH session with Controller and and execute command."""
if not self.host:
self.fail('Wrong test configuration: '
'"online_controllers" parameter is empty.')
@ -652,7 +654,7 @@ class NovaNetworkScenarioTest(OfficialClientTest):
'parameters are empty controller_node_name or '
'controller_node_ip ')
# TODO Allow configuration of execution and sleep duration.
# TODO(???) Allow configuration of execution and sleep duration.
return fuel_health.test.call_until_true(ping, 40, 1)
def _ping_ip_address_from_instance(self, ip_address, timeout,
@ -683,7 +685,7 @@ class NovaNetworkScenarioTest(OfficialClientTest):
password='cubswin:)',
vm=ip_address)
# TODO Allow configuration of execution and sleep duration.
# TODO(???) Allow configuration of execution and sleep duration.
return fuel_health.test.call_until_true(ping, 40, 1)
def _check_vm_connectivity(self, ip_address, timeout, retries):
@ -766,9 +768,7 @@ class PlatformServicesBaseClass(NovaNetworkScenarioTest):
class SanityChecksTest(OfficialClientTest):
"""
Base class for openstack sanity tests
"""
"""Base class for openstack sanity tests."""
_enabled = True
@ -849,9 +849,7 @@ class SanityChecksTest(OfficialClientTest):
class SmokeChecksTest(OfficialClientTest):
"""
Base class for openstack smoke tests
"""
"""Base class for openstack smoke tests."""
@classmethod
def setUpClass(cls):

View File

@ -30,10 +30,7 @@ LOG = logging.getLogger(__name__)
class SaharaTest(nmanager.PlatformServicesBaseClass):
"""
Base class for openstack sanity tests for Sahara
"""
"""Base class for openstack sanity tests for Sahara."""
@classmethod
def setUpClass(cls):
super(SaharaTest, cls).setUpClass()

View File

@ -21,9 +21,9 @@ import time
import testresources
import unittest2
from fuel_health import config
from fuel_health.common import log as logging
from fuel_health.common.test_mixins import FuelTestAssertMixin
from fuel_health import config
LOG = logging.getLogger(__name__)
@ -44,8 +44,7 @@ class BaseTestCase(unittest2.TestCase,
def call_until_true(func, duration, sleep_for, arg=None):
"""
Call the given function until it returns True (and return True) or
"""Call the given function until it returns True (and return True) or
until the specified duration (in seconds) elapses (and return
False).
@ -105,8 +104,7 @@ class TestCase(BaseTestCase):
del self.resource_keys[key]
def status_timeout(self, things, thing_id, expected_status):
"""
Given a thing and an expected status, do a loop, sleeping
"""Given a thing and an expected status, do a loop, sleeping
for a configurable amount of time, checking for the
expected status to show. At any time, if the returned
status of the thing is ERROR, fail out.

View File

@ -14,12 +14,12 @@
# License for the specific language governing permissions and limitations
# under the License.
'''
"""
Main purpose of following attribute is
to supply general information about test set.
This information will be stored in ostf database
in test_sets table.
'''
"""
__profile__ = {
"test_runs_ordering_priority": 3,
"id": "ha",

View File

@ -25,9 +25,7 @@ LOG = logging.getLogger(__name__)
class RabbitSmokeTest(BaseTestCase):
"""
TestClass contains RabbitMQ test checks.
"""
"""TestClass contains RabbitMQ test checks."""
@classmethod
def setUpClass(cls):

View File

@ -14,12 +14,12 @@
# License for the specific language governing permissions and limitations
# under the License.
'''
"""
Main purpose of following attribute is
to supply general information about test set.
This information will be stored in ostf database
in test_sets table.
'''
"""
__profile__ = {
"test_runs_ordering_priority": 4,
"id": "platform_tests",

View File

@ -17,9 +17,7 @@ from fuel_health.common.utils.data_utils import rand_name
class CeilometerApiPlatformTests(ceilometermanager.CeilometerBaseTest):
"""
TestClass contains tests that check basic Ceilometer functionality.
"""
"""TestClass contains tests that check basic Ceilometer functionality."""
def test_check_alarm_state(self):
"""Ceilometer test to check alarm status and get Nova notifications.

View File

@ -17,9 +17,7 @@ from fuel_health.common.utils.data_utils import rand_name
class CeilometerApiSmokeTests(ceilometermanager.CeilometerBaseTest):
"""
TestClass contains tests that check basic Ceilometer functionality.
"""
"""TestClass contains tests that check basic Ceilometer functionality."""
def test_create_alarm(self):
"""Ceilometer create, update, check, delete alarm

View File

@ -21,8 +21,8 @@ LOG = logging.getLogger(__name__)
class HeatSmokeTests(heatmanager.HeatBaseTest):
"""
Test class verifies Heat API calls, rollback and autoscaling use-cases.
"""Test class verifies Heat API calls, rollback and
autoscaling use-cases.
"""
def setUp(self):
super(HeatSmokeTests, self).setUp()

View File

@ -24,8 +24,8 @@ LOG = logging.getLogger(__name__)
class MuranoDeployLinuxServicesTests(muranomanager.MuranoTest):
"""
TestClass contains verifications of full Murano functionality.
"""TestClass contains verifications of full Murano functionality.
Special requirements:
1. Murano component should be installed.
2. Internet access for virtual machines in OpenStack.
@ -154,7 +154,7 @@ class MuranoDeployLinuxServicesTests(muranomanager.MuranoTest):
self.environment['id'])
def test_deploy_wordpress_app(self):
"""Check that user can deploy WordPress application in Murano environment
"""Check that user can deploy WordPress app in Murano environment
Target component: Murano
Scenario:

View File

@ -22,9 +22,7 @@ LOG = logging.getLogger(__name__)
class PlatformSaharaTests(saharamanager.SaharaTest):
"""
TestClass contains tests that check basic Sahara functionality.
"""
"""TestClass contains tests that check basic Sahara functionality."""
def setUp(self):
super(PlatformSaharaTests, self).setUp()

View File

@ -14,12 +14,12 @@
# License for the specific language governing permissions and limitations
# under the License.
'''
"""
Main purpose of following attribute is
to supply general information about test set.
This information will be stored in ostf database
in test_sets table.
'''
"""
__profile__ = {
"test_runs_ordering_priority": 1,
"id": "sanity",

View File

@ -18,9 +18,7 @@ from fuel_health import ceilometermanager
class CeilometerApiTests(ceilometermanager.CeilometerBaseTest):
"""
TestClass contains tests that check basic Ceilometer functionality.
"""
"""TestClass contains tests that check basic Ceilometer functionality."""
def test_list_meters(self):
"""List ceilometer availability

View File

@ -22,9 +22,7 @@ LOG = logging.getLogger(__name__)
class SanityComputeTest(nmanager.SanityChecksTest):
"""
TestClass contains tests that check basic Compute functionality.
"""
"""TestClass contains tests that check basic Compute functionality."""
def test_list_instances(self):
"""Request instance list

View File

@ -22,8 +22,7 @@ LOG = logging.getLogger(__name__)
class SanityHeatTest(nmanager.SanityChecksTest):
"""
Class contains tests that check basic Heat functionality.
"""Class contains tests that check basic Heat functionality.
Special requirements:
1. Heat component should be installed.
"""

View File

@ -22,8 +22,7 @@ LOG = logging.getLogger(__name__)
class SanityIdentityTest(nmanager.SanityChecksTest):
"""
TestClass contains tests that check basic authentication functionality.
"""TestClass contains tests that check basic authentication functionality.
Special requirements: OS admin user permissions are needed
"""

View File

@ -15,7 +15,7 @@
# under the License.
import logging
from time import sleep
import time
import traceback
from fuel_health.common.ssh import Client as SSHClient
@ -73,10 +73,10 @@ class SanityInfrastructureTest(nmanager.SanityChecksTest):
self.verify_response_true(
u'XXX' not in output, 'Step 2 failed: Some nova services '
'have not been started.')
except:
except Exception:
LOG.info("Will sleep for 60 seconds and try again")
LOG.debug(traceback.format_exc())
sleep(60)
time.sleep(60)
self.verify_response_true(
u'XXX' not in output, 'Step 2 failed: Some nova services '
'have not been started.')

View File

@ -18,8 +18,7 @@ from fuel_health import muranomanager
class MuranoSanityTests(muranomanager.MuranoTest):
"""
TestClass contains verifications of basic Murano functionality.
"""TestClass contains verifications of basic Murano functionality.
Special requirements:
1. Murano API service should be installed.
"""

View File

@ -22,9 +22,7 @@ LOG = logging.getLogger(__name__)
class NetworksTest(nmanager.SanityChecksTest):
"""
TestClass contains tests check base networking functionality
"""
"""TestClass contains tests check base networking functionality."""
def test_list_networks_nova_network(self):
"""Request list of networks

View File

@ -22,9 +22,7 @@ LOG = logging.getLogger(__name__)
class SanitySaharaTests(saharamanager.SaharaTest):
"""
TestClass contains tests that check basic Sahara functionality.
"""
"""TestClass contains tests that check basic Sahara functionality."""
def test_sanity_sahara(self):
"""Sahara tests to create/list/delete node group and cluster templates

View File

@ -14,12 +14,12 @@
# License for the specific language governing permissions and limitations
# under the License.
'''
"""
Main purpose of following attribute is
to supply general information about test set.
This information will be stored in ostf database
in test_sets table.
'''
"""
__profile__ = {
"test_runs_ordering_priority": 2,
"id": "smoke",

View File

@ -22,8 +22,7 @@ LOG = logging.getLogger(__name__)
class TestNeutron(neutronmanager.NeutronBaseTest):
"""
Test suite verifies:
"""Test suite verifies:
- router creation
- network creation
- subnet creation

View File

@ -25,8 +25,7 @@ LOG = logging.getLogger(__name__)
class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
"""
Test suit verifies:
"""Test suit verifies:
- keypairs creation
- security groups creation
- Network creation

View File

@ -26,8 +26,7 @@ LOG = logging.getLogger(__name__)
class TestImageAction(nmanager.SmokeChecksTest):
"""
Test class verifies the following:
"""Test class verifies the following:
- verify that image can be created;
- verify that instance can be booted from created image;
- verify that snapshot can be created from an instance;

View File

@ -25,8 +25,7 @@ LOG = logging.getLogger(__name__)
class TestUserTenantRole(nmanager.SmokeChecksTest):
"""
Test class verifies the following:
"""Test class verifies the following:
- verify that a tenant can be created;
- verify that a user can be created based on the new tenant;
- verify that a user role can be created.

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
import logging
import os
from oslo.config import cfg

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
import logging
import logging.handlers
import os
_LOG_TIME_FORMAT = "%Y-%m-%d %H:%M:%S"

View File

@ -12,15 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import requests
from sqlalchemy.orm import joinedload
import logging
from oslo.config import cfg
import requests
from sqlalchemy.orm import joinedload
from fuel_plugin.ostf_adapter.storage import models
from fuel_plugin.ostf_adapter.nose_plugin import nose_utils
from fuel_plugin.ostf_adapter.storage import models
LOG = logging.getLogger(__name__)

View File

@ -13,28 +13,28 @@
# under the License.
import fcntl
import os
import logging
import os
import signal
from oslo.config import cfg
from fuel_plugin.ostf_adapter.logger import ResultsLogger
from fuel_plugin.ostf_adapter.nose_plugin import nose_storage_plugin
from fuel_plugin.ostf_adapter.nose_plugin import nose_test_runner
from fuel_plugin.ostf_adapter.nose_plugin import nose_utils
from fuel_plugin.ostf_adapter.storage import engine, models
from fuel_plugin.ostf_adapter.nose_plugin import nose_storage_plugin
from fuel_plugin.ostf_adapter.storage import engine
from fuel_plugin.ostf_adapter.storage import models
LOG = logging.getLogger(__name__)
class InterruptTestRunException(KeyboardInterrupt):
''' Current class exception is used for cleanup action
"""Current class exception is used for cleanup action
as KeyboardInterrupt is the only exception that is reraised by
unittest (and nose correspondingly) into outside environment
'''
pass
"""
class NoseDriver(object):

View File

@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from time import time
import logging
import os
from nose import plugins
import time
from nose import plugins
from oslo.config import cfg
from fuel_plugin.ostf_adapter.nose_plugin import nose_utils
@ -122,7 +122,7 @@ class StoragePlugin(plugins.Plugin):
self._add_message(test, err=err, status='error')
def beforeTest(self, test):
self._start_time = time()
self._start_time = time.time()
self._add_message(test, status='running')
def describeTest(self, test):
@ -131,5 +131,5 @@ class StoragePlugin(plugins.Plugin):
@property
def taken(self):
if self._start_time:
return time() - self._start_time
return time.time() - self._start_time
return 0

View File

@ -13,13 +13,12 @@
# under the License.
import itertools
import traceback
import re
import json
import os
import multiprocessing
import logging
import multiprocessing
import os
import re
import traceback
from nose import case
from nose.suite import ContextSuite
@ -36,8 +35,9 @@ def parse_json_file(file_path):
def get_exc_message(exception_value):
"""
@exception_value - Exception type object
"""Gets message from exception
:param exception_value: Exception type object
"""
_exc_long = str(exception_value)
if isinstance(_exc_long, basestring):
@ -58,15 +58,14 @@ def _process_docstring(docstring, pattern):
def get_description(test_obj):
'''
Parses docstring of test object in order
"""Parses docstring of test object in order
to get necessary data.
test_obj.test._testMethodDoc is using directly
instead of calling test_obj.shortDescription()
for the sake of compability with python 2.6 where
this method works pretty buggy.
'''
"""
if isinstance(test_obj, case.Test):
docstring = test_obj.test._testMethodDoc
@ -145,15 +144,14 @@ def get_module(module_path):
def get_tests_to_update(test):
'''
Sometimes (e.g. unhandles exception is occured in
"""Sometimes (e.g. unhandles exception is occured in
setUpClass of test case) tests can be packed in
separate ContextSuite each. At the moment of following code
creation depth of this packaging was unknown so
current function is implemented with recursion
(which is not good by any means and you are free to
modify that if you can)
'''
"""
tests = []
if isinstance(test, case.Test):
@ -166,11 +164,10 @@ def get_tests_to_update(test):
def process_deployment_tags(cluster_depl_tags, test_depl_tags):
'''
Process alternative deployment tags for testsets and tests
"""Process alternative deployment tags for testsets and tests
and determines whether current test entity (testset or test)
is appropriate for cluster.
'''
"""
test_depl_tags = [
[alt_tag.strip() for alt_tag in tag.split('|')]

View File

@ -13,21 +13,21 @@
# under the License.
import os
import sys
import logging
import os
import signal
import sys
from oslo.config import cfg
from gevent import pywsgi
from oslo.config import cfg
from fuel_plugin.ostf_adapter import config as ostf_config
from fuel_plugin.ostf_adapter import nailgun_hooks
from fuel_plugin.ostf_adapter import logger
from fuel_plugin.ostf_adapter.wsgi import app
from fuel_plugin.ostf_adapter import mixins
from fuel_plugin.ostf_adapter import nailgun_hooks
from fuel_plugin.ostf_adapter.nose_plugin import nose_discovery
from fuel_plugin.ostf_adapter.storage import engine
from fuel_plugin.ostf_adapter import mixins
from fuel_plugin.ostf_adapter.wsgi import app
CONF = cfg.CONF

View File

@ -12,13 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
import logging
from oslo.config import cfg
import os
from alembic import command
from alembic import config
from oslo.config import cfg
log = logging.getLogger(__name__)

View File

@ -12,19 +12,19 @@
# License for the specific language governing permissions and limitations
# under the License.
import contextlib
import logging
from contextlib import contextmanager
from sqlalchemy import create_engine, orm
LOG = logging.getLogger(__name__)
@contextmanager
@contextlib.contextmanager
def contexted_session(dbpath):
'''Allows to handle session via context manager
'''
"""Allows to handle session via context manager
"""
LOG.debug('Starting session with dbpath={0}'.format(dbpath))
engine = create_engine(dbpath)
session = orm.Session(bind=engine)

View File

@ -13,7 +13,7 @@
# under the License.
from __future__ import with_statement
from logging.config import fileConfig
import logging
from sqlalchemy import engine_from_config, pool
@ -26,7 +26,7 @@ config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
logging.config.fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support

View File

@ -1,3 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2015 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.
"""pid_field_for_testrun
Revision ID: 5133b1e66258

View File

@ -1,3 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2015 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.
"""initial
Revision ID: 53af7c2d9ccc

View File

@ -1,3 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2015 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.
"""list_of_excl_testsets
Revision ID: 54904076d82d

View File

@ -12,18 +12,19 @@
# License for the specific language governing permissions and limitations
# under the License.
from datetime import datetime
import datetime
import logging
import sqlalchemy as sa
from sqlalchemy import desc
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.orm import joinedload, relationship, object_mapper
from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import joinedload, relationship, object_mapper
from fuel_plugin.ostf_adapter import nose_plugin
from fuel_plugin.ostf_adapter.storage import fields, engine
from fuel_plugin.ostf_adapter.storage import engine
from fuel_plugin.ostf_adapter.storage import fields
LOG = logging.getLogger(__name__)
@ -33,8 +34,7 @@ BASE = declarative_base()
class ClusterState(BASE):
'''
Represents clusters currently
"""Represents clusters currently
present in the system. Holds info
about deployment type which is using in
redeployment process.
@ -42,7 +42,7 @@ class ClusterState(BASE):
Is linked with TestSetToCluster entity
that implements many-to-many relationship with
TestSet.
'''
"""
__tablename__ = 'cluster_state'
@ -51,9 +51,7 @@ class ClusterState(BASE):
class ClusterTestingPattern(BASE):
'''
Stores cluster's pattern for testsets and tests
'''
"""Stores cluster's pattern for testsets and tests."""
__tablename__ = 'cluster_testing_pattern'
@ -191,10 +189,9 @@ class Test(BASE):
synchronize_session=False)
def copy_test(self, test_run, predefined_tests):
'''
Performs copying of tests for newly created
"""Performs copying of tests for newly created
test_run.
'''
"""
new_test = self.__class__()
mapper = object_mapper(self)
primary_keys = set([col.key for col in mapper.primary_key])
@ -223,7 +220,7 @@ class TestRun(BASE):
status = sa.Column(sa.Enum(*STATES, name='test_run_states'),
nullable=False)
meta = sa.Column(fields.JsonField())
started_at = sa.Column(sa.DateTime, default=datetime.utcnow)
started_at = sa.Column(sa.DateTime, default=datetime.datetime.utcnow)
ended_at = sa.Column(sa.DateTime)
pid = sa.Column(sa.Integer)
@ -255,7 +252,7 @@ class TestRun(BASE):
def update(self, status):
self.status = status
if status == 'finished':
self.ended_at = datetime.utcnow()
self.ended_at = datetime.datetime.utcnow()
@property
def enabled_tests(self):
@ -284,12 +281,11 @@ class TestRun(BASE):
@classmethod
def add_test_run(cls, session, test_set, cluster_id, status='running',
tests=None):
'''
Creates new test_run object with given data
"""Creates new test_run object with given data
and makes copy of tests that will be bound
with this test_run. Copying is performed by
copy_test method of Test class.
'''
"""
predefined_tests = tests or []
tests_names = session.query(ClusterTestingPattern.tests)\
.filter_by(test_set_id=test_set, cluster_id=cluster_id)\
@ -338,7 +334,7 @@ class TestRun(BASE):
@classmethod
def update_test_run(cls, session, test_run_id, updated_data):
if updated_data.get('status') in ['finished']:
updated_data['ended_at'] = datetime.utcnow()
updated_data['ended_at'] = datetime.datetime.utcnow()
session.query(cls). \
filter(cls.id == test_run_id). \
@ -346,11 +342,10 @@ class TestRun(BASE):
@classmethod
def is_last_running(cls, session, test_set, cluster_id):
'''
Checks whether there one can perform creation of new
"""Checks whether there one can perform creation of new
test_run by testing of existing of test_run object
with given data or test_run with 'finished' status.
'''
"""
test_run = cls.get_last_test_run(session, test_set, cluster_id)
return not bool(test_run) or test_run.is_finished()

View File

@ -15,19 +15,18 @@
from oslo.config import cfg
import pecan
from fuel_plugin.ostf_adapter.storage import engine
from fuel_plugin.ostf_adapter.wsgi import access_control
from fuel_plugin.ostf_adapter.wsgi import hooks
from fuel_plugin.ostf_adapter.storage import engine
CONF = cfg.CONF
def setup_config(custom_pecan_config):
'''
Updates defaults values for pecan server
"""Updates defaults values for pecan server
by those supplied via command line arguments
when ostf-server is started
'''
"""
config_to_use = {
'server': {
'host': CONF.adapter.server_host,

View File

@ -15,11 +15,13 @@
import json
import logging
from oslo.config import cfg
from pecan import abort
from pecan import expose
from pecan import request
from pecan import rest
from sqlalchemy import func
from sqlalchemy.orm import joinedload
from pecan import rest, expose, request, abort
from oslo.config import cfg
from fuel_plugin.ostf_adapter import mixins
from fuel_plugin.ostf_adapter.storage import models

View File

@ -12,15 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from pecan import expose
from fuel_plugin.ostf_adapter.wsgi import controllers
from pecan import expose
class V1Controller(object):
"""
TODO Rewrite it with wsme expose
"""
# TODO(???) Rewrite it with wsme expose
tests = controllers.TestsController()
testsets = controllers.TestsetsController()
testruns = controllers.TestrunsController()

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
import requests
from json import dumps
import time
@ -38,7 +38,7 @@ class TestingAdapterClient(object):
else:
data_el['ostf_os_access_creds'] = ostf_os_access_creds
data = dumps({'objects': data})
data = json.dumps({'objects': data})
r = requests.request(
method,
@ -146,9 +146,9 @@ class TestingAdapterClient(object):
def _with_timeout(self, action, testset, cluster_id,
timeout, polling=5, polling_hook=None):
start_time = time.time()
json = action().json()
decoded_json = action().json()
if json == [{}]:
if decoded_json == [{}]:
self.stop_testrun_last(testset, cluster_id)
time.sleep(1)
action()

View File

@ -12,14 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import TestCase
from oslo.config import cfg
import unittest
opts = [
cfg.StrOpt('quantum', default='fake')
]
class Config(TestCase):
class Config(unittest.TestCase):
def test_config(self):
cfg.CONF

View File

@ -22,8 +22,8 @@ __profile__ = {
"exclusive_testsets": []
}
import time
import httplib
import time
import unittest2

View File

@ -28,17 +28,16 @@ import unittest
class FakeTests(unittest.TestCase):
def test_successfully_passed(self):
'''imitation of work
'''
"""imitation of work
"""
self.assertTrue(True)
class WithErrorTest(unittest.TestCase):
'''
This is supoused to introduce errorness behaviour
"""This is supoused to introduce errorness behaviour
in means that it have exception raised in setUp method for
testing purposes.
'''
"""
@classmethod
def setUpClass(cls):
raise Exception('Unhandled exception in setUpClass')
@ -47,8 +46,8 @@ class WithErrorTest(unittest.TestCase):
raise Exception('Error in setUp method')
def test_supposed_to_be_success(self):
'''test in errorness class
'''
"""test in errorness class
"""
self.assertTrue(True)
def test_supposed_to_be_fail(self):

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from functools import wraps
from unittest import TestCase
import functools
import unittest
from fuel_plugin.ostf_client.client import TestingAdapterClient
@ -23,7 +23,7 @@ class EmptyResponseError(Exception):
class Response(object):
"""This is testing_adapter response object"""
"""This is testing_adapter response object."""
test_name_mapping = {}
def __init__(self, response):
@ -74,7 +74,7 @@ class AdapterClientProxy(object):
return self._decorate_call(call)
def _decorate_call(self, call):
@wraps(call)
@functools.wraps(call)
def inner(*args, **kwargs):
r = call(*args, **kwargs)
return Response(r)
@ -85,7 +85,7 @@ class SubsetException(Exception):
pass
class BaseAdapterTest(TestCase):
class BaseAdapterTest(unittest.TestCase):
def compare(self, response, comparable):
if response.is_empty:
msg = '{0} is empty'.format(response.request)

View File

@ -13,15 +13,14 @@
# under the License.
import os
import time
from sqlalchemy import create_engine
import time
from fuel_plugin.testing.tests.functional.base import \
BaseAdapterTest, Response
from fuel_plugin.ostf_client import client
from fuel_plugin.testing.tests.functional import base
class AdapterTests(BaseAdapterTest):
class AdapterTests(base.BaseAdapterTest):
@classmethod
def setUpClass(cls):
@ -136,7 +135,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.testruns_last(cluster_id)
assertions = Response(
assertions = base.Response(
[
{
'testset': 'general_test',
@ -180,7 +179,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.testruns_last(cluster_id)
assertions = Response([
assertions = base.Response([
{
'testset': 'stopped_test',
'status': 'running',
@ -240,12 +239,12 @@ class AdapterTests(BaseAdapterTest):
msg = '{0} was empty'.format(resp.request)
self.assertFalse(resp.is_empty, msg)
'''TODO: Rewrite assertions to verity that all
"""TODO: Rewrite assertions to verity that all
5 testruns ended with appropriate status
'''
"""
def test_run_single_test(self):
"""Verify that you can run individual tests from given testset"""
"""Verify that you can run individual tests from given testset."""
testset = "general_test"
tests = [
('fuel_plugin.testing.fixture.dummy_tests.'
@ -260,7 +259,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.start_testrun_tests(testset, tests, cluster_id)
assertions = Response([
assertions = base.Response([
{
'testset': 'general_test',
'status': 'running',
@ -328,7 +327,7 @@ class AdapterTests(BaseAdapterTest):
self.compare(resp, assertions)
def test_single_test_restart(self):
"""Verify that you restart individual tests for given testrun"""
"""Verify that you restart individual tests for given testrun."""
testset = "general_test"
tests = [
('fuel_plugin.testing.fixture.dummy_tests.'
@ -345,7 +344,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.restart_tests_last(testset, tests, cluster_id)
assertions = Response([
assertions = base.Response([
{
'testset': 'general_test',
'status': 'running',
@ -413,7 +412,8 @@ class AdapterTests(BaseAdapterTest):
def test_restart_combinations(self):
"""Verify that you can restart both tests that
ran and did not run during single test start"""
ran and did not run during single test start
"""
testset = "general_test"
tests = [
('fuel_plugin.testing.fixture.dummy_tests.'
@ -436,7 +436,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.restart_tests_last(testset, disabled_test,
cluster_id)
assertions = Response([
assertions = base.Response([
{
'testset': 'general_test',
'status': 'running',
@ -533,7 +533,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.testruns_last(cluster_id)
assertions = Response([
assertions = base.Response([
{
'testset': 'test_with_error',
'status': 'finished',
@ -574,7 +574,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.testruns()
assertions = Response([
assertions = base.Response([
{
'testset': 'gemini_first',
'status': 'running',
@ -628,7 +628,7 @@ class AdapterTests(BaseAdapterTest):
self.compare(resp, assertions)
def test_env_variables_are_set(self):
assertions = Response([
assertions = base.Response([
{
'testset': 'environment_variables',
'status': 'finished',

View File

@ -2,7 +2,6 @@
WebTest>=2.0.17
mock==1.0.1
requests-mock>=0.5.1
flake8
tox>=1.7.1
coverage==3.6
fabric

View File

@ -20,6 +20,7 @@ deps = -r{toxinidir}/requirements.txt
commands = {posargs:}
[testenv:pep8]
deps = hacking==0.7
usedevelop = False
commands =
flake8 {posargs}