blob: c07e98c0121eb748294d64ff50170c78f7aad479 [file] [log] [blame]
Marc Koderer173fc062015-08-27 14:01:42 +02001# Copyright (c) 2015 Deutsche Telekom AG
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest.test_discover import plugins
Matthew Treinishffad78a2016-04-16 14:39:52 -040017from tempest.tests import base
Marc Koderer173fc062015-08-27 14:01:42 +020018from tempest.tests import fake_tempest_plugin as fake_plugin
Marc Koderer173fc062015-08-27 14:01:42 +020019
20
21class TestPluginDiscovery(base.TestCase):
22 def test_load_tests_with_one_plugin(self):
23 # we can't mock stevedore since it's a singleton and already executed
24 # during test discovery. So basically this test covers the plugin loop
25 # and the abstract plugin interface.
26 manager = plugins.TempestTestPluginManager()
27 fake_obj = fake_plugin.FakeStevedoreObj()
28 manager.ext_plugins = [fake_obj]
29 result = manager.get_plugin_load_tests_tuple()
30
31 self.assertEqual(fake_plugin.FakePlugin.expected_load_test,
32 result[fake_obj.name])
33
34 def test_load_tests_with_two_plugins(self):
35 manager = plugins.TempestTestPluginManager()
36 obj1 = fake_plugin.FakeStevedoreObj('fake01')
37 obj2 = fake_plugin.FakeStevedoreObj('fake02')
38 manager.ext_plugins = [obj1, obj2]
39 result = manager.get_plugin_load_tests_tuple()
40
41 self.assertEqual(fake_plugin.FakePlugin.expected_load_test,
42 result['fake01'])
43 self.assertEqual(fake_plugin.FakePlugin.expected_load_test,
44 result['fake02'])