Exemplo n.º 1
0
    def test_parse_args_lack_opts(self, mock_usage):
        # Verify if it will exit with prompting usage if not
        # pass in all required opts.
        argv = ['bootstrap', '-i', '169.254.0.1']

        bootstrap._parse_args(argv)

        mock_usage.assert_called_with()
Exemplo n.º 2
0
    def test_parse_args_invalid_opts(self, mock_usage):
        # Verify if it will exit with prompting usage if pass in
        # wrong opts.
        argv = ['bootstrap', '-v', 'invalid_opt']

        bootstrap._parse_args(argv)

        mock_usage.assert_called_with()
Exemplo n.º 3
0
    def test_parse_args_no_valid_option(self, mock_usage):
        # Verify if it will exit with prompting usage if no
        # valid options passed except the command name.
        argv = ['bootstrap']

        bootstrap._parse_args(argv)

        mock_usage.assert_called_with()
Exemplo n.º 4
0
    def test_parse_args(self):
        argv = ['bootstrap', '-i', '169.254.0.1', '-u', 'root', '-p', 'passwd']

        return_opts = bootstrap._parse_args(argv)

        expect_opts = {'himn-ip': '169.254.0.1',
                       'passwd': 'passwd',
                       'user-name': 'root'}
        self.assertEqual(expect_opts, return_opts)
Exemplo n.º 5
0
    def test_parse_args_with_filepath(self):
        argv = ['bootstrap', '-i', '169.254.0.1', '-u', 'root', '-p', 'passwd',
                '-f', '/path/to/file']

        return_opts = bootstrap._parse_args(argv)

        expect_opts = {'himn-ip': '169.254.0.1',
                       'passwd': 'passwd',
                       'user-name': 'root',
                       'xenapi-facts-file': '/path/to/file'}
        self.assertEqual(expect_opts, return_opts)