Esempio n. 1
0
    def test_setup_no_module(self):
        with self.assertRaises(CliError) as context:
            get_operation_and_args('no.op', '')

        self.assertEqual(
            context.exception.message,
            'No such module: no',
        )
Esempio n. 2
0
    def test_setup_no_op(self):
        with self.assertRaises(CliError) as context:
            get_operation_and_args('server.no', '')

        self.assertEqual(
            context.exception.message,
            'No such operation: server.no',
        )
Esempio n. 3
0
    def test_setup_op_and_json_args(self):
        commands = ('server.user', '[["one", "two"], {"hello": "world"}]')

        assert get_operation_and_args(commands) == (
            server.user,
            (['one', 'two'], {'hello': 'world'}),
        )
Esempio n. 4
0
    def test_setup_op_and_args(self):
        commands = ('server.user', 'one', 'two', 'hello=world')

        assert get_operation_and_args(commands) == (
            server.user,
            (['one', 'two'], {'hello': 'world'}),
        )
Esempio n. 5
0
    def test_legacy_setup_op_and_json_args(self):
        op_string = 'server.user'
        args_string = '[["one", "two"], {"hello": "world"}]'

        assert get_operation_and_args((op_string, args_string)) == (
            server.user,
            (['one', 'two'], {
                'hello': 'world'
            }),
        )
Esempio n. 6
0
    def test_legacy_setup_op_and_args_list(self):
        op_string = 'server.user'
        args_string = '[one,two],hello=world'

        assert get_operation_and_args((op_string, args_string)) == (
            server.user,
            ([['one', 'two']], {
                'hello': 'world'
            }),
        )
Esempio n. 7
0
    def test_legacy_setup_op_and_args(self):
        op_string = 'server.user'
        args_string = 'one,two,hello=world'

        self.assertEqual(
            get_operation_and_args((op_string, args_string)),
            (
                server.user,
                (['one', 'two'], {'hello': 'world'}),
            ),
        )
Esempio n. 8
0
    def test_setup_op_and_json_args(self):
        op_string = 'server.user'
        args_string = '[["one", "two"], {"hello": "world"}]'

        self.assertEqual(
            get_operation_and_args(op_string, args_string),
            (
                server.user,
                (['one', 'two'], {
                    'hello': 'world'
                }),
            ),
        )
Esempio n. 9
0
    def test_setup_op_and_args_list(self):
        op_string = 'server.user'
        args_string = '[one,two],hello=world'

        self.assertEqual(
            get_operation_and_args(op_string, args_string),
            (
                server.user,
                ([['one', 'two']], {
                    'hello': 'world'
                }),
            ),
        )
Esempio n. 10
0
def test_user_op(user_sys_path):
    commands = ('test_ops.dummy_op', 'arg1', 'arg2')
    res = get_operation_and_args(commands)

    import test_ops
    assert res == (test_ops.dummy_op, (['arg1', 'arg2'], {}))