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}}
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))