Files
deb-python-oslo.service/tests/unit/test_threadgroup.py
Victor Sergeyev 17aa866086 Use oslotest instead of common test module
Module openstack.common.test is obsolete, so we should use
oslotest library instead of it.
Modified tests and common database code, new requirement added.

Change-Id: I853e548f11a4c3785eaf75124510a6d789536634
2014-04-15 17:53:05 +03:00

47 lines
1.5 KiB
Python

# Copyright (c) 2012 Rackspace Hosting
# All Rights Reserved.
#
# 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.
"""
Unit Tests for thread groups
"""
from oslotest import base as test_base
from openstack.common import threadgroup
class ThreadGroupTestCase(test_base.BaseTestCase):
"""Test cases for thread group."""
def setUp(self):
super(ThreadGroupTestCase, self).setUp()
self.tg = threadgroup.ThreadGroup()
self.addCleanup(self.tg.stop)
def test_add_dynamic_timer(self):
def foo(*args, **kwargs):
pass
initial_delay = 1
periodic_interval_max = 2
self.tg.add_dynamic_timer(foo, initial_delay, periodic_interval_max,
'arg', kwarg='kwarg')
self.assertEqual(1, len(self.tg.timers))
timer = self.tg.timers[0]
self.assertTrue(timer._running)
self.assertEqual(('arg',), timer.args)
self.assertEqual({'kwarg': 'kwarg'}, timer.kw)