def test_check(self): assert check({'foo': 'bar'}, '/foo', 'bar') assert not check({'foo': 'bar'}, '/foo', 'baz') assert not check({'foo': 'bar'}, '/bar/baz', 'quux') with self.assertRaises(Error): check({'foo': 'bar'}, '/bar/baz', 'quux', raise_onerror=True)
def test_testing_value_success(self): obj = { 'baz': 'qux', 'foo': ['a', 2, 'c'] } assert check(obj, '/baz', 'qux') assert check(obj, '/foo/1', 2)
def run(self, args): parse_pointer(args) parse_document(args) parse_fragment(args) from jsonspec.operations import check, Error from jsonspec.pointer import ParseError try: if check(args.document, args.pointer, args.fragment): return 'It validates' else: raise Exception('It does not validate') except Error as error: raise Exception('It does not validate') except ParseError as error: raise Exception('{} is not a valid pointer'.format(args.pointer))
def test_comparing_strings_and_numbers(self): obj = { '/': 9, '~1': 10 } assert not check(obj, '/~01', '10')
def test_escape_ordering(self): obj = { '/': 9, '~1': 10 } assert check(obj, '/~01', 10)
def test_testing_value_error(self): obj = {'baz': 'qux'} assert not check(obj, '/baz', 'bar')
def test_comparing_strings_and_numbers(self): obj = {'/': 9, '~1': 10} assert not check(obj, '/~01', '10')
def test_escape_ordering(self): obj = {'/': 9, '~1': 10} assert check(obj, '/~01', 10)
def test_testing_value_success(self): obj = {'baz': 'qux', 'foo': ['a', 2, 'c']} assert check(obj, '/baz', 'qux') assert check(obj, '/foo/1', 2)