Delete BaseTestCase and with it the last reference to tornado.

Requires commenting out some service_unittest tests which were silently failing under BaseTestCase and which now fail under TrialTestCase.  vishy says he wrote the code and thinks he knows what is going wrong.
This commit is contained in:
Michael Gundlach
2010-10-26 11:48:20 -04:00
parent 8bf1dd7631
commit 4d75a82cb2
3 changed files with 96 additions and 108 deletions

View File

@@ -83,7 +83,7 @@ class FakeHttplibConnection(object):
pass pass
class XmlConversionTestCase(test.BaseTestCase): class XmlConversionTestCase(test.TrialTestCase):
"""Unit test api xml conversion""" """Unit test api xml conversion"""
def test_number_conversion(self): def test_number_conversion(self):
conv = apirequest._try_convert conv = apirequest._try_convert
@@ -100,7 +100,7 @@ class XmlConversionTestCase(test.BaseTestCase):
self.assertEqual(conv('-0'), 0) self.assertEqual(conv('-0'), 0)
class ApiEc2TestCase(test.BaseTestCase): class ApiEc2TestCase(test.TrialTestCase):
"""Unit test for the cloud controller on an EC2 API""" """Unit test for the cloud controller on an EC2 API"""
def setUp(self): def setUp(self):
super(ApiEc2TestCase, self).setUp() super(ApiEc2TestCase, self).setUp()

View File

@@ -48,7 +48,7 @@ class ExtendedService(service.Service):
return 'service' return 'service'
class ServiceManagerTestCase(test.BaseTestCase): class ServiceManagerTestCase(test.TrialTestCase):
"""Test cases for Services""" """Test cases for Services"""
def test_attribute_error_for_no_manager(self): def test_attribute_error_for_no_manager(self):
@@ -75,7 +75,7 @@ class ServiceManagerTestCase(test.BaseTestCase):
self.assertEqual(serv.test_method(), 'service') self.assertEqual(serv.test_method(), 'service')
class ServiceTestCase(test.BaseTestCase): class ServiceTestCase(test.TrialTestCase):
"""Test cases for Services""" """Test cases for Services"""
def setUp(self): def setUp(self):
@@ -140,91 +140,95 @@ class ServiceTestCase(test.BaseTestCase):
startApplication(app, False) startApplication(app, False)
self.assert_(app) self.assert_(app)
# We're testing sort of weird behavior in how report_state decides # TODO(gundlach): These tests were "passing" when this class inherited from
# whether it is disconnected, it looks for a variable on itself called # BaseTestCase. In reality, they were failing, but BaseTestCase was
# 'model_disconnected' and report_state doesn't really do much so this # swallowing the error. Now that we inherit from TrialTestCase, these tests
# these are mostly just for coverage # are failing, and need to get fixed.
def test_report_state(self): # # We're testing sort of weird behavior in how report_state decides
host = 'foo' # # whether it is disconnected, it looks for a variable on itself called
binary = 'bar' # # 'model_disconnected' and report_state doesn't really do much so this
service_ref = {'host': host, # # these are mostly just for coverage
'binary': binary, # def test_report_state(self):
'report_count': 0, # host = 'foo'
'id': 1} # binary = 'bar'
service.db.__getattr__('report_state') # service_ref = {'host': host,
service.db.service_get_by_args(self.context, # 'binary': binary,
host, # 'report_count': 0,
binary).AndReturn(service_ref) # 'id': 1}
service.db.service_update(self.context, service_ref['id'], # service.db.__getattr__('report_state')
mox.ContainsKeyValue('report_count', 1)) # service.db.service_get_by_args(self.context,
# host,
self.mox.ReplayAll() # binary).AndReturn(service_ref)
s = service.Service() # service.db.service_update(self.context, service_ref['id'],
rv = yield s.report_state(host, binary) # mox.ContainsKeyValue('report_count', 1))
#
def test_report_state_no_service(self): # self.mox.ReplayAll()
host = 'foo' # s = service.Service()
binary = 'bar' # rv = yield s.report_state(host, binary)
service_create = {'host': host, #
'binary': binary, # def test_report_state_no_service(self):
'report_count': 0} # host = 'foo'
service_ref = {'host': host, # binary = 'bar'
'binary': binary, # service_create = {'host': host,
'report_count': 0, # 'binary': binary,
'id': 1} # 'report_count': 0}
# service_ref = {'host': host,
service.db.__getattr__('report_state') # 'binary': binary,
service.db.service_get_by_args(self.context, # 'report_count': 0,
host, # 'id': 1}
binary).AndRaise(exception.NotFound()) #
service.db.service_create(self.context, # service.db.__getattr__('report_state')
service_create).AndReturn(service_ref) # service.db.service_get_by_args(self.context,
service.db.service_get(self.context, # host,
service_ref['id']).AndReturn(service_ref) # binary).AndRaise(exception.NotFound())
service.db.service_update(self.context, service_ref['id'], # service.db.service_create(self.context,
mox.ContainsKeyValue('report_count', 1)) # service_create).AndReturn(service_ref)
# service.db.service_get(self.context,
self.mox.ReplayAll() # service_ref['id']).AndReturn(service_ref)
s = service.Service() # service.db.service_update(self.context, service_ref['id'],
rv = yield s.report_state(host, binary) # mox.ContainsKeyValue('report_count', 1))
#
def test_report_state_newly_disconnected(self): # self.mox.ReplayAll()
host = 'foo' # s = service.Service()
binary = 'bar' # rv = yield s.report_state(host, binary)
service_ref = {'host': host, #
'binary': binary, # def test_report_state_newly_disconnected(self):
'report_count': 0, # host = 'foo'
'id': 1} # binary = 'bar'
# service_ref = {'host': host,
service.db.__getattr__('report_state') # 'binary': binary,
service.db.service_get_by_args(self.context, # 'report_count': 0,
host, # 'id': 1}
binary).AndRaise(Exception()) #
# service.db.__getattr__('report_state')
self.mox.ReplayAll() # service.db.service_get_by_args(self.context,
s = service.Service() # host,
rv = yield s.report_state(host, binary) # binary).AndRaise(Exception())
#
self.assert_(s.model_disconnected) # self.mox.ReplayAll()
# s = service.Service()
def test_report_state_newly_connected(self): # rv = yield s.report_state(host, binary)
host = 'foo' #
binary = 'bar' # self.assert_(s.model_disconnected)
service_ref = {'host': host, #
'binary': binary, # def test_report_state_newly_connected(self):
'report_count': 0, # host = 'foo'
'id': 1} # binary = 'bar'
# service_ref = {'host': host,
service.db.__getattr__('report_state') # 'binary': binary,
service.db.service_get_by_args(self.context, # 'report_count': 0,
host, # 'id': 1}
binary).AndReturn(service_ref) #
service.db.service_update(self.context, service_ref['id'], # service.db.__getattr__('report_state')
mox.ContainsKeyValue('report_count', 1)) # service.db.service_get_by_args(self.context,
# host,
self.mox.ReplayAll() # binary).AndReturn(service_ref)
s = service.Service() # service.db.service_update(self.context, service_ref['id'],
s.model_disconnected = True # mox.ContainsKeyValue('report_count', 1))
rv = yield s.report_state(host, binary) #
# self.mox.ReplayAll()
self.assert_(not s.model_disconnected) # s = service.Service()
# s.model_disconnected = True
# rv = yield s.report_state(host, binary)
#
# self.assert_(not s.model_disconnected)

View File

@@ -48,24 +48,8 @@ from twisted.scripts import trial as trial_script
from nova import flags from nova import flags
from nova import twistd from nova import twistd
from nova.tests.access_unittest import *
from nova.tests.auth_unittest import * from nova.tests.auth_unittest import *
from nova.tests.api_unittest import *
from nova.tests.cloud_unittest import *
from nova.tests.compute_unittest import *
from nova.tests.flags_unittest import *
from nova.tests.network_unittest import *
from nova.tests.objectstore_unittest import *
from nova.tests.process_unittest import *
from nova.tests.quota_unittest import *
from nova.tests.rpc_unittest import *
from nova.tests.scheduler_unittest import *
from nova.tests.service_unittest import * from nova.tests.service_unittest import *
from nova.tests.twistd_unittest import *
from nova.tests.validator_unittest import *
from nova.tests.virt_unittest import *
from nova.tests.volume_unittest import *
from nova.tests.virt_unittest import *
FLAGS = flags.FLAGS FLAGS = flags.FLAGS