def test_bool_arg(self): sys.argv.append(TEST_ARGV["name"]) arg_name = TEST_ARGV["name"] arg_type = bool argv_store = Argv(arg_name, type=arg_type) result = argv_store.get() self.assertEqual(result, TEST_ARGV_BOOL_RESULT) self.assertIsInstance(result, dict)
def test_args_default_params(self): sys.argv.append(TEST_ARGV["name"]) sys.argv.append(TEST_ARGV_RESULT[TEST_ARGV["name"].replace("--", "")]) arg_name = TEST_ARGV["name"] argv_store = Argv(arg_name) result = argv_store.get() self.assertEqual(result, TEST_ARGV_RESULT) self.assertIsInstance(result, dict)
def test_dash_in_name(self): sys.argv.append(TEST_DASH_IN_KEY) arg_name = TEST_DASH_IN_KEY arg_type = bool argv_store = Argv(arg_name, type=arg_type) result = argv_store.get() self.assertEqual(result, TEST_DASH_IN_KEY_RESULT) self.assertIsInstance(result, dict)
def test_args_optional_params_without_short(self): sys.argv.append(TEST_ARGV["name"]) sys.argv.append(TEST_ARGV_RESULT[TEST_ARGV["name"].replace("--", "")]) arg_name = TEST_ARGV["name"] arg_type = TEST_ARGV["type"] arg_help = TEST_ARGV["help"] argv_store = Argv(arg_name, type=arg_type, help=arg_help) result = argv_store.get() self.assertEqual(result, TEST_ARGV_RESULT) self.assertIsInstance(result, dict)
def test_literal_dict(self): sys.argv.append(TEST_LITERAL_DICT['name']) sys.argv.append(TEST_LITERAL_DICT['value']) argv_store = Argv(TEST_LITERAL_DICT['name'], type=type(TEST_LITERAL_DICT['result'])) result = argv_store.get() self.assertEqual( result, { str(TEST_LITERAL_DICT['name']).replace('--', ''): TEST_LITERAL_DICT['result'] })
def test_args_optional_params_without_short(self): sys.argv.append(TEST_ARGV['name']) sys.argv.append(TEST_ARGV_RESULT[TEST_ARGV['name'].replace('--', '')]) arg_name = TEST_ARGV['name'] arg_type = TEST_ARGV['type'] arg_help = TEST_ARGV['help'] argv_store = Argv(arg_name, type=arg_type, help=arg_help) result = argv_store.get() self.assertEqual(result, TEST_ARGV_RESULT) self.assertIsInstance(result, dict)
def test_repeated_list(self): for value in TEST_LITERAL_LIST['result']: sys.argv.append(TEST_LITERAL_LIST['name']) sys.argv.append(value) argv_store = Argv(TEST_LITERAL_LIST['name'], type='repeated_list') result = argv_store.get() self.assertEqual( result, { str(TEST_LITERAL_LIST['name']).replace('--', ''): TEST_LITERAL_LIST['result'] })
def test_literal_dict(self): sys.argv.append(TEST_LITERAL_DICT["name"]) sys.argv.append(TEST_LITERAL_DICT["value"]) argv_store = Argv( TEST_LITERAL_DICT["name"], type=type(TEST_LITERAL_DICT["result"]) ) result = argv_store.get() self.assertEqual( result, { str(TEST_LITERAL_DICT["name"]).replace("--", ""): TEST_LITERAL_DICT[ "result" ] }, )
def test_repeated_list(self): for value in TEST_LITERAL_LIST["result"]: sys.argv.append(TEST_LITERAL_LIST["name"]) sys.argv.append(value) argv_store = Argv(TEST_LITERAL_LIST["name"], type="repeated_list") result = argv_store.get() self.assertEqual( result, { str(TEST_LITERAL_LIST["name"]).replace("--", ""): TEST_LITERAL_LIST[ "result" ] }, )