def test_stdout_capture(self): stdout = sys.stdout messages = ["abcdef", "defgaga"] with utils.StdOutCapture() as out: for msg in messages: print(msg) self.assertEqual(messages, out.getvalue().rstrip("\n").split("\n")) self.assertEqual(sys.stdout, stdout)
def test_show(self): with utils.StdOutCapture() as out: plugin_cmd.PluginCommands().show(None, "p1", "p1_ns") output = out.getvalue() self.assertIn("NAME\n\tp1", output) self.assertIn("PLATFORM\n\tp1_ns", output) self.assertIn("cli.commands.test_plugin", output) self.assertIn("DESCRIPTION\n\tDescription of T1", output) self.assertIn("PARAMETERS", output)
def test_show_many(self, mock_plugin_commands__print_plugins_list): with utils.StdOutCapture() as out: with mock.patch("rally.cli.commands.plugin.plugin.Plugin." "get_all") as mock_plugin_get_all: mock_plugin_get_all.return_value = [self.Plugin2, self.Plugin3] plugin_cmd.PluginCommands().show(None, "p", "p2_ns") self.assertEqual("Multiple plugins found:\n", out.getvalue()) mock_plugin_get_all.assert_called_once_with(platform="p2_ns") mock_plugin_commands__print_plugins_list.assert_called_once_with( [self.Plugin2, self.Plugin3])
def test_list_not_found(self, name, platform, text): with utils.StdOutCapture() as out: plugin_cmd.PluginCommands().list(None, name, platform) self.assertEqual(text, out.getvalue())
def test_show_not_found(self, name, namespace, text): with utils.StdOutCapture() as out: plugin_cmd.PluginCommands().show(None, name, namespace) self.assertEqual(text, out.getvalue())
def test_list_not_found(self, name, namespace, text): with utils.StdOutCapture() as out: plugin_cmd.PluginCommands().list(name, namespace) self.assertEqual(out.getvalue(), text)