コード例 #1
0
    def test_clusters_location(self, fake_stderr):
        """parse_args rasies SystemExit  if --location isn't supplied with --clusters"""
        cli_args = [
            '--clusters', 'myCluster', '--username', 'pat', '--password', 'a'
        ]

        with self.assertRaises(SystemExit):
            iiqtools_cluster_backup.parse_args(cli_args)
コード例 #2
0
    def test_inspect_bad_name(self, fake_isfile, fake_is_zipfile):
        """parse_args - The ``--inspect`` argument raises SystemExit if the value is not correctly named"""
        fake_isfile.return_value = True
        fake_is_zipfile.return_value = True
        cli_args = ['--inspect', 'insightiq_export_123.zip']

        with self.assertRaises(SystemExit):
            iiqtools_cluster_backup.parse_args(cli_args)
コード例 #3
0
    def test_password_prompt(self, fake_getpass, fake_stderr):
        """parse_args prompts for password if it's not supplied"""
        cli_args = [
            '--clusters', 'myCluster', '--location', '/foo', '--username',
            'pat'
        ]

        iiqtools_cluster_backup.parse_args(cli_args)

        fake_getpass.assert_called()
コード例 #4
0
    def test_parse_args_namespace(self):
        """parse_args returns argparse.Namespace object"""
        cli_args = ['--show-clusters']

        result = iiqtools_cluster_backup.parse_args(cli_args)

        self.assertTrue(isinstance(result, argparse.Namespace))
コード例 #5
0
    def test_clusters_required(self):
        """parse_args, supplying --clusters requires --location, --username, and --password"""
        cli_args = [
            '--clusters', 'myCluster', '--location', '/foo', '--username',
            'pat', '--password', 'a'
        ]

        result = iiqtools_cluster_backup.parse_args(cli_args)

        self.assertTrue(isinstance(result, argparse.Namespace))
コード例 #6
0
    def test_inspect(self, fake_isfile, fake_is_zipfile):
        """parse_args supports the ``--inspect`` argument"""
        fake_isfile.return_value = True
        fake_is_zipfile.return_value = True
        cli_args = ['--inspect', 'insightiq_export_1234567890.zip']

        result = iiqtools_cluster_backup.parse_args(cli_args)

        expected = 'insightiq_export_1234567890.zip'
        actual = result.inspect

        self.assertEqual(expected, actual)
コード例 #7
0
    def test_all_clusters(self):
        """parse_args support the ``--all-clusters`` argument"""
        cli_args = [
            '--all-clusters', '--location', '/foo', '--username', 'alice',
            '--password', 'a'
        ]

        result = iiqtools_cluster_backup.parse_args(cli_args)

        expected = True
        actual = result.all_clusters

        self.assertEqual(expected, actual)
コード例 #8
0
    def test_many_clusters(self):
        """parse_args accepts a list of clusters as a value for --clusters"""
        cli_args = [
            '--clusters', 'myCluster', 'myOtherCluster', '--location', '/foo',
            '--username', 'pat', '--password', 'a'
        ]

        result = iiqtools_cluster_backup.parse_args(cli_args)

        expected = ['myCluster', 'myOtherCluster']
        actual = result.clusters

        self.assertEqual(expected, actual)
コード例 #9
0
    def test_parse_args_mutex(self, fake_stderr):
        """parse_args, --show-clusters and --clusters is mutually exclusive"""
        cli_args = ['--show-clusters', '--clusters', 'myCluster']

        with self.assertRaises(SystemExit):
            iiqtools_cluster_backup.parse_args(cli_args)