コード例 #1
0
  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)
コード例 #2
0
    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)
コード例 #3
0
  def test_it_returns_path(self):
    pointer = Pointer(self.dictionary)
    self.assertEqual(pointer.path(), '#')

    pointer = Pointer(self.dictionary, ['result'])
    self.assertEqual(pointer.path(), '#.result')

    pointer = Pointer(self.dictionary, ['result', 'total'])
    self.assertEqual(pointer.path(), '#.result.total')

    pointer = Pointer(self.dictionary, ['result', 'items'])
    self.assertEqual(pointer.path(), '#.result.items')

    pointer = Pointer(self.dictionary, ['result', 'items', 0])
    self.assertEqual(pointer.path(), '#.result.items[0]')

    pointer = Pointer(self.dictionary, ['result', 'items', 0, 'id'])
    self.assertEqual(pointer.path(), '#.result.items[0].id')
コード例 #4
0
    def test_it_returns_path(self):
        pointer = Pointer(self.dictionary)
        self.assertEqual(pointer.path(), '#')

        pointer = Pointer(self.dictionary, ['result'])
        self.assertEqual(pointer.path(), '#.result')

        pointer = Pointer(self.dictionary, ['result', 'total'])
        self.assertEqual(pointer.path(), '#.result.total')

        pointer = Pointer(self.dictionary, ['result', 'items'])
        self.assertEqual(pointer.path(), '#.result.items')

        pointer = Pointer(self.dictionary, ['result', 'items', 0])
        self.assertEqual(pointer.path(), '#.result.items[0]')

        pointer = Pointer(self.dictionary, ['result', 'items', 0, 'id'])
        self.assertEqual(pointer.path(), '#.result.items[0].id')