Example #1
0
    def test_it_raises_an_error_on_unrecognized_escape_sequences(self):
        with self.assertRaises(error.UnrecognizedEscapeSequence):
            Pointer.resolve_in('/~2', document={})

        with self.assertRaises(error.UnrecognizedEscapeSequence):
            Pointer.resolve_in('~2', document={})
Example #2
0
    def test_it_raises_an_error_on_unescaped_tilde(self):
        with self.assertRaises(error.UnescapedTilde):
            Pointer.resolve_in('/~', document={})

        with self.assertRaises(error.UnescapedTilde):
            Pointer.resolve_in('~', document={})
Example #3
0
    def check_pointer_equal(self, document, pointer, value):
        self.assertEqual(Pointer.resolve_in(pointer, document), value)

        # test that starting slash in non-empty pointer is optional
        if (len(pointer) > 1 and pointer[0] == '/'):
            self.assertEqual(Pointer.resolve_in(pointer[1:], document), value)
Example #4
0
    def test_it_raises_an_error_if_key_not_in_document(self):
        with self.assertRaises(error.MemberNotDefined):
            Pointer.resolve_in('/key', document={})

        with self.assertRaises(error.MemberNotDefined):
            Pointer.resolve_in('key', document={})
Example #5
0
    def test_it_raises_an_error_for_non_numeric_array_index(self):
        with self.assertRaises(error.InvalidArrayIndex):
            Pointer.resolve_in('/key', document=[])

        with self.assertRaises(error.InvalidArrayIndex):
            Pointer.resolve_in('key', document=[])
Example #6
0
    def test_it_raises_an_error_for_array_index_out_of_range(self):
        with self.assertRaises(error.IndexOutOfRange):
            Pointer.resolve_in('/5', document=[])

        with self.assertRaises(error.IndexOutOfRange):
            Pointer.resolve_in('5', document=[])
Example #7
0
    def test_it_raises_an_error_for_dash_as_an_array_index(self):
        with self.assertRaises(error.DashArrayIndexNotSupported):
            Pointer.resolve_in('/-', document=[])

        with self.assertRaises(error.DashArrayIndexNotSupported):
            Pointer.resolve_in('-', document=[])