Skip to content

Commit

Permalink
Merge "Fix and gate on H302 (import only modules)"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Aug 30, 2013
2 parents d734bd5 + 686d48d commit 3951958
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 41 deletions.
17 changes: 9 additions & 8 deletions nova/tests/api/ec2/test_error_response.py
Expand Up @@ -20,10 +20,10 @@

from lxml import etree

from nova.api.ec2 import ec2_error_ex
from nova.context import RequestContext
from nova.api import ec2
from nova import context
from nova import test
from nova.wsgi import Request
from nova import wsgi


class TestClientExceptionEC2(Exception):
Expand All @@ -37,12 +37,13 @@ class Ec2ErrorResponseTestCase(test.TestCase):
Test EC2 error responses.
This deals mostly with api/ec2/__init__.py code, especially
the ec2_error_ex helper.
the ec2.ec2_error_ex helper.
"""
def setUp(self):
super(Ec2ErrorResponseTestCase, self).setUp()
self.context = RequestContext('test_user_id', 'test_project_id')
self.req = Request.blank('/test')
self.context = context.RequestContext('test_user_id',
'test_project_id')
self.req = wsgi.Request.blank('/test')
self.req.environ['nova.context'] = self.context

def _validate_ec2_error(self, response, http_status, ec2_code, msg=None,
Expand Down Expand Up @@ -82,7 +83,7 @@ def test_exception_ec2_client(self):
Test response to client (400) EC2 exception.
"""
msg = "Test client failure."
err = ec2_error_ex(TestClientExceptionEC2(msg), self.req)
err = ec2.ec2_error_ex(TestClientExceptionEC2(msg), self.req)
self._validate_ec2_error(err, TestClientExceptionEC2.code,
TestClientExceptionEC2.ec2_code, msg)

Expand All @@ -91,7 +92,7 @@ def test_unexpected_exception_ec2_client(self):
Test response to an unexpected client (400) exception.
"""
msg = "Test client failure."
err = ec2_error_ex(TestClientExceptionEC2(msg), self.req,
err = ec2.ec2_error_ex(TestClientExceptionEC2(msg), self.req,
unexpected=True)
self._validate_ec2_error(err, TestClientExceptionEC2.code,
TestClientExceptionEC2.ec2_code, msg)
4 changes: 2 additions & 2 deletions nova/tests/api/ec2/test_faults.py
Expand Up @@ -17,7 +17,7 @@

from nova.api.ec2 import faults
from nova import test
from nova.wsgi import Request
from nova import wsgi


class TestFaults(test.TestCase):
Expand All @@ -40,7 +40,7 @@ def test_fault_call(self):
message = 'test message'
ex = webob.exc.HTTPNotFound(explanation=message)
fault = faults.Fault(ex)
req = Request.blank('/test')
req = wsgi.Request.blank('/test')
req.GET['AWSAccessKeyId'] = "test_user_id:test_project_id"
self.mox.StubOutWithMock(faults, 'ec2_error_response')
faults.ec2_error_response(mox.IgnoreArg(), 'HTTPNotFound',
Expand Down
21 changes: 9 additions & 12 deletions nova/tests/compute/test_compute.py
Expand Up @@ -77,11 +77,7 @@
from nova.tests import matchers
from nova.tests.objects import test_migration
from nova import utils
from nova.virt.event import EVENT_LIFECYCLE_PAUSED
from nova.virt.event import EVENT_LIFECYCLE_RESUMED
from nova.virt.event import EVENT_LIFECYCLE_STARTED
from nova.virt.event import EVENT_LIFECYCLE_STOPPED
from nova.virt.event import LifecycleEvent
from nova.virt import event
from nova.virt import fake
from nova.volume import cinder

Expand Down Expand Up @@ -5273,26 +5269,27 @@ def _test_lifecycle_event(self, lifecycle_event, power_state):
mox.ContainsKeyValue('uuid', uuid),
power_state)
self.mox.ReplayAll()
self.compute.handle_events(LifecycleEvent(uuid, lifecycle_event))
self.compute.handle_events(event.LifecycleEvent(uuid, lifecycle_event))
self.mox.VerifyAll()
self.mox.UnsetStubs()

def test_lifecycle_events(self):
self._test_lifecycle_event(EVENT_LIFECYCLE_STOPPED,
self._test_lifecycle_event(event.EVENT_LIFECYCLE_STOPPED,
power_state.SHUTDOWN)
self._test_lifecycle_event(EVENT_LIFECYCLE_STARTED,
self._test_lifecycle_event(event.EVENT_LIFECYCLE_STARTED,
power_state.RUNNING)
self._test_lifecycle_event(EVENT_LIFECYCLE_PAUSED,
self._test_lifecycle_event(event.EVENT_LIFECYCLE_PAUSED,
power_state.PAUSED)
self._test_lifecycle_event(EVENT_LIFECYCLE_RESUMED,
self._test_lifecycle_event(event.EVENT_LIFECYCLE_RESUMED,
power_state.RUNNING)
self._test_lifecycle_event(-1, None)

def test_lifecycle_event_non_existent_instance(self):
# No error raised for non-existent instance because of inherent race
# between database updates and hypervisor events. See bug #1180501.
event = LifecycleEvent('does-not-exist', EVENT_LIFECYCLE_STOPPED)
self.compute.handle_events(event)
event_instance = event.LifecycleEvent('does-not-exist',
event.EVENT_LIFECYCLE_STOPPED)
self.compute.handle_events(event_instance)

def test_allow_confirm_resize_on_instance_in_deleting_task_state(self):
instance = self._create_fake_instance_obj()
Expand Down
9 changes: 4 additions & 5 deletions nova/tests/db/test_db_api.py
Expand Up @@ -48,8 +48,7 @@
from nova.openstack.common.db.sqlalchemy import session as db_session
from nova.openstack.common import timeutils
from nova.openstack.common import uuidutils
from nova.quota import ReservableResource
from nova.quota import resources
from nova import quota
from nova import test
from nova.tests import matchers
from nova import utils
Expand Down Expand Up @@ -95,7 +94,7 @@ def sync(elevated, project_id, user_id, session):
resource, i,
user_id=user_id)
sync_name = '_sync_%s' % resource
resources[resource] = ReservableResource(
resources[resource] = quota.ReservableResource(
resource, sync_name, 'quota_res_%d' % i)
deltas[resource] = i
setattr(sqlalchemy_api, sync_name, get_sync(resource, i))
Expand Down Expand Up @@ -4899,8 +4898,8 @@ def test_quota_reserve_all_resources(self):
quotas = {}
deltas = {}
reservable_resources = {}
for i, resource in enumerate(resources):
if isinstance(resource, ReservableResource):
for i, resource in enumerate(quota.resources):
if isinstance(resource, quota.ReservableResource):
quotas[resource.name] = db.quota_create(self.ctxt, 'project1',
resource.name, 100)
deltas[resource.name] = i
Expand Down
11 changes: 7 additions & 4 deletions nova/tests/integrated/test_api_samples.py
Expand Up @@ -30,7 +30,7 @@
from nova.api.metadata import password
from nova.api.openstack.compute.contrib import coverage_ext
from nova.api.openstack.compute.contrib import fping
from nova.api.openstack.compute.extensions import ExtensionManager as ext_mgr
from nova.api.openstack.compute import extensions
# Import extensions to pull in osapi_compute_extension CONF option used below.
from nova.cells import rpcapi as cells_rpcapi
from nova.cells import state
Expand Down Expand Up @@ -1759,7 +1759,8 @@ def test_service_detail(self):
Return a list of all running services with the disable reason
information if that exists.
"""
self.stubs.Set(ext_mgr, "is_loaded", self.fake_load)
self.stubs.Set(extensions.ExtensionManager, "is_loaded",
self.fake_load)
response = self._do_get('os-services')
self.assertEqual(response.status, 200)
subs = {'binary': 'nova-compute',
Expand All @@ -1773,7 +1774,8 @@ def test_service_detail(self):

def test_service_disable_log_reason(self):
"""Disable an existing service and log the reason."""
self.stubs.Set(ext_mgr, "is_loaded", self.fake_load)
self.stubs.Set(extensions.ExtensionManager, "is_loaded",
self.fake_load)
subs = {"host": "host1",
'binary': 'nova-compute',
'disabled_reason': 'test2'}
Expand Down Expand Up @@ -2140,7 +2142,8 @@ def test_show_quotas_for_user(self):

def test_delete_quotas_for_user(self):
# Get api sample to delete quota for user.
self.stubs.Set(ext_mgr, "is_loaded", self.fake_load)
self.stubs.Set(extensions.ExtensionManager, "is_loaded",
self.fake_load)
response = self._do_delete('os-quota-sets/fake_tenant?user_id=1')
self.assertEqual(response.status, 202)
self.assertEqual(response.read(), '')
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/integrated/v3/api_sample_base.py
Expand Up @@ -17,7 +17,7 @@

from oslo.config import cfg

from nova.api.openstack import API_V3_CORE_EXTENSIONS
from nova.api.openstack import API_V3_CORE_EXTENSIONS # noqa
from nova import test
from nova.tests import fake_network
from nova.tests import fake_utils
Expand Down
4 changes: 2 additions & 2 deletions nova/tests/virt/libvirt/test_designer.py
Expand Up @@ -15,7 +15,7 @@
# under the License.

from nova import test
from nova.virt.libvirt.designer import set_vif_bandwidth_config
from nova.virt.libvirt import designer


class DesignerTestCase(test.TestCase):
Expand All @@ -27,6 +27,6 @@ def test_set_vif_bandwidth_config_no_extra_specs(self):
# The conf will never be user be used, so we can use 'None'.
# An empty dictionary is fine: all that matters it that there is no
# 'extra_specs' field.
set_vif_bandwidth_config(None, {})
designer.set_vif_bandwidth_config(None, {})
except KeyError as e:
self.fail('KeyError: %s' % e)
8 changes: 4 additions & 4 deletions nova/tests/virt/vmwareapi/test_vmwareapi_vm_util.py
Expand Up @@ -16,7 +16,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from collections import namedtuple
import collections
import re

from nova import exception
Expand Down Expand Up @@ -159,9 +159,9 @@ def test_get_host_name_for_vm(self):

def test_property_from_property_set(self):

ObjectContent = namedtuple('ObjectContent', ['propSet'])
DynamicProperty = namedtuple('Property', ['name', 'val'])
MoRef = namedtuple('Val', ['value'])
ObjectContent = collections.namedtuple('ObjectContent', ['propSet'])
DynamicProperty = collections.namedtuple('Property', ['name', 'val'])
MoRef = collections.namedtuple('Val', ['value'])

good_objects = fake.FakeRetrieveResult()
results_good = [
Expand Down
4 changes: 2 additions & 2 deletions nova/tests/virt/xenapi/test_driver.py
Expand Up @@ -17,7 +17,7 @@

from nova.tests.virt.xenapi import stubs
from nova.virt import fake
from nova.virt.xenapi import XenAPIDriver
from nova.virt import xenapi


class XenAPIDriverTestCase(stubs.XenAPITestBase):
Expand All @@ -37,7 +37,7 @@ def test_available_resource(self):
xenapi_connection_password='test_pass')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)

driver = XenAPIDriver(fake.FakeVirtAPI(), False)
driver = xenapi.XenAPIDriver(fake.FakeVirtAPI(), False)
driver._session.product_version = (6, 8, 2)

self.stubs.Set(driver, 'get_host_stats', self.host_stats)
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Expand Up @@ -46,8 +46,9 @@ commands = {posargs}
# TODO Hacking 0.6 checks to fix
# H102 Apache 2.0 license header not found

ignore = E121,E122,E123,E124,E126,E127,E128,E711,E712,H102,H302,H404,F403,F811,F841
ignore = E121,E122,E123,E124,E126,E127,E128,E711,E712,H102,H404,F403,F811,F841
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,*plugins/xenserver*,tools

[hacking]
local-check-factory = nova.hacking.checks.factory
import_exceptions = nova.openstack.common.gettextutils._

0 comments on commit 3951958

Please sign in to comment.