예제 #1
0
    def test_copy(self):
        obj = {'foo': 42, 'bar': {}}
        response = copy(obj, '/bar/baz', '/foo')
        assert response == {'foo': 42, 'bar': {'baz': 42}}
        assert response != obj

        obj = {'foo': {'baz': 42}}
        response = copy(obj, '/bar', '/foo')
        assert response == {'foo': {'baz': 42}, 'bar': {'baz': 42}}
예제 #2
0
    def test_copy(self):
        obj = {'foo': 42, 'bar': {}}
        response = copy(obj, '/bar/baz', '/foo')
        assert response == {'foo': 42, 'bar': {'baz': 42}}
        assert response != obj

        obj = {'foo': {'baz': 42}}
        response = copy(obj, '/bar', '/foo')
        assert response == {'foo': {'baz': 42}, 'bar': {'baz': 42}}
예제 #3
0
    def run(self, args):
        parse_pointer(args)
        parse_document(args)
        parse_target(args)

        from jsonspec.operations import copy, Error
        from jsonspec.pointer import ParseError

        try:
            response = copy(args.document, args.target, args.pointer)
            return driver.dumps(response, indent=args.indent)
        except Error as error:
            raise Exception(error)
        except ParseError as error:
            raise Exception('{} is not a valid pointer'.format(args.pointer))
예제 #4
0
파일: cli.py 프로젝트: johnnoone/json-spec
    def run(self, args):
        parse_pointer(args)
        parse_document(args)
        parse_target(args)

        from jsonspec.operations import copy, Error
        from jsonspec.pointer import ParseError

        try:
            response = copy(args.document, args.target, args.pointer)
            return driver.dumps(response, indent=args.indent)
        except Error as error:
            raise Exception(error)
        except ParseError as error:
            raise Exception('{} is not a valid pointer'.format(args.pointer))