Пример #1
0
    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)
Пример #2
0
 def test_testing_value_success(self):
     obj = {
         'baz': 'qux',
         'foo': ['a', 2, 'c']
     }
     assert check(obj, '/baz', 'qux')
     assert check(obj, '/foo/1', 2)
Пример #3
0
    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)
Пример #4
0
    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))
Пример #5
0
    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))
Пример #6
0
 def test_comparing_strings_and_numbers(self):
     obj = {
         '/': 9,
         '~1': 10
     }
     assert not check(obj, '/~01', '10')
Пример #7
0
 def test_escape_ordering(self):
     obj = {
         '/': 9,
         '~1': 10
     }
     assert check(obj, '/~01', 10)
Пример #8
0
 def test_testing_value_error(self):
     obj = {'baz': 'qux'}
     assert not check(obj, '/baz', 'bar')
Пример #9
0
 def test_comparing_strings_and_numbers(self):
     obj = {'/': 9, '~1': 10}
     assert not check(obj, '/~01', '10')
Пример #10
0
 def test_escape_ordering(self):
     obj = {'/': 9, '~1': 10}
     assert check(obj, '/~01', 10)
Пример #11
0
 def test_testing_value_error(self):
     obj = {'baz': 'qux'}
     assert not check(obj, '/baz', 'bar')
Пример #12
0
 def test_testing_value_success(self):
     obj = {'baz': 'qux', 'foo': ['a', 2, 'c']}
     assert check(obj, '/baz', 'qux')
     assert check(obj, '/foo/1', 2)