Merge "add more test cases to improve the test code coverage #2"
This commit is contained in:
commit
a162cef4d1
@ -24,10 +24,12 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import repr
|
||||||
from mock import patch
|
from mock import patch
|
||||||
|
|
||||||
from ceilometer.storage import models
|
from ceilometer.storage import models
|
||||||
from ceilometer.storage.sqlalchemy.models import table_args
|
from ceilometer.storage.sqlalchemy.models import table_args
|
||||||
|
from ceilometer.storage.sqlalchemy import models as sql_models
|
||||||
from ceilometer import utils
|
from ceilometer import utils
|
||||||
from ceilometer.tests import db as tests_db
|
from ceilometer.tests import db as tests_db
|
||||||
|
|
||||||
@ -38,6 +40,13 @@ class EventTestBase(tests_db.TestBase):
|
|||||||
database_connection = 'sqlite://'
|
database_connection = 'sqlite://'
|
||||||
|
|
||||||
|
|
||||||
|
class CeilometerBaseTest(EventTestBase):
|
||||||
|
def test_ceilometer_base(self):
|
||||||
|
base = sql_models.CeilometerBase()
|
||||||
|
base['key'] = 'value'
|
||||||
|
self.assertEqual(base['key'], 'value')
|
||||||
|
|
||||||
|
|
||||||
class UniqueNameTest(EventTestBase):
|
class UniqueNameTest(EventTestBase):
|
||||||
# UniqueName is a construct specific to sqlalchemy.
|
# UniqueName is a construct specific to sqlalchemy.
|
||||||
# Not applicable to other drivers.
|
# Not applicable to other drivers.
|
||||||
@ -55,6 +64,8 @@ class UniqueNameTest(EventTestBase):
|
|||||||
u2 = self.conn._get_or_create_unique_name("blah")
|
u2 = self.conn._get_or_create_unique_name("blah")
|
||||||
self.assertNotEqual(u1.id, u2.id)
|
self.assertNotEqual(u1.id, u2.id)
|
||||||
self.assertNotEqual(u1.key, u2.key)
|
self.assertNotEqual(u1.key, u2.key)
|
||||||
|
# Test the method __repr__ returns a string
|
||||||
|
self.assertTrue(repr.repr(u2))
|
||||||
|
|
||||||
|
|
||||||
class MyException(Exception):
|
class MyException(Exception):
|
||||||
@ -115,6 +126,16 @@ class EventTest(EventTestBase):
|
|||||||
for bad, event in problem_events:
|
for bad, event in problem_events:
|
||||||
self.assertEquals(models.Event.UNKNOWN_PROBLEM, bad)
|
self.assertEquals(models.Event.UNKNOWN_PROBLEM, bad)
|
||||||
|
|
||||||
|
def test_get_none_value_traits(self):
|
||||||
|
model = sql_models.Trait(None, None, 5)
|
||||||
|
self.assertIsNone(model.get_value())
|
||||||
|
self.assertTrue(repr.repr(model))
|
||||||
|
|
||||||
|
def test_event_repr(self):
|
||||||
|
ev = sql_models.Event('msg_id', None, False)
|
||||||
|
ev.id = 100
|
||||||
|
self.assertTrue(repr.repr(ev))
|
||||||
|
|
||||||
|
|
||||||
class ModelTest(tests_db.TestBase):
|
class ModelTest(tests_db.TestBase):
|
||||||
database_connection = 'mysql://localhost'
|
database_connection = 'mysql://localhost'
|
||||||
|
Loading…
Reference in New Issue
Block a user