f17f7d6690
Openstack common has a wrapper for generating uuids. We should use that function when generating uuids for consistency. Change-Id: I839aef8095960ebe00e6e7992c5415b7d7dfa3d9 Closes-Bug: #1082248
44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
#
|
|
# Copyright 2013 IBM Corp
|
|
#
|
|
# 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 datetime
|
|
|
|
import mock
|
|
from oslo_utils import uuidutils
|
|
from oslotest import base
|
|
|
|
from panko.dispatcher import database
|
|
from panko.event.storage import models as event_models
|
|
from panko import service
|
|
|
|
|
|
class TestDispatcherDB(base.BaseTestCase):
|
|
|
|
def setUp(self):
|
|
super(TestDispatcherDB, self).setUp()
|
|
self.CONF = service.prepare_service([], [])
|
|
self.CONF.set_override('connection', 'sqlite://', group='database')
|
|
with mock.patch('panko.service.prepare_service') as f:
|
|
f.return_value = self.CONF
|
|
self.dispatcher = database.DatabaseDispatcher(None)
|
|
|
|
def test_event_conn(self):
|
|
event = event_models.Event(uuidutils.generate_uuid(), 'test',
|
|
datetime.datetime(2012, 7, 2, 13, 53, 40),
|
|
[], {}).serialize()
|
|
with mock.patch.object(self.dispatcher.event_conn,
|
|
'record_events') as record_events:
|
|
self.dispatcher.record_events(event)
|
|
self.assertEqual(1, len(record_events.call_args_list[0][0][0]))
|