[PATCH 1 of 3 seda] [test] Import profile_generation module rather than specific names

Sylvain Thenault sylvain.thenault at logilab.fr
Thu Aug 24 16:24:29 CEST 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1503584527 -7200
#      Thu Aug 24 16:22:07 2017 +0200
# Node ID 21de2d5db25611a963b4e0edb1962db1f096caab
# Parent  12ff9f4270d1a39153cd059aeb4f826f6816c929
# Available At https://hg.logilab.org/review/cubes/seda
#              hg pull https://hg.logilab.org/review/cubes/seda -r 21de2d5db256
[test] Import profile_generation module rather than specific names

this will ease testing of other things in this module (as in following cset).

diff --git a/test/test_profile_generation.py b/test/test_profile_generation.py
--- a/test/test_profile_generation.py
+++ b/test/test_profile_generation.py
@@ -32,11 +32,11 @@ from lxml.doctestcompare import LXMLOutp
 from logilab.common.decorators import cached
 
 from cubicweb.devtools.testlib import CubicWebTC
 
 from cubicweb_seda.xsd2yams import XSDMMapping
-from cubicweb_seda.entities.profile_generation import _path_target_values, eid2xmlid
+from cubicweb_seda.entities import profile_generation as pg
 
 from cubicweb_seda import testutils
 
 
 class XmlTestMixin(object):
@@ -239,32 +239,32 @@ class PathTargetValuesTC(CubicWebTC):
             #        ('seda_keyword_reference_to', 'subject', 'Concept')]),
             #      ('KeywordType', [('seda_keyword_type_from', 'object', 'SEDAKeywordType'),
             #                       ('seda_keyword_type_to', 'subject', 'Concept')]),
             #  ]))
             path = edef[-1][0][1]
-            target_values = _path_target_values(kw, path)
+            target_values = pg._path_target_values(kw, path)
             self.assertEqual(len(target_values), 1)
             target_value = target_values[0]
             self.assertEqual(target_value[0], None)
             self.assertEqual(target_value[1], None)
 
             path = edef[-1][2][1]
-            target_values = _path_target_values(kw, path)
+            target_values = pg._path_target_values(kw, path)
             self.assertEqual(len(target_values), 0)
 
             path = edef[-1][3][1]
-            target_values = _path_target_values(kw, path)
+            target_values = pg._path_target_values(kw, path)
             self.assertEqual(len(target_values), 1)
             target_value = target_values[0]
             self.assertEqual(target_value[0].eid, kt.eid)
             self.assertEqual(target_value[1], None)
 
             kt_scheme = testutils.scheme_for_rtype(cnx, 'seda_keyword_type_to', u'theme')
             kw_type = kt_scheme.reverse_in_scheme[0]
             kt.cw_set(seda_keyword_type_to=kw_type)
             path = edef[-1][3][1]
-            target_values = _path_target_values(kw, path)
+            target_values = pg._path_target_values(kw, path)
             self.assertEqual(len(target_values), 1)
             target_value = target_values[0]
             self.assertEqual(target_value[0].eid, kt.eid)
             self.assertEqual(target_value[1].eid, kw_type.eid)
 
@@ -273,11 +273,11 @@ class PathTargetValuesTC(CubicWebTC):
             #     readable_edef(edef),
             #     ('KeywordContent', 'SEDAKeyword', [
             #         ('KeywordContent', [('keyword_content', 'subject', 'String')]),
             #     ]))
             path = edef[-1][0][1]
-            target_values = _path_target_values(kw, path)
+            target_values = pg._path_target_values(kw, path)
             self.assertEqual(len(target_values), 1)
             target_value = target_values[0]
             self.assertEqual(target_value[0], None)
             self.assertEqual(target_value[1], None)
 
@@ -303,11 +303,11 @@ class PathTargetValuesTC(CubicWebTC):
             #    [('seda_data_object_reference_id',
             #      'subject',
             #      ('SEDABinaryDataObject', 'SEDAPhysicalDataObject'))])])
 
             path = edef[-1][1][1]
-            target_values = _path_target_values(ref, path)
+            target_values = pg._path_target_values(ref, path)
             self.assertEqual(len(target_values), 1)
             target_value = target_values[0]
             self.assertEqual(target_value[0], None)
             self.assertEqual(target_value[1].eid, bdo.eid)
 
@@ -663,11 +663,11 @@ class SEDARNGExportFuncTC(SEDAExportFunc
         # ensure profile's temporary id are exported in custom seda:profid attribute
         self.assertEqual(len(self.xpath(root, '//rng:attribute[@seda:profid]')), 2)
         for attrdef in self.xpath(root, '//xs:attribute[@seda:profid]'):
             self.assertEqual(attrdef[0]['type'], 'ID')
         # ensure they are properly referenced using 'default' attribute
-        xmlid = eid2xmlid(self.bdo_eid)
+        xmlid = pg.eid2xmlid(self.bdo_eid)
         references = self.xpath(root, '//rng:element[@a:defaultValue="{}"]'.format(xmlid))
         self.assertEqual(len(references), 1)
         self.assertEqual(references[0].attrib['name'], 'DataObjectReferenceId')
         for reference_id in self.xpath(root, '//rng:element[@name="DataObjectReferenceId"]'):
             self.assertEqual(reference_id[0].attrib['type'], 'NCName')


More information about the saem-devel mailing list