Merge "Unit test case migration for Event object"

This commit is contained in:
Jenkins 2015-03-23 04:01:32 +00:00 committed by Gerrit Code Review
commit 912b977360
2 changed files with 9 additions and 6 deletions

View File

@ -48,6 +48,7 @@ from heat.engine import stack_lock
from heat.engine import template as templatem
from heat.engine import watchrule
from heat.engine import worker
from heat.objects import event as event_object
from heat.objects import resource as resource_objects
from heat.objects import service as service_objects
from heat.objects import software_deployment as software_deployment_object
@ -1921,7 +1922,7 @@ class StackServiceTest(common.HeatTestCase):
self.m.VerifyAll()
@mock.patch.object(db_api, 'event_get_all_by_stack')
@mock.patch.object(event_object.Event, 'get_all_by_stack')
@mock.patch.object(service.EngineService, '_get_stack')
def test_stack_events_list_passes_marker_and_filters(self,
mock_get_stack,
@ -1944,7 +1945,7 @@ class StackServiceTest(common.HeatTestCase):
sort_dir=sort_dir,
filters=filters)
@mock.patch.object(db_api, 'event_get_all_by_tenant')
@mock.patch.object(event_object.Event, 'get_all_by_tenant')
def test_tenant_events_list_passes_marker_and_filters(
self, mock_tenant_events_get_all):
limit = object()

View File

@ -19,6 +19,7 @@ from heat.engine import parser
from heat.engine import resource
from heat.engine import rsrc_defn
from heat.engine import template
from heat.objects import event as event_object
from heat.tests import common
from heat.tests import generic_resource as generic_rsrc
from heat.tests import utils
@ -89,7 +90,7 @@ class EventTest(common.HeatTestCase):
e.store()
self.assertIsNotNone(e.id)
ev = db_api.event_get(self.ctx, e.id)
ev = event_object.Event.get_by_id(self.ctx, e.id)
loaded_e = event.Event.load(self.ctx, e.id, stack=self.stack, event=ev)
@ -111,13 +112,14 @@ class EventTest(common.HeatTestCase):
'alabama', self.resource.properties,
self.resource.name, self.resource.type())
e.store()
self.assertEqual(1, len(db_api.event_get_all_by_stack(self.ctx,
self.stack.id)))
self.assertEqual(1, len(event_object.Event.get_all_by_stack(
self.ctx,
self.stack.id)))
e = event.Event(self.ctx, self.stack, 'TEST', 'IN_PROGRESS', 'Testing',
'arizona', self.resource.properties,
self.resource.name, self.resource.type())
e.store()
events = db_api.event_get_all_by_stack(self.ctx, self.stack.id)
events = event_object.Event.get_all_by_stack(self.ctx, self.stack.id)
self.assertEqual(1, len(events))
self.assertEqual('arizona', events[0].physical_resource_id)