Skip to content

Commit

Permalink
feat: add parsing of orient link with hash sign
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed May 27, 2024
1 parent 0ebd28a commit 469021e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyorient/otypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ class OrientRecordLink(object):
def __init__(self, recordlink):
cid, rpos = recordlink.split(":")
self.__link = recordlink
self.clusterID = cid
if cid.startswith("#") :
self.clusterID = cid[1:]
else :
self.clusterID = cid
self.recordPosition = rpos

def __str__(self):
Expand Down
27 changes: 27 additions & 0 deletions tests/test_orient_link.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
__author__ = 'Tglman <[email protected]>'
import unittest
import os

os.environ['DEBUG'] = "0"
os.environ['DEBUG_VERBOSE'] = "0"

import pyorient


class OrientLinkTestCase(unittest.TestCase):
""" Orient Link Case """

def test_simple_parse(self):

link = pyorient.OrientRecordLink("10:0")

assert link.clusterID == "10"
assert link.recordPosition == "0"

def test_simple_hash(self):

link = pyorient.OrientRecordLink("#10:20")

assert link.clusterID == "10"
assert link.recordPosition == "20"

0 comments on commit 469021e

Please sign in to comment.