def test_it_moves(self): origin_pointer = Pointer(self.dictionary) pointer = origin_pointer.move('result').move('items').move(0).move('id') self.assertEqual(pointer.path(), '#.result.items[0].id') self.assertEqual(pointer.value(), self.dictionary['result']['items'][0]['id']) self.assertEqual(origin_pointer.path(), '#') self.assertEqual(origin_pointer.value(), self.dictionary)
def test_it_moves(self): origin_pointer = Pointer(self.dictionary) pointer = origin_pointer.move('result').move('items').move(0).move( 'id') self.assertEqual(pointer.path(), '#.result.items[0].id') self.assertEqual(pointer.value(), self.dictionary['result']['items'][0]['id']) self.assertEqual(origin_pointer.path(), '#') self.assertEqual(origin_pointer.value(), self.dictionary)
def test_it_returns_value(self): pointer = Pointer(self.dictionary) self.assertEqual(pointer.value(), self.dictionary) pointer = Pointer(self.dictionary, ['result']) self.assertEqual(pointer.value(), self.dictionary['result']) pointer = Pointer(self.dictionary, ['result', 'total']) self.assertEqual(pointer.value(), self.dictionary['result']['total']) pointer = Pointer(self.dictionary, ['result', 'items']) self.assertEqual(pointer.value(), self.dictionary['result']['items']) pointer = Pointer(self.dictionary, ['result', 'items', 0]) self.assertEqual(pointer.value(), self.dictionary['result']['items'][0]) pointer = Pointer(self.dictionary, ['result', 'items', 0, 'id']) self.assertEqual(pointer.value(), self.dictionary['result']['items'][0]['id'])