def test_with_upgrade_with_no_site_dir(self):
        """Testing rb-site parse_options with upgrade and no site directory"""
        expected_message = \
            "You'll need to provide a site directory to run this command."

        with self.assertRaisesMessage(MissingSiteError, expected_message):
            parse_options(['upgrade'])
    def test_with_invalid_command(self):
        """Testing rb-site parse_options with invalid command"""
        with self.assertRaises(SystemExit):
            parse_options(['frob', self.sitedir1])

        output = sys.stderr.getvalue()
        self.assertTrue(output.startswith('usage: rb-site [-h]'))
        self.assertIn('rb-site: error: invalid choice:', output)
    def test_with_help_as_command_option(self):
        """Testing rb-site parse_options with --help as command option"""
        with self.assertRaises(SystemExit):
            parse_options(['install', self.sitedir1, '--help'])

        help_text = sys.stdout.getvalue()
        self.assertTrue(help_text.startswith('usage: rb-site install'))
        self.assertIn('This will guide you through installing', help_text)
    def test_with_help_first(self):
        """Testing rb-site parse_options with --help as first option"""
        with self.assertRaises(SystemExit):
            parse_options(['--help', 'install', self.sitedir1])

        help_text = sys.stdout.getvalue()
        self.assertTrue(help_text.startswith('usage: rb-site [-h]'))
        self.assertIn('rb-site helps create, upgrade', help_text)
    def test_with_help_only(self):
        """Testing rb-site parse_options with --help only"""
        with self.assertRaises(SystemExit):
            parse_options(['--help'])

        help_text = sys.stdout.getvalue()
        self.assertTrue(help_text.startswith('usage: rb-site [-h]'))
        self.assertIn('rb-site helps create, upgrade', help_text)
    def test_with_manage_with_invalid_site_dir(self):
        """Testing rb-site parse_options with manage with invalid site
        directory
        """
        expected_error = ('The site directory "%s" does not exist.' %
                          self.invalid_sitedir)

        with self.assertRaisesMessage(MissingSiteError, expected_error):
            parse_options(['manage', self.invalid_sitedir, 'my-command'])
    def test_with_upgrade_with_all_sites_not_stored(self):
        """Testing rb-site parse_options with upgrade and --all-sites but no
        stored site
        """
        expected_message = \
            "No Review Board sites were listed in %s" % SITELIST_FILE_UNIX

        with self.assertRaisesMessage(MissingSiteError, expected_message):
            parse_options(['upgrade', '--all-sites'])
Exemplo n.º 8
0
    def test_with_manage_no_command(self):
        """Testing rb-site parse_options with manage and no command"""
        with self.assertRaises(SystemExit):
            parse_options(['manage', self.sitedir1])

        output = sys.stderr.getvalue()
        self.assertTrue(output.startswith('usage: rb-site manage [-h]'))

        self.assertIn(
            'rb-site manage: error: the following arguments are '
            'required: <command> <args>', output)
    def test_with_upgrade(self):
        """Testing rb-site parse_options with upgrade"""
        result = parse_options(['upgrade', self.sitedir1])

        self.assertIsNotNone(result)
        self.assertIsInstance(result['command'], UpgradeCommand)
        self.assertEqual(result['site_paths'], [self.sitedir1])
    def test_with_no_options(self):
        """Testing rb-site parse_options with no options"""
        self.assertIsNone(parse_options([]))

        help_text = sys.stdout.getvalue()
        self.assertTrue(help_text.startswith('usage: rb-site [-h]'))
        self.assertIn('rb-site helps create, upgrade', help_text)
    def test_with_manage_with_command(self):
        """Testing rb-site parse_options with manage and command"""
        result = parse_options(['manage', self.sitedir1, 'my-command'])

        self.assertIsNotNone(result)
        self.assertIsInstance(result['command'], ManageCommand)
        self.assertEqual(result['site_paths'], [self.sitedir1])
        self.assertEqual(result['options'].manage_command, ['my-command'])
    def test_with_install(self):
        """Testing rb-site parse_options with install"""
        sitedir = os.path.join(self.sitedir1, 'newdir')

        result = parse_options(['install', sitedir])

        self.assertIsNotNone(result)
        self.assertIsInstance(result['command'], InstallCommand)
        self.assertEqual(result['site_paths'], [sitedir])
    def test_with_upgrade_with_all_sites_and_stored(self):
        """Testing rb-site parse_options with upgrade and --all-sites and
        sites stored
        """
        result = parse_options(
            ['upgrade', '--all-sites', '--sitelist', self.sitelist_filename])

        self.assertIsNotNone(result)
        self.assertIsInstance(result['command'], UpgradeCommand)
        self.assertEqual(result['site_paths'], [self.sitedir1, self.sitedir2])