From 469021e7f85f820e5e84260a449743845357bf02 Mon Sep 17 00:00:00 2001 From: Tglman Date: Mon, 27 May 2024 17:42:30 +0200 Subject: [PATCH] feat: add parsing of orient link with hash sign --- pyorient/otypes.py | 5 ++++- tests/test_orient_link.py | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/test_orient_link.py diff --git a/pyorient/otypes.py b/pyorient/otypes.py index 22d99a2c..246d0d1b 100644 --- a/pyorient/otypes.py +++ b/pyorient/otypes.py @@ -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): diff --git a/tests/test_orient_link.py b/tests/test_orient_link.py new file mode 100644 index 00000000..f8f45884 --- /dev/null +++ b/tests/test_orient_link.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +__author__ = 'Tglman ' +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"