File: test_cli_plugin.py

package info (click to toggle)
rally 5.0.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,364 kB
  • sloc: python: 42,541; javascript: 487; sh: 198; makefile: 192; xml: 43
file content (76 lines) | stat: -rw-r--r-- 2,799 bytes parent folder | download | duplicates (2)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright 2015: Mirantis Inc.
# 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 unittest

from tests.functional import utils


class PluginTestCase(unittest.TestCase):

    def test_show_one(self):
        rally = utils.Rally()
        result = rally("plugin show Dummy.dummy")
        self.assertIn("NAME", result)
        self.assertIn("PLATFORM", result)
        self.assertIn("Dummy.dummy", result)
        self.assertIn("MODULE", result)

    def test_show_multiple(self):
        rally = utils.Rally()
        with self.assertRaises(utils.RallyCliError) as e_ctx:
            rally("plugin show Dummy")
        result = e_ctx.exception
        self.assertIn("Multiple plugins found:", result.output)
        self.assertIn("Dummy.dummy", result.output)
        self.assertIn("Dummy.dummy_exception", result.output)
        self.assertIn("Dummy.dummy_random_fail_in_atomic", result.output)

    def test_show_not_found(self):
        rally = utils.Rally()
        name = "Dummy666666"
        with self.assertRaises(utils.RallyCliError) as e_ctx:
            rally(f"plugin show {name}")
        self.assertIn("Plugin %s not found" % name, e_ctx.exception.output)

    def test_show_not_found_in_specific_platform(self):
        rally = utils.Rally()
        name = "Dummy"
        platform = "non_existing"

        with self.assertRaises(utils.RallyCliError) as e_ctx:
            rally(f"plugin show --name {name} --platform {platform}")

        self.assertIn(
            "Plugin %(name)s@%(platform)s not found"
            % {"name": name, "platform": platform},
            e_ctx.exception.output)

    def test_list(self):
        rally = utils.Rally()
        result = rally("plugin list Dummy")
        self.assertIn("Dummy.dummy", result)
        self.assertIn("Dummy.dummy_exception", result)
        self.assertIn("Dummy.dummy_random_fail_in_atomic", result)

    def test_list_not_found_platform(self):
        rally = utils.Rally()
        result = rally("plugin list --platform some")
        self.assertIn("Platform some not found", result)

    def test_list_not_found_name(self):
        rally = utils.Rally()
        result = rally("plugin list Dummy2222")
        self.assertIn("Plugin Dummy2222 not found", result)