Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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))
Beispiel #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))
Beispiel #6
0
 def test_comparing_strings_and_numbers(self):
     obj = {
         '/': 9,
         '~1': 10
     }
     assert not check(obj, '/~01', '10')
Beispiel #7
0
 def test_escape_ordering(self):
     obj = {
         '/': 9,
         '~1': 10
     }
     assert check(obj, '/~01', 10)
Beispiel #8
0
 def test_testing_value_error(self):
     obj = {'baz': 'qux'}
     assert not check(obj, '/baz', 'bar')
Beispiel #9
0
 def test_comparing_strings_and_numbers(self):
     obj = {'/': 9, '~1': 10}
     assert not check(obj, '/~01', '10')
Beispiel #10
0
 def test_escape_ordering(self):
     obj = {'/': 9, '~1': 10}
     assert check(obj, '/~01', 10)
Beispiel #11
0
 def test_testing_value_error(self):
     obj = {'baz': 'qux'}
     assert not check(obj, '/baz', 'bar')
Beispiel #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)