Use the utils.BaseTestCase for all tests
Change-Id: I411fa9a60122cef6f9d5f723497a2d9427f5624e
This commit is contained in:
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
|
||||
from tests import utils
|
||||
|
||||
from ceilometerclient.common import http
|
||||
@@ -23,7 +21,7 @@ from ceilometerclient.common import http
|
||||
fixtures = {}
|
||||
|
||||
|
||||
class HttpClientTest(unittest.TestCase):
|
||||
class HttpClientTest(utils.BaseTestCase):
|
||||
|
||||
def test_url_generation_trailing_slash_in_base(self):
|
||||
client = http.HTTPClient('http://localhost/')
|
||||
|
||||
@@ -4,8 +4,6 @@ import httplib2
|
||||
import sys
|
||||
|
||||
import mox
|
||||
import unittest
|
||||
import unittest2
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
@@ -15,9 +13,10 @@ from keystoneclient.v2_0 import client as ksclient
|
||||
from ceilometerclient import exc
|
||||
from ceilometerclient.v1 import client as v1client
|
||||
import ceilometerclient.shell
|
||||
from tests import utils
|
||||
|
||||
|
||||
class ShellValidationTest(unittest.TestCase):
|
||||
class ShellValidationTest(utils.BaseTestCase):
|
||||
|
||||
def shell_error(self, argstr, error_match):
|
||||
orig = sys.stderr
|
||||
@@ -36,11 +35,11 @@ class ShellValidationTest(unittest.TestCase):
|
||||
return err
|
||||
|
||||
|
||||
class ShellTest(unittest2.TestCase):
|
||||
class ShellTest(utils.BaseTestCase):
|
||||
|
||||
# Patch os.environ to avoid required auth info.
|
||||
def setUp(self):
|
||||
self.m = mox.Mox()
|
||||
super(ShellTest, self).setUp()
|
||||
self.m.StubOutWithMock(ksclient, 'Client')
|
||||
self.m.StubOutWithMock(v1client.Client, 'json_request')
|
||||
self.m.StubOutWithMock(v1client.Client, 'raw_request')
|
||||
@@ -55,6 +54,7 @@ class ShellTest(unittest2.TestCase):
|
||||
_old_env, os.environ = os.environ, fake_env.copy()
|
||||
|
||||
def tearDown(self):
|
||||
super(ShellTest, self).tearDown()
|
||||
self.m.UnsetStubs()
|
||||
global _old_env
|
||||
os.environ = _old_env
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
import cStringIO
|
||||
import sys
|
||||
import unittest2
|
||||
|
||||
from ceilometerclient.common import utils
|
||||
from tests import utils as test_utils
|
||||
|
||||
|
||||
class UtilsTest(unittest2.TestCase):
|
||||
class UtilsTest(test_utils.BaseTestCase):
|
||||
|
||||
def test_prettytable(self):
|
||||
class Struct:
|
||||
|
||||
@@ -15,10 +15,19 @@
|
||||
|
||||
import copy
|
||||
import StringIO
|
||||
import mox
|
||||
import unittest2
|
||||
|
||||
from ceilometerclient.common import http
|
||||
|
||||
|
||||
class BaseTestCase(unittest2.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(BaseTestCase, self).setUp()
|
||||
self.m = mox.Mox()
|
||||
|
||||
|
||||
class FakeAPI(object):
|
||||
def __init__(self, fixtures):
|
||||
self.fixtures = fixtures
|
||||
@@ -56,4 +65,3 @@ class FakeResponse(object):
|
||||
|
||||
def read(self, amt):
|
||||
return self.body.read(amt)
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
|
||||
import ceilometerclient.v1.meters
|
||||
from tests import utils
|
||||
|
||||
@@ -107,9 +105,10 @@ fixtures = {
|
||||
}
|
||||
|
||||
|
||||
class MeterManagerTest(unittest.TestCase):
|
||||
class MeterManagerTest(utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(MeterManagerTest, self).setUp()
|
||||
self.api = utils.FakeAPI(fixtures)
|
||||
self.mgr = ceilometerclient.v1.meters.MeterManager(self.api)
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
|
||||
import ceilometerclient.v1.meters
|
||||
from tests import utils
|
||||
|
||||
@@ -38,9 +36,10 @@ fixtures = {
|
||||
}
|
||||
|
||||
|
||||
class ProjectManagerTest(unittest.TestCase):
|
||||
class ProjectManagerTest(utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ProjectManagerTest, self).setUp()
|
||||
self.api = utils.FakeAPI(fixtures)
|
||||
self.mgr = ceilometerclient.v1.meters.ProjectManager(self.api)
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
|
||||
import ceilometerclient.v1.meters
|
||||
from tests import utils
|
||||
|
||||
@@ -106,9 +104,10 @@ fixtures = {
|
||||
}
|
||||
|
||||
|
||||
class ResourceManagerTest(unittest.TestCase):
|
||||
class ResourceManagerTest(utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ResourceManagerTest, self).setUp()
|
||||
self.api = utils.FakeAPI(fixtures)
|
||||
self.mgr = ceilometerclient.v1.meters.ResourceManager(self.api)
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
|
||||
import ceilometerclient.v1.meters
|
||||
from tests import utils
|
||||
|
||||
@@ -120,9 +118,10 @@ fixtures = {
|
||||
}
|
||||
|
||||
|
||||
class SampleManagerTest(unittest.TestCase):
|
||||
class SampleManagerTest(utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(SampleManagerTest, self).setUp()
|
||||
self.api = utils.FakeAPI(fixtures)
|
||||
self.mgr = ceilometerclient.v1.meters.SampleManager(self.api)
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
|
||||
import ceilometerclient.v1.meters
|
||||
from tests import utils
|
||||
|
||||
@@ -38,9 +36,10 @@ fixtures = {
|
||||
}
|
||||
|
||||
|
||||
class UserManagerTest(unittest.TestCase):
|
||||
class UserManagerTest(utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(UserManagerTest, self).setUp()
|
||||
self.api = utils.FakeAPI(fixtures)
|
||||
self.mgr = ceilometerclient.v1.meters.UserManager(self.api)
|
||||
|
||||
|
||||
@@ -11,12 +11,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
|
||||
from ceilometerclient.v2 import options
|
||||
from tests import utils
|
||||
|
||||
|
||||
class BuildUrlTest(unittest.TestCase):
|
||||
class BuildUrlTest(utils.BaseTestCase):
|
||||
|
||||
def test_one(self):
|
||||
url = options.build_url('/', [{'field': 'this',
|
||||
@@ -42,7 +41,7 @@ class BuildUrlTest(unittest.TestCase):
|
||||
self.assertEqual(url, '/?q.op=&q.value=43&q.field=this')
|
||||
|
||||
|
||||
class CliTest(unittest.TestCase):
|
||||
class CliTest(utils.BaseTestCase):
|
||||
|
||||
def test_one(self):
|
||||
ar = options.cli_to_array('this<=34')
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
|
||||
import ceilometerclient.v2.resources
|
||||
from tests import utils
|
||||
|
||||
@@ -68,9 +66,10 @@ fixtures = {
|
||||
}
|
||||
|
||||
|
||||
class ResourceManagerTest(unittest.TestCase):
|
||||
class ResourceManagerTest(utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ResourceManagerTest, self).setUp()
|
||||
self.api = utils.FakeAPI(fixtures)
|
||||
self.mgr = ceilometerclient.v2.resources.ResourceManager(self.api)
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
|
||||
import ceilometerclient.v2.samples
|
||||
from tests import utils
|
||||
|
||||
@@ -52,9 +50,10 @@ fixtures = {
|
||||
}
|
||||
|
||||
|
||||
class SampleManagerTest(unittest.TestCase):
|
||||
class SampleManagerTest(utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(SampleManagerTest, self).setUp()
|
||||
self.api = utils.FakeAPI(fixtures)
|
||||
self.mgr = ceilometerclient.v2.samples.SampleManager(self.api)
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
|
||||
import ceilometerclient.v2.statistics
|
||||
from tests import utils
|
||||
|
||||
@@ -58,9 +56,10 @@ fixtures = {
|
||||
}
|
||||
|
||||
|
||||
class StatisticsManagerTest(unittest.TestCase):
|
||||
class StatisticsManagerTest(utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(StatisticsManagerTest, self).setUp()
|
||||
self.api = utils.FakeAPI(fixtures)
|
||||
self.mgr = ceilometerclient.v2.statistics.StatisticsManager(self.api)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user