コード例 #1
0
    def test_setup_cmd_parser(self):
        """Test if it parser object is correctly initialized"""

        parser = HyperKittyCommand.setup_cmd_parser()
        self.assertIsInstance(parser, BackendCommandArgumentParser)
        self.assertEqual(parser._backend, HyperKitty)

        args = [
            'http://example.com/archives/list/[email protected]/',
            '--mboxes-path', '/tmp/perceval/', '--tag', 'test', '--from-date',
            '1970-01-01'
        ]

        parsed_args = parser.parse(*args)
        self.assertEqual(parsed_args.url,
                         'http://example.com/archives/list/[email protected]/')
        self.assertEqual(parsed_args.mboxes_path, '/tmp/perceval/')
        self.assertEqual(parsed_args.tag, 'test')
        self.assertEqual(parsed_args.from_date, DEFAULT_DATETIME)
        self.assertTrue(parsed_args.ssl_verify)

        args = [
            'http://example.com/archives/list/[email protected]/',
            '--mboxes-path', '/tmp/perceval/', '--tag', 'test',
            '--no-ssl-verify', '--from-date', '1970-01-01'
        ]

        parsed_args = parser.parse(*args)
        self.assertEqual(parsed_args.url,
                         'http://example.com/archives/list/[email protected]/')
        self.assertEqual(parsed_args.mboxes_path, '/tmp/perceval/')
        self.assertEqual(parsed_args.tag, 'test')
        self.assertEqual(parsed_args.from_date, DEFAULT_DATETIME)
        self.assertFalse(parsed_args.ssl_verify)
コード例 #2
0
    def test_mboxes_path_init(self, mock_expanduser):
        """Test dirpath initialization"""

        mock_expanduser.return_value = os.path.join(self.tmp_path, 'testpath')

        args = ['http://example.com/archives/list/[email protected]/']

        cmd = HyperKittyCommand(*args)
        self.assertEqual(cmd.parsed_args.dirpath,
                         os.path.join(self.tmp_path,
                                      'testpath/http://example.com/archives/list/[email protected]/'))

        args = ['http://example.com/archives/list/[email protected]/',
                '--mboxes-path', '/tmp/perceval/']

        cmd = HyperKittyCommand(*args)
        self.assertEqual(cmd.parsed_args.dirpath, '/tmp/perceval/')
コード例 #3
0
    def test_parsing_on_init(self):
        """Test if the class is initialized"""

        args = ['http://example.com/archives/list/[email protected]/',
                '--mboxes-path', '/tmp/perceval/',
                '--tag', 'test']

        cmd = HyperKittyCommand(*args)
        self.assertEqual(cmd.parsed_args.url, 'http://example.com/archives/list/[email protected]/')
        self.assertEqual(cmd.parsed_args.mboxes_path, '/tmp/perceval/')
        self.assertEqual(cmd.parsed_args.tag, 'test')