Exemplo n.º 1
0
 def test_parse_arguments__invalid(self):
     parser = scripts_utils.create_legacy_arguments_parser(
         "Test script", run)
     with test_utils.capture('stdout', 'stderr') as (stdout, stderr):
         with self.assertRaises(SystemExit):
             scripts_utils.run_import_script_and_ingest(
                 parser,
                 argv=[
                     path.join(self.tempdir, 'test.import'),
                     path.join(self.tempdir, 'Non-existent'),
                 ])
Exemplo n.º 2
0
 def test_parse_arguments__multiple(self):
     parser = scripts_utils.create_legacy_arguments_parser(
         "Test script", run)
     with test_utils.capture('stdout', 'stderr') as (stdout, stderr):
         args = parser.parse_args(args=[
             path.join(self.tempdir, 'test.import'),
             path.join(self.tempdir, 'Downloads/ofxdownload.ofx'),  # File
             path.join(self.tempdir, 'Downloads/Subdir'),  # Directory
         ])
     self.assertIsInstance(args, argparse.Namespace)
     self.assertEqual(path.join(self.tempdir, 'test.import'), args.config)
     self.assertEqual(2, len(args.downloads))
Exemplo n.º 3
0
 def test_parse_arguments__sufficient(self):
     parser = scripts_utils.create_legacy_arguments_parser(
         "Test script", run)
     with test_utils.capture('stdout', 'stderr') as (stdout, stderr):
         args = parser.parse_args(args=[
             path.join(self.tempdir, 'test.import'),
             path.join(self.tempdir, 'Downloads'),
         ])
     self.assertIsInstance(args, argparse.Namespace)
     self.assertEqual(path.join(self.tempdir, 'test.import'), args.config)
     self.assertEqual([path.join(self.tempdir, 'Downloads')],
                      args.downloads)
Exemplo n.º 4
0
    def test_parse_arguments__insufficient(self):
        # Test with insufficient arguments.
        parser = scripts_utils.create_legacy_arguments_parser(
            "Test script", run)
        with test_utils.capture('stdout', 'stderr') as (stdout, stderr):
            with self.assertRaises(SystemExit):
                parser.parse_args(args=[])

        with test_utils.capture('stdout', 'stderr') as (stdout, stderr):
            with self.assertRaises(SystemExit):
                parser.parse_args(
                    args=[path.join(self.tempdir, 'test.import')])