Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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']
            })
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
    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']
            })
Ejemplo n.º 8
0
    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"
                ]
            },
        )
Ejemplo n.º 9
0
    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"
                ]
            },
        )