
In order to migrate the code base to the "OpenStack way": * Replace ConfigParser by oslo.config * Replace logging by oslo.log * Use testtools as base class for unit tests * Add tox -e genconfig to generate config file * Start to organize the file structure like other projects * Define 2 cli entry points almanach-collector and almanach-api * The docker-compose.yml is now used to run integration-tests * Integration tests will be moved to tempest in the future * Docker configs should be deprecated and moved to Kolla Change-Id: I89a89a92c7bdb3125cc568323db0f9488e1380db
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
# Copyright 2016 Internap.
|
|
#
|
|
# 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.
|
|
|
|
from flexmock import flexmock
|
|
|
|
from almanach.collector.handlers import instance_handler
|
|
from integration_tests.builders import messages
|
|
from tests import base
|
|
|
|
|
|
class InstanceHandlerTest(base.BaseTestCase):
|
|
|
|
def setUp(self):
|
|
super(InstanceHandlerTest, self).setUp()
|
|
|
|
self.controller = flexmock()
|
|
self.retry = flexmock()
|
|
self.instance_bus_adapter = instance_handler.InstanceHandler(self.controller)
|
|
|
|
def test_deleted_instance(self):
|
|
notification = messages.get_instance_delete_end_sample()
|
|
|
|
self.controller.should_receive('delete_instance').once()
|
|
self.instance_bus_adapter.on_instance_deleted(notification)
|
|
|
|
def test_instance_resized(self):
|
|
notification = messages.get_instance_rebuild_end_sample()
|
|
|
|
self.controller.should_receive('resize_instance').once()
|
|
self.instance_bus_adapter.on_instance_resized(notification)
|
|
|
|
def test_instance_rebuild(self):
|
|
notification = messages.get_instance_rebuild_end_sample()
|
|
self.controller \
|
|
.should_receive("rebuild_instance") \
|
|
.once()
|
|
self.instance_bus_adapter.on_instance_rebuilt(notification)
|