How to use the perceval.backend.BackendCommandArgumentParser function in perceval

To help you get started, we’ve selected a few perceval examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chaoss / grimoirelab-perceval / tests / test_backend.py View on Github external
def test_incompatible_date_and_offset(self):
        """Test if date and offset arguments are incompatible"""

        with self.assertRaises(AttributeError):
            _ = BackendCommandArgumentParser(MockedBackendCommand.BACKEND,
                                             from_date=True,
                                             offset=True)
        with self.assertRaises(AttributeError):
            _ = BackendCommandArgumentParser(MockedBackendCommand.BACKEND,
                                             to_date=True,
                                             offset=True)
        with self.assertRaises(AttributeError):
            _ = BackendCommandArgumentParser(MockedBackendCommand.BACKEND,
                                             from_date=True,
                                             to_date=True,
                                             offset=True)
github chaoss / grimoirelab-perceval / tests / test_backend.py View on Github external
def test_parse_auth_args(self):
        """Test if the authtentication arguments are parsed"""

        args = ['-u', 'jsmith', '-p', '1234', '-t', 'abcd']

        parser = BackendCommandArgumentParser(MockedBackendCommand.BACKEND,
                                              basic_auth=True,
                                              token_auth=True)
        parsed_args = parser.parse(*args)

        self.assertIsInstance(parsed_args, argparse.Namespace)
        self.assertEqual(parsed_args.user, 'jsmith')
        self.assertEqual(parsed_args.password, '1234')
        self.assertEqual(parsed_args.api_token, 'abcd')
github chaoss / grimoirelab-perceval / tests / test_backend.py View on Github external
def test_parse_archive_args(self):
        """Test if achiving arguments are parsed"""

        args = ['--archive-path', '/tmp/archive',
                '--fetch-archive',
                '--archived-since', '2016-01-01',
                '--category', 'mocked']

        parser = BackendCommandArgumentParser(MockedBackendCommand.BACKEND,
                                              archive=True)
        parsed_args = parser.parse(*args)

        expected_dt = datetime.datetime(2016, 1, 1, 0, 0,
                                        tzinfo=dateutil.tz.tzutc())

        self.assertIsInstance(parsed_args, argparse.Namespace)
        self.assertEqual(parsed_args.archive_path, '/tmp/archive')
        self.assertEqual(parsed_args.fetch_archive, True)
        self.assertEqual(parsed_args.no_archive, False)
        self.assertEqual(parsed_args.archived_since, expected_dt)
github chaoss / grimoirelab-perceval / tests / test_backend.py View on Github external
def test_incompatible_date_and_offset(self):
        """Test if date and offset arguments are incompatible"""

        with self.assertRaises(AttributeError):
            _ = BackendCommandArgumentParser(MockedBackendCommand.BACKEND,
                                             from_date=True,
                                             offset=True)
        with self.assertRaises(AttributeError):
            _ = BackendCommandArgumentParser(MockedBackendCommand.BACKEND,
                                             to_date=True,
                                             offset=True)
        with self.assertRaises(AttributeError):
            _ = BackendCommandArgumentParser(MockedBackendCommand.BACKEND,
                                             from_date=True,
                                             to_date=True,
                                             offset=True)
github chaoss / grimoirelab-perceval / tests / test_slack.py View on Github external
def test_setup_cmd_parser(self):
        """Test if it parser object is correctly initialized"""

        parser = SlackCommand.setup_cmd_parser()
        self.assertIsInstance(parser, BackendCommandArgumentParser)
        self.assertEqual(parser._backend, Slack)

        args = ['--tag', 'test', '--no-archive',
                '--api-token', 'abcdefgh',
                '--from-date', '1970-01-01',
                '--max-items', '10',
                'C001']

        parsed_args = parser.parse(*args)
        self.assertEqual(parsed_args.channel, 'C001')
        self.assertEqual(parsed_args.tag, 'test')
        self.assertEqual(parsed_args.from_date, DEFAULT_DATETIME)
        self.assertEqual(parsed_args.no_archive, True)
        self.assertEqual(parsed_args.api_token, 'abcdefgh')
        self.assertEqual(parsed_args.max_items, 10)
github chaoss / grimoirelab-perceval / tests / test_googlehits.py View on Github external
def test_setup_cmd_parser(self):
        """Test if it parser object is correctly initialized"""

        parser = GoogleHitsCommand.setup_cmd_parser()
        self.assertIsInstance(parser, BackendCommandArgumentParser)
        self.assertEqual(parser._backend, GoogleHits)
        args = ['', '--no-archive']

        parsed_args = parser.parse(*args)
        self.assertEqual(parsed_args.no_archive, True)
        self.assertEqual(parsed_args.keywords, [''])
        self.assertEqual(parsed_args.max_retries, MAX_RETRIES)
        self.assertEqual(parsed_args.sleep_time, DEFAULT_SLEEP_TIME)

        args = ['bitergia', '--no-archive']

        parsed_args = parser.parse(*args)
        self.assertEqual(parsed_args.no_archive, True)
        self.assertEqual(parsed_args.keywords, ['bitergia'])
        self.assertEqual(parsed_args.max_retries, MAX_RETRIES)
        self.assertEqual(parsed_args.sleep_time, DEFAULT_SLEEP_TIME)
github chaoss / grimoirelab-perceval / tests / test_dockerhub.py View on Github external
def test_setup_cmd_parser(self):
        """Test if it parser object is correctly initialized"""

        parser = DockerHubCommand.setup_cmd_parser()
        self.assertIsInstance(parser, BackendCommandArgumentParser)
        self.assertEqual(parser._backend, DockerHub)

        args = ['grimoirelab', 'perceval', '--no-archive']

        parsed_args = parser.parse(*args)
        self.assertEqual(parsed_args.no_archive, True)
        self.assertEqual(parsed_args.owner, 'grimoirelab')
        self.assertEqual(parsed_args.repository, 'perceval')
github chaoss / grimoirelab-perceval / perceval / backends / core / gmane.py View on Github external
def setup_cmd_parser():
        """Returns the Gmane argument parser."""

        aliases = {
            'mailing_list_address': 'mailing_list'
        }
        parser = BackendCommandArgumentParser(offset=True,
                                              cache=True,
                                              aliases=aliases)

        # Optional arguments
        group = parser.parser.add_argument_group('Gmane arguments')
        group.add_argument('--mboxes-path', dest='mboxes_path',
                           help="Path where mbox files will be stored")

        # Required arguments
        parser.parser.add_argument('mailing_list',
                                   help='Mailing list address on Gmane')

        return parser
github chaoss / grimoirelab-perceval / perceval / backends / core / launchpad.py View on Github external
def setup_cmd_parser(cls):
        """Returns the Launchpad argument parser."""

        parser = BackendCommandArgumentParser(cls.BACKEND,
                                              from_date=True,
                                              archive=True,
                                              token_auth=False)

        # Optional arguments
        group = parser.parser.add_argument_group('Launchpad arguments')
        group.add_argument('--items-per-page', dest='items_per_page',
                           help="Items per page")
        group.add_argument('--sleep-time', dest='sleep_time',
                           help="Sleep time in case of connection lost")

        # Required arguments
        parser.parser.add_argument('distribution',
                                   help="Launchpad distribution")

        return parser
github chaoss / grimoirelab-perceval / perceval / backends / core / confluence.py View on Github external
def setup_cmd_parser(cls):
        """Returns the Bugzilla argument parser."""

        parser = BackendCommandArgumentParser(cls.BACKEND,
                                              from_date=True,
                                              archive=True)

        # Required arguments
        parser.parser.add_argument('url',
                                   help="URL of the Confluence server")

        return parser