def test_dx_parse_option(self): # Test offline and debug command line options defined_options = {'debug':True, 'offline':True} expected_result = dict(self.default_options.items() + defined_options.items()) result = parse_options(['-dx']) err_msg = "Parse Options result [%s] does not equal expected result [%s]" % (result, expected_result) self.assertEqual(result, expected_result, err_msg)
def test_help_parse_option(self): # Test -h system exit command line options defined_options = {'exit':True} expected_result = dict(self.default_options.items() + defined_options.items()) result = parse_options(['-h']) err_msg = "Parse Options result [%s] does not equal expected result [%s]" % (result, expected_result) self.assertEqual(result, expected_result, err_msg)
def test_invalid_parse_option(self): defined_options = {'exit':True, 'error':getopt.GetoptError('option -z not recognized', 'z')} expected_result = dict(self.default_options.items() + defined_options.items()) result = parse_options(['-z']) self.assertIsNone(result['debug'], "debug option is not None") self.assertIsNone(result['offline'], "offline option is not None") self.assertTrue(result['exit'], "exit options is not True") self.assertIsInstance(result['error'], getopt.GetoptError, 'Error not instance of getopt.GetoptError.') self.assertEqual(result['error'].msg, 'option -z not recognized', 'Error msg not equal [%s]' % result['error'].msg)
def test_no_parse_options(self): result = parse_options() err_msg = "Parse Options result [%s] does not equal expected result [%s]" % (result, self.default_options) self.assertEqual(result, self.default_options, err_msg)