[PATCH 1 of 7 saem_ref] [test] Move tests concerning "ark" regexp and matching into test_ark.py

Denis Laxalde denis.laxalde at logilab.fr
Wed Feb 21 12:03:26 CET 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1519199141 -3600
#      Wed Feb 21 08:45:41 2018 +0100
# Node ID 9f17a87a83eedfd24e852ad6b8a2110f00425bb4
# Parent  28a4c9f49713599909cb66034d6b12411187cbb8
# Available At http://hg.logilab.org/review/cubes/saem_ref
#              hg pull http://hg.logilab.org/review/cubes/saem_ref -r 9f17a87a83ee
# EXP-Topic ark/unique-overall
[test] Move tests concerning "ark" regexp and matching into test_ark.py

diff --git a/test/test_ark.py b/test/test_ark.py
--- a/test/test_ark.py
+++ b/test/test_ark.py
@@ -15,6 +15,8 @@
 # with this program. If not, see <http://www.gnu.org/licenses/>.
 """cubicweb-saem-ref tests for ARK identifier generation."""
 
+from unittest import TestCase
+
 import psycopg2
 
 from cubicweb.devtools import (
@@ -22,6 +24,9 @@ from cubicweb.devtools import (
     testlib,
 )
 
+from cubicweb_saem_ref.ark import (
+    match as ark_match,
+)
 import testutils
 
 
@@ -29,6 +34,31 @@ def setUpModule():
     testutils.startpgcluster(__file__)
 
 
+class ArkRgxTC(TestCase):
+
+    def test(self):
+        match = ark_match('ark:/12345/rf%sg' % ('q' * 7))
+        self.assertTrue(match)
+        self.assertEqual(match.group('naan'), '12345')
+        self.assertEqual(match.group('name'), 'rfqqqqqqqg')
+
+    def test_no_scheme(self):
+        match = ark_match('12345/rf%sg' % ('q' * 7))
+        self.assertTrue(match)
+        self.assertEqual(match.group('naan'), '12345')
+        self.assertEqual(match.group('name'), 'rfqqqqqqqg')
+
+    def test_tesutils_match_ark_qualified(self):
+        ark = '0/rfr8hps6ng/h4050n4j02'
+
+        def check(match):
+            self.assertTrue(match)
+            self.assertEqual(match.group(1), '/h4050n4j02')
+
+        check(testutils.match_ark(ark))
+        check(testutils.match_ark_uri('ark:/' + ark))
+
+
 class ArkServiceTC(testlib.CubicWebTC):
     # This could be a plain unittest.TestCase as we don't use CubicWeb's
     # database. But on the other hand, CubicWebTC makes it easier to get a
diff --git a/test/unittest_entities.py b/test/unittest_entities.py
--- a/test/unittest_entities.py
+++ b/test/unittest_entities.py
@@ -14,14 +14,11 @@
 # You should have received a copy of the GNU Lesser General Public License along
 # with this program. If not, see <http://www.gnu.org/licenses/>.
 
-from unittest import TestCase
-
 from cubicweb.devtools import PostgresApptestConfiguration
 from cubicweb.devtools.testlib import CubicWebTC
 
 from cubicweb_saem_ref.ark import (
     ARK_QUALIFIER_LENGTH,
-    match as ark_match,
 )
 import testutils
 
@@ -30,31 +27,6 @@ def setUpModule():
     testutils.startpgcluster(__file__)
 
 
-class ArkRgxTC(TestCase):
-
-    def test(self):
-        match = ark_match('ark:/12345/rf%sg' % ('q' * 7))
-        self.assertTrue(match)
-        self.assertEqual(match.group('naan'), '12345')
-        self.assertEqual(match.group('name'), 'rfqqqqqqqg')
-
-    def test_no_scheme(self):
-        match = ark_match('12345/rf%sg' % ('q' * 7))
-        self.assertTrue(match)
-        self.assertEqual(match.group('naan'), '12345')
-        self.assertEqual(match.group('name'), 'rfqqqqqqqg')
-
-    def test_tesutils_match_ark_qualified(self):
-        ark = '0/rfr8hps6ng/h4050n4j02'
-
-        def check(match):
-            self.assertTrue(match)
-            self.assertEqual(match.group(1), '/h4050n4j02')
-
-        check(testutils.match_ark(ark))
-        check(testutils.match_ark_uri('ark:/' + ark))
-
-
 class ArkGeneratorTC(CubicWebTC):
 
     configcls = PostgresApptestConfiguration



More information about the saem-devel mailing list