Ejemplo n.º 1
0
    def test_env_parallel(self):
        main.parse_and_validate_commands(
            ['server', 'install', "local_path", "--serial"])
        self.assertEqual(env.parallel, False)

        main.parse_and_validate_commands(['server', 'install', "local_path"])
        self.assertEqual(env.parallel, True)
Ejemplo n.º 2
0
 def test_cli_overrides_config(self, unused_mock_load):
     main.parse_and_validate_commands(
         args=['-H', 'master,slave1', '-u', 'other_user', '--port', '2179',
               'server', 'uninstall'])
     self.assertEqual(env.hosts, ['master', 'slave1'])
     self.assertEqual(env.user, 'other_user')
     self.assertEqual(env.port, '2179')
Ejemplo n.º 3
0
    def test_env_parallel(self):
        main.parse_and_validate_commands(['server', 'install',
                                          "local_path", "--serial"])
        self.assertEqual(env.parallel, False)

        main.parse_and_validate_commands(['server', 'install',
                                          "local_path"])
        self.assertEqual(env.parallel, True)
Ejemplo n.º 4
0
 def test_cli_overrides_config(self, unused_mock_load):
     main.parse_and_validate_commands(args=[
         '-H', 'master,slave1', '-u', 'other_user', '--port', '2179',
         'server', 'uninstall'
     ])
     self.assertEqual(env.hosts, ['master', 'slave1'])
     self.assertEqual(env.user, 'other_user')
     self.assertEqual(env.port, '2179')
Ejemplo n.º 5
0
 def test_set_vars(self):
     main.parse_and_validate_commands(
         ['--set', 'skip_bad_hosts,shell=,hosts=m\,slave1\,slave2,'
                   'skip_unknown_tasks=True,use_shell=False',
          'server', 'install', "local_path"])
     self.assertEqual(env.skip_bad_hosts, True)
     self.assertEqual(env.shell, '')
     self.assertEqual(env.hosts, ['m', 'slave1', 'slave2'])
     self.assertEqual(env.use_shell, False)
     self.assertEqual(env.skip_unknown_tasks, True)
Ejemplo n.º 6
0
 def test_unchanged_hosts(self, unused_mock_load):
     """
     Possible alternate name for the test: test_does_my_magic_work
     """
     main.parse_and_validate_commands(args=['server', 'uninstall'])
     self.assertDefaultHosts()
     self.assertDefaultRoledefs()
     self.assertEqual(env.port, 1234)
     self.assertEqual(env.user, 'user')
     self.assertNotIn('conf_hosts', env)
Ejemplo n.º 7
0
 def test_unchanged_hosts(self, unused_mock_load):
     """
     Possible alternate name for the test: test_does_my_magic_work
     """
     main.parse_and_validate_commands(
         args=['server', 'uninstall'])
     self.assertDefaultHosts()
     self.assertDefaultRoledefs()
     self.assertEqual(env.port, 1234)
     self.assertEqual(env.user, 'user')
     self.assertNotIn('conf_hosts', env)
Ejemplo n.º 8
0
 def test_set_vars(self):
     main.parse_and_validate_commands([
         '--set', 'skip_bad_hosts,shell=,hosts=m\,slave1\,slave2,'
         'skip_unknown_tasks=True,use_shell=False', 'server', 'install',
         "local_path"
     ])
     self.assertEqual(env.skip_bad_hosts, True)
     self.assertEqual(env.shell, '')
     self.assertEqual(env.hosts, ['m', 'slave1', 'slave2'])
     self.assertEqual(env.use_shell, False)
     self.assertEqual(env.skip_unknown_tasks, True)
Ejemplo n.º 9
0
    def _run_command_compare_to_string(self, command, exit_status,
                                       stdout_text=None, stderr_text=None):
        """
            Compares stdout from the CLI to the given string
        """
        try:
            main.parse_and_validate_commands(command)
        except SystemExit as e:
            self.assertEqual(e.code, exit_status)

        if stdout_text is not None:
            self.assertEqual(stdout_text, self.test_stdout.getvalue())

        if stderr_text is not None:
            self.assertEqual(stderr_text, self.test_stderr.getvalue())
Ejemplo n.º 10
0
    def _run_command_compare_to_string(self,
                                       command,
                                       exit_status,
                                       stdout_text=None,
                                       stderr_text=None):
        """
            Compares stdout from the CLI to the given string
        """
        try:
            main.parse_and_validate_commands(command)
        except SystemExit as e:
            self.assertEqual(e.code, exit_status)

        if stdout_text is not None:
            self.assertEqual(stdout_text, self.test_stdout.getvalue())

        if stderr_text is not None:
            self.assertEqual(stderr_text, self.test_stderr.getvalue())
Ejemplo n.º 11
0
 def test_initial_password(self, pass_mock):
     try:
         main.parse_and_validate_commands(['-I', 'topology', 'show'])
     except SystemExit as e:
         self.assertEqual(0, e.code)
     pass_mock.assert_called_once_with('Initial value for env.password: ')
Ejemplo n.º 12
0
 def test_argument_parsing_with_arguments(self):
     commands = main.parse_and_validate_commands(["topology", "show", "f"])
     self.assertEqual(commands[0][0], "topology.show")
     self.assertEqual(commands[0][1], ["f"])
Ejemplo n.º 13
0
 def test_skip_bad_hosts(self):
     main.parse_and_validate_commands(['server', 'install', "local_path"])
     self.assertEqual(env.skip_bad_hosts, True)
Ejemplo n.º 14
0
 def test_specific_hosts_long_option(self, unused_mock_load):
     main.parse_and_validate_commands(
         args=['--hosts', 'master', 'server', 'uninstall'])
     self.assertEqual(env.hosts, ['master'])
     self.assertNotIn('cli_hosts', env)
Ejemplo n.º 15
0
 def test_generic_set_hosts(self, unused_mock_load):
     main.parse_and_validate_commands(
         args=['--set', 'hosts=master\,slave2', 'server', 'uninstall'])
     self.assertEqual(env.hosts, ['master', 'slave2'])
     self.assertNotIn('env_settings', env)
Ejemplo n.º 16
0
 def test_argument_parsing_with_arguments(self):
     commands = main.parse_and_validate_commands(["topology", "show", "f"])
     self.assertEqual(commands[0][0], "topology.show")
     self.assertEqual(commands[0][1], ["f"])
Ejemplo n.º 17
0
 def test_skip_bad_hosts(self):
     main.parse_and_validate_commands(['server', 'install',
                                       "local_path"])
     self.assertEqual(env.skip_bad_hosts, True)
Ejemplo n.º 18
0
 def test_default_topology(self, unused_mock_load):
     main.parse_and_validate_commands(args=['server', 'uninstall'])
     self.assertEqual(env.port, 22)
     self.assertEqual(env.user, 'root')
     self.assertEqual(env.hosts, ['localhost'])
Ejemplo n.º 19
0
 def test_default_topology(self, unused_mock_load):
     main.parse_and_validate_commands(args=['server', 'uninstall'])
     self.assertEqual(env.port, 22)
     self.assertEqual(env.user, 'root')
     self.assertEqual(env.hosts, ['localhost'])
Ejemplo n.º 20
0
 def test_specific_overrides_generic(self, unused_mock_load):
     main.parse_and_validate_commands(args=[
         '-H', 'master,slave1', '--set', 'hosts=master\,slave2', 'server',
         'uninstall'
     ])
     self.assertEqual(env.hosts, ['master', 'slave1'])
Ejemplo n.º 21
0
 def test_generic_set_hosts(self, unused_mock_load):
     main.parse_and_validate_commands(
         args=['--set', 'hosts=master\,slave2', 'server', 'uninstall'])
     self.assertEqual(env.hosts, ['master', 'slave2'])
     self.assertNotIn('env_settings', env)
Ejemplo n.º 22
0
 def test_specific_hosts_short_option(self, unused_mock_load):
     main.parse_and_validate_commands(
         args=['-H', 'master,slave2', 'server', 'uninstall'])
     self.assertEqual(env.hosts, ['master', 'slave2'])
Ejemplo n.º 23
0
 def test_specific_hosts_short_option(self, unused_mock_load):
     main.parse_and_validate_commands(
         args=['-H', 'master,slave2', 'server', 'uninstall'])
     self.assertEqual(env.hosts, ['master', 'slave2'])
Ejemplo n.º 24
0
 def test_initial_password(self, pass_mock):
     try:
         main.parse_and_validate_commands(['-I', 'topology', 'show'])
     except SystemExit as e:
         self.assertEqual(0, e.code)
     pass_mock.assert_called_once_with('Initial value for env.password: ')
Ejemplo n.º 25
0
 def test_specific_hosts_long_option(self, unused_mock_load):
     main.parse_and_validate_commands(
         args=['--hosts', 'master', 'server', 'uninstall'])
     self.assertEqual(env.hosts, ['master'])
     self.assertNotIn('cli_hosts', env)
Ejemplo n.º 26
0
 def test_specific_overrides_generic(self, unused_mock_load):
     main.parse_and_validate_commands(
         args=['-H', 'master,slave1', '--set', 'hosts=master\,slave2',
               'server', 'uninstall'])
     self.assertEqual(env.hosts, ['master', 'slave1'])
Ejemplo n.º 27
0
 def test_argument_parsing_with_valid_command(self, unused_load_mock):
     commands = main.parse_and_validate_commands(["topology", "show"])
     self.assertEqual(commands[0][0], "topology.show")
Ejemplo n.º 28
0
 def test_argument_parsing_with_valid_command(self, unused_load_mock):
     commands = main.parse_and_validate_commands(["topology", "show"])
     self.assertEqual(commands[0][0], "topology.show")