File: test_platform.py

package info (click to toggle)
rally 5.0.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,368 kB
  • sloc: python: 42,541; javascript: 487; sh: 198; makefile: 192; xml: 43
file content (62 lines) | stat: -rw-r--r-- 2,212 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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.

import jsonschema

from rally.env import env_mgr
from rally.env import platform

from tests.unit import test


class PlatformBaseTestCase(test.TestCase):

    def _check_schema(self, schema, obj):
        jsonschema.validate(obj, schema)

    def _check_health_schema(self, obj):
        self._check_schema(env_mgr.EnvManager._HEALTH_FORMAT, obj)

    def _check_cleanup_schema(self, obj):
        self._check_schema(env_mgr.EnvManager._CLEANUP_FORMAT, obj)

    def _check_info_schema(self, obj):
        self._check_schema(env_mgr.EnvManager._INFO_FORMAT, obj)


class PlatformTestCase(test.TestCase):

    def test_plugin_configure_and_methods(self):

        @platform.configure(name="existing", platform="foo")
        class FooPlugin(platform.Platform):
            pass

        self.addCleanup(FooPlugin.unregister)

        f = FooPlugin("spec", "uuid", "plugin_data", "platform_data", "status")
        self.assertEqual(f.uuid, "uuid")
        self.assertEqual(f.spec, "spec")
        self.assertEqual(f.plugin_data, "plugin_data")
        self.assertEqual(f.platform_data, "platform_data")
        self.assertEqual(f.status, "status")

        self.assertRaises(NotImplementedError, f.create)
        self.assertRaises(NotImplementedError, f.destroy)
        self.assertRaises(NotImplementedError, f.update, "new_spec")
        self.assertRaises(NotImplementedError, f.cleanup)
        self.assertRaises(NotImplementedError,
                          f.cleanup, task_uuid="task_uuid")
        self.assertRaises(NotImplementedError, f.check_health)
        self.assertRaises(NotImplementedError, f.info)