def test_create_common_parser_passed_usage_string(self, mock_func):
     mock_parser = Mock()
     mock_parser.parse_args.return_value = lambda: Mock(), []
     mock_func.return_value = mock_parser
     archivewal_parse_args(args=[])
     kwargs = mock_func.call_args_list[0][1]
     expected_usage_suffix = '[options] <path_to_wal_file_to_archive>'
     self.assertTrue(kwargs['usage'].endswith(expected_usage_suffix))
Пример #2
0
def archivewal_handle_args():
    parser, options, args = archivewal_parse_args()

    try:
        archivewal_validate_options_and_args(options, args)
    except Exception, e:
        stdout.write(str(e) + '\n')
        parser.print_help()
        raise e
 def setUp(self):
     self.tempdir = TempDirectory()
     self.config_dict = {
         'General': {
             'pgsql_data_directory': self.tempdir.path,
         },
     }
     self.config_file = os.path.join(self.tempdir.path, 'config_file')
     write_config_to_filename(self.config_dict, self.config_file)
     parser, self.options, self.args = archivewal_parse_args(['-c',
         self.config_file])
 def test_archivewal_parse_args_returns_args(self):
     item1, item2, args = archivewal_parse_args(args=['walfilename'])
     self.assertEqual(type(args), type([]))
 def test_archivewal_parse_args_returns_options(self):
     item1, options, item3 = archivewal_parse_args(args=['walfilename'])
     self.assertTrue(isinstance(options, object))
 def test_archivewal_parse_args_returns_parser(self):
     parser, item2, item3 = archivewal_parse_args(args=['walfilename'])
     self.assertTrue(isinstance(parser, OptionParser))
 def test_archivewal_parse_args_returns_three_items(self):
     item1, item2, item3 = archivewal_parse_args(args=['walfilename'])
     self.assertNotEqual(type(item1), type(None))
     self.assertNotEqual(type(item2), type(None))
     self.assertNotEqual(type(item3), type(None))
 def test_create_common_parser_used(self, mock_func):
     mock_parser = Mock()
     mock_parser.parse_args.return_value = lambda: Mock(), []
     mock_func.return_value = mock_parser
     archivewal_parse_args(args=[])
     self.assertTrue(mock_func.called)