summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-06-06 00:03:38 +0000
committerGerrit Code Review <review@openstack.org>2013-06-06 00:03:39 +0000
commitf22679007d772b31d69d8f024f5f8cbb03fb3da2 (patch)
tree073d90ac81bdde9f11618382dbe8b9035991d692
parentfc5137d764b3768f713b87dfe55133ae51b41edf (diff)
parent895e61c57f1c4e15e414a9e1f108d75a63378c83 (diff)
downloadnova-f22679007d772b31d69d8f024f5f8cbb03fb3da2.tar.gz
nova-f22679007d772b31d69d8f024f5f8cbb03fb3da2.tar.xz
nova-f22679007d772b31d69d8f024f5f8cbb03fb3da2.zip
Merge "Moving `test_misc` tests to better locations"
-rw-r--r--nova/tests/test_exception.py14
-rw-r--r--nova/tests/test_migrations.py28
-rw-r--r--nova/tests/test_misc.py61
3 files changed, 42 insertions, 61 deletions
diff --git a/nova/tests/test_exception.py b/nova/tests/test_exception.py
index 040b56b13..10a877b8e 100644
--- a/nova/tests/test_exception.py
+++ b/nova/tests/test_exception.py
@@ -169,3 +169,17 @@ class NovaExceptionTestCase(test.TestCase):
self.flags(fatal_exception_format_errors=False)
exc = FakeNovaException_Remote(lame_arg='lame')
self.assertEquals(exc.format_message(), "some message %(somearg)s")
+
+
+class ExceptionTestCase(test.TestCase):
+ @staticmethod
+ def _raise_exc(exc):
+ raise exc()
+
+ def test_exceptions_raise(self):
+ # NOTE(dprince): disable format errors since we are not passing kwargs
+ self.flags(fatal_exception_format_errors=False)
+ for name in dir(exception):
+ exc = getattr(exception, name)
+ if isinstance(exc, type):
+ self.assertRaises(exc, self._raise_exc, exc)
diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py
index 9baf9eb6a..7121bdb04 100644
--- a/nova/tests/test_migrations.py
+++ b/nova/tests/test_migrations.py
@@ -45,6 +45,7 @@ import collections
import commands
import ConfigParser
import datetime
+import glob
import os
import urlparse
import uuid
@@ -1517,3 +1518,30 @@ class TestBaremetalMigrations(BaseMigrationTestCase, CommonTestsMixIn):
bm_nodes = db_utils.get_table(engine, 'bm_nodes')
columns = [c.name for c in bm_nodes.columns]
self.assertNotIn(u'prov_mac_address', columns)
+
+
+class ProjectTestCase(test.TestCase):
+
+ def test_all_migrations_have_downgrade(self):
+ topdir = os.path.normpath(os.path.dirname(__file__) + '/../../../')
+ py_glob = os.path.join(topdir, "nova", "db", "sqlalchemy",
+ "migrate_repo", "versions", "*.py")
+
+ missing_downgrade = []
+ for path in glob.iglob(py_glob):
+ has_upgrade = False
+ has_downgrade = False
+ with open(path, "r") as f:
+ for line in f:
+ if 'def upgrade(' in line:
+ has_upgrade = True
+ if 'def downgrade(' in line:
+ has_downgrade = True
+
+ if has_upgrade and not has_downgrade:
+ fname = os.path.basename(path)
+ missing_downgrade.append(fname)
+
+ helpful_msg = (_("The following migrations are missing a downgrade:"
+ "\n\t%s") % '\n\t'.join(sorted(missing_downgrade)))
+ self.assert_(not missing_downgrade, helpful_msg)
diff --git a/nova/tests/test_misc.py b/nova/tests/test_misc.py
deleted file mode 100644
index 6744a2a6a..000000000
--- a/nova/tests/test_misc.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 OpenStack Foundation
-#
-# 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 glob
-import os
-
-from nova import exception
-from nova import test
-
-
-class ExceptionTestCase(test.TestCase):
- @staticmethod
- def _raise_exc(exc):
- raise exc()
-
- def test_exceptions_raise(self):
- # NOTE(dprince): disable format errors since we are not passing kwargs
- self.flags(fatal_exception_format_errors=False)
- for name in dir(exception):
- exc = getattr(exception, name)
- if isinstance(exc, type):
- self.assertRaises(exc, self._raise_exc, exc)
-
-
-class ProjectTestCase(test.TestCase):
-
- def test_all_migrations_have_downgrade(self):
- topdir = os.path.normpath(os.path.dirname(__file__) + '/../../')
- py_glob = os.path.join(topdir, "nova", "db", "sqlalchemy",
- "migrate_repo", "versions", "*.py")
- missing_downgrade = []
- for path in glob.iglob(py_glob):
- has_upgrade = False
- has_downgrade = False
- with open(path, "r") as f:
- for line in f:
- if 'def upgrade(' in line:
- has_upgrade = True
- if 'def downgrade(' in line:
- has_downgrade = True
-
- if has_upgrade and not has_downgrade:
- fname = os.path.basename(path)
- missing_downgrade.append(fname)
-
- helpful_msg = (_("The following migrations are missing a downgrade:"
- "\n\t%s") % '\n\t'.join(sorted(missing_downgrade)))
- self.assert_(not missing_downgrade, helpful_msg)