[PATCH 03 of 11 saem_ref] [ark] Add a control character at the end of "name" component of identifiers

Denis Laxalde denis.laxalde at logilab.fr
Mon Feb 12 15:20:39 CET 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1518170539 -3600
#      Fri Feb 09 11:02:19 2018 +0100
# Node ID 7572cbb74a1d8a57a804eb43a0651b45dd76dcd6
# Parent  5008f846f60b21a217149cd4f7e27a3228ff387b
# Available At http://hg.logilab.org/review/cubes/saem_ref
#              hg pull http://hg.logilab.org/review/cubes/saem_ref -r 7572cbb74a1d
# EXP-Topic ark/prefix-suffix
[ark] Add a control character at the end of "name" component of identifiers

Related to #46881387.

diff --git a/cubicweb_saem_ref/entities/__init__.py b/cubicweb_saem_ref/entities/__init__.py
--- a/cubicweb_saem_ref/entities/__init__.py
+++ b/cubicweb_saem_ref/entities/__init__.py
@@ -22,10 +22,8 @@ from cubicweb.predicates import match_kw
 from cubicweb.entities import AnyEntity, fetch_config, authobjs, lib
 
 
-
-
 def make_ark(name):
-    return u'rf{name}'.format(name=name)
+    return u'rf{name}g'.format(name=name)
 
 
 class ARKGeneratorMixIn(object):
diff --git a/test/test_seda.py b/test/test_seda.py
--- a/test/test_seda.py
+++ b/test/test_seda.py
@@ -121,7 +121,7 @@ class CloneImportTC(CubicWebTC):
         with self.admin_access.web_request(**params) as req:
             path, _ = self.expect_redirect_handle_request(
                 req, 'seda.doimport')
-            match = re.match(r'^ark:/0/rf0*(\d+)$', path)
+            match = re.match(r'^ark:/0/rf0*(\d+)g$', path)
             assert match, path
             eid = int(match.group(1))
             rset = req.execute('Any X WHERE X seda_archive_unit P, P eid %(p)s',
diff --git a/test/test_views.py b/test/test_views.py
--- a/test/test_views.py
+++ b/test/test_views.py
@@ -329,7 +329,7 @@ class ArkViewsTC(CubicWebTC):
             path = self.expect_redirect_handle_request(req)[0]
             eid = eid_from_ark(path)
             record = req.cnx.entity_from_eid(eid)
-            self.assertEqual(record.ark, u'0/rf%09d' % eid)
+            self.assertEqual(record.ark, u'0/rf%09dg' % eid)
 
     def test_ark_agent_creation(self):
         with self.admin_access.web_request() as req:
@@ -343,7 +343,7 @@ class ArkViewsTC(CubicWebTC):
             path = self.expect_redirect_handle_request(req)[0]
             eid = eid_from_ark(path)
             agent = req.cnx.entity_from_eid(eid)
-            self.assertEqual(agent.ark, u'0/rf%09d' % eid)
+            self.assertEqual(agent.ark, u'0/rf%09dg' % eid)
 
     def test_ark_scheme_creation(self):
         with self.admin_access.web_request() as req:
@@ -355,7 +355,7 @@ class ArkViewsTC(CubicWebTC):
             path = self.expect_redirect_handle_request(req)[0]
             eid = eid_from_ark(path)
             scheme = req.cnx.entity_from_eid(eid)
-            self.assertEqual(scheme.ark, u'0/rf%09d' % eid)
+            self.assertEqual(scheme.ark, u'0/rf%09dg' % eid)
 
     def test_ark_concept_creation_form(self):
         # test addition of a concept by specifying in_scheme in form
@@ -374,7 +374,7 @@ class ArkViewsTC(CubicWebTC):
             path = self.expect_redirect_handle_request(req)[0]
             eid = eid_from_ark(path)
             concept = req.cnx.entity_from_eid(eid)
-            self.assertEqual(concept.ark, u'0/rf%09d' % eid)
+            self.assertEqual(concept.ark, u'0/rf%09dg' % eid)
 
     def test_ark_concept_creation_linkto(self):
         # test addition of a concept by specifying in_scheme with __linkto
@@ -393,7 +393,7 @@ class ArkViewsTC(CubicWebTC):
             path = self.expect_redirect_handle_request(req)[0]
             eid = eid_from_ark(path)
             concept = req.cnx.entity_from_eid(eid)
-            self.assertEqual(concept.ark, u'0/rf%09d' % eid)
+            self.assertEqual(concept.ark, u'0/rf%09dg' % eid)
 
     def test_ark_url_rewrite(self):
         with self.admin_access.web_request() as req:
@@ -473,14 +473,14 @@ class AssignArkWebServiceTC(CubicWebTC):
                 method='POST', **params) as req:
             result = self.app_handle_request(req, 'ark')
             self.assertEqual(json.loads(result),
-                             [{'ark': '0/rf000000001'}])
+                             [{'ark': '0/rf000000001g'}])
         params = {'organization': 'ark:/' + org_ark}
         with self.admin_access.web_request(
                 headers={'Accept': 'application/json'},
                 method='POST', **params) as req:
             result = self.app_handle_request(req, 'ark')
             self.assertEqual(json.loads(result),
-                             [{'ark': '0/rf000000002'}])
+                             [{'ark': '0/rf000000002g'}])
 
 
 class ListArchivalUnitsServiceTC(CubicWebTC):
diff --git a/test/unittest_entities.py b/test/unittest_entities.py
--- a/test/unittest_entities.py
+++ b/test/unittest_entities.py
@@ -24,13 +24,13 @@ class ArkGeneratorTC(CubicWebTC):
             generator = self.vreg['adapters'].select(
                 'IARKGenerator', cnx, eid=42, naa_what='saemref-test')
             self.assertEqual(generator.generate_ark(),
-                             'saemref-test/rf000000042')
+                             'saemref-test/rf000000042g')
 
     def test_ext_identifier(self):
         with self.admin_access.repo_cnx() as cnx:
             generator = self.vreg['adapters'].select('IARKGenerator', cnx,
                                                      naa_what='saemref-test')
-            self.assertEqual(generator.generate_ark(), 'saemref-test/rf000000001')
+            self.assertEqual(generator.generate_ark(), 'saemref-test/rf000000001g')
 
 
 if __name__ == '__main__':
diff --git a/test/unittest_hooks.py b/test/unittest_hooks.py
--- a/test/unittest_hooks.py
+++ b/test/unittest_hooks.py
@@ -205,22 +205,22 @@ class SAEMRefHooksTC(CubicWebTC):
         with self.admin_access.repo_cnx() as cnx:
             agent = testutils.authority_record(cnx, u'bob')
             cnx.commit()
-            self.assertEqual(agent.ark, '0/rf%09d' % agent.eid)
-            self.assertEqual(agent.cwuri, 'ark:/0/rf%09d' % agent.eid)
+            self.assertEqual(agent.ark, '0/rf%09dg' % agent.eid)
+            self.assertEqual(agent.cwuri, 'ark:/0/rf%09dg' % agent.eid)
             agent = testutils.authority_record(cnx, u'john', ark=u'authority/123456')
             cnx.commit()
             self.assertEqual(agent.ark, 'authority/123456')
             self.assertEqual(agent.cwuri, 'ark:/authority/123456')
             agent = testutils.authority_record(cnx, u'alf', cwuri=u'http://someuri/someagent')
             cnx.commit()
-            self.assertEqual(agent.ark, '0/rf%09d' % agent.eid)
+            self.assertEqual(agent.ark, '0/rf%09dg' % agent.eid)
             self.assertEqual(agent.cwuri, 'http://someuri/someagent')
 
     def test_ark_generation_seda_profile(self):
         with self.admin_access.repo_cnx() as cnx:
             profile = testutils.setup_profile(cnx)
-            self.assertEqual(profile.ark, '0/rf{0:09d}'.format(profile.eid))
-            self.assertEqual(profile.cwuri, 'ark:/0/rf{0:09d}'.format(profile.eid))
+            self.assertEqual(profile.ark, '0/rf{0:09d}g'.format(profile.eid))
+            self.assertEqual(profile.cwuri, 'ark:/0/rf{0:09d}g'.format(profile.eid))
 
     def test_ark_generation_seda_profile_ark_given(self):
         with self.admin_access.repo_cnx() as cnx:
@@ -232,7 +232,7 @@ class SAEMRefHooksTC(CubicWebTC):
         with self.admin_access.repo_cnx() as cnx:
             profile = testutils.setup_profile(
                 cnx, cwuri=u'http://example.org/profile/125')
-            self.assertEqual(profile.ark, '0/rf{0:09d}'.format(profile.eid))
+            self.assertEqual(profile.ark, '0/rf{0:09d}g'.format(profile.eid))
             self.assertEqual(profile.cwuri, 'http://example.org/profile/125')
 
     def test_ark_generation_concept(self):
@@ -240,19 +240,19 @@ class SAEMRefHooksTC(CubicWebTC):
             scheme = cnx.create_entity('ConceptScheme', ark_naa=testutils.naa(cnx))
             concept = scheme.add_concept(u'some object')
             cnx.commit()
-            self.assertEqual(scheme.ark, '0/rf%09d' % scheme.eid)
+            self.assertEqual(scheme.ark, '0/rf%09dg' % scheme.eid)
             self.assertEqual(scheme.cwuri,
-                             'ark:/0/rf%09d' % scheme.eid)
-            self.assertEqual(concept.ark, '0/rf%09d' % concept.eid)
+                             'ark:/0/rf%09dg' % scheme.eid)
+            self.assertEqual(concept.ark, '0/rf%09dg' % concept.eid)
             self.assertEqual(concept.cwuri,
-                             'ark:/0/rf%09d' % concept.eid)
+                             'ark:/0/rf%09dg' % concept.eid)
             scheme = cnx.create_entity('ConceptScheme', cwuri=u'http://someuri/somescheme',
                                        ark_naa=testutils.naa(cnx))
             concept = scheme.add_concept(u'some object', cwuri=u'http://someuri/someconcept')
             cnx.commit()
-            self.assertEqual(scheme.ark, '0/rf%09d' % scheme.eid)
+            self.assertEqual(scheme.ark, '0/rf%09dg' % scheme.eid)
             self.assertEqual(scheme.cwuri, 'http://someuri/somescheme')
-            self.assertEqual(concept.ark, '0/rf%09d' % concept.eid)
+            self.assertEqual(concept.ark, '0/rf%09dg' % concept.eid)
             self.assertEqual(concept.cwuri, 'http://someuri/someconcept')
             scheme = cnx.create_entity('ConceptScheme', cwuri=u'http://dcf/res/ark:/67717/Matiere',
                                        ark_naa=testutils.naa(cnx))
diff --git a/test/unittest_sobjects_skos.py b/test/unittest_sobjects_skos.py
--- a/test/unittest_sobjects_skos.py
+++ b/test/unittest_sobjects_skos.py
@@ -92,7 +92,7 @@ class LCSVImportTC(CubicWebTC):
             concept1 = cnx.find(
                 'Concept', definition="Définition de l'organisation politique de l'organisme").one()
             self.assertEqual(concept1.cwuri,
-                             'ark:/0/rf%09d' % concept1.eid)
+                             'ark:/0/rf%09dg' % concept1.eid)
 
 
 if __name__ == '__main__':


More information about the saem-devel mailing list