[test] Follow new eac cube API
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 20 Jan 2017 10:34:37 +0100
changeset 2312 7f773346c679
parent 2311 1fe3dfa71ce3
child 2314 4286fd72c879
[test] Follow new eac cube API
dev-requirements.txt
test/test_profile_generation.py
test/testutils.py
--- a/dev-requirements.txt	Fri Jan 20 10:33:34 2017 +0100
+++ b/dev-requirements.txt	Fri Jan 20 10:34:37 2017 +0100
@@ -1,2 +1,3 @@
 pytest
 http://hg.logilab.org/master/cubicweb/archive/3.24.tar.bz2#egg=cubicweb
+http://hg.logilab.org/master/cubes/eac/archive/tip.tar.bz2#egg=cubicweb-eac
--- a/test/test_profile_generation.py	Fri Jan 20 10:33:34 2017 +0100
+++ b/test/test_profile_generation.py	Fri Jan 20 10:34:37 2017 +0100
@@ -601,8 +601,8 @@
         """Check that an agent is exported as expected in a SEDA profile."""
         with self.admin_access.client_cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
-            archival_org = cnx.create_entity('AuthorityRecord', name=u'Archival inc.',
-                                             reverse_seda_archival_agency=transfer)
+            archival_org = testutils.create_authority_record(
+                cnx, u'Archival inc.', reverse_seda_archival_agency=transfer)
             profile = self.profile_etree(transfer)
             enum_elts = self.xpath(profile,
                                    '//xs:element[@name="ArchivalAgency"]/xs:complexType'
@@ -898,7 +898,7 @@
                 for value, key in [(file_concept.cwuri, 'concept-uri'),
                                    (file_concept.scheme.cwuri, 'scheme-uri'),
                                    (text_type(agent.eid), 'agent-id'),
-                                   (agent.name, 'agent-name')]:
+                                   (agent.dc_title(), 'agent-name')]:
                     orig_content = orig_content.replace(value, '%({})s'.format(key))
                 with open(self.datapath(expected_file + '.new'), 'w') as stream:
                     stream.write(orig_content)
@@ -911,7 +911,7 @@
                                     % {'concept-uri': binary_type(file_concept.cwuri),
                                        'scheme-uri': binary_type(file_concept.scheme.cwuri),
                                        'agent-id': binary_type(agent.eid),
-                                       'agent-name': binary_type(agent.name)},
+                                       'agent-name': binary_type(agent.dc_title())},
                                     generated_xsd)
             return adapter, root
 
--- a/test/testutils.py	Fri Jan 20 10:33:34 2017 +0100
+++ b/test/testutils.py	Fri Jan 20 10:34:37 2017 +0100
@@ -68,8 +68,10 @@
 def create_authority_record(cnx, name, kind=u'person', **kwargs):
     """Return an AuthorityRecord with specified kind and name."""
     kind_eid = cnx.find('AgentKind', name=kind)[0][0]
-    return cnx.create_entity('AuthorityRecord', name=name,
-                             agent_kind=kind_eid, **kwargs)
+    record = cnx.create_entity('AuthorityRecord', agent_kind=kind_eid, **kwargs)
+    cnx.create_entity('NameEntry', parts=name, form_variant=u'authorized',
+                      name_entry_for=record)
+    return record
 
 
 def map_cs_to_type(scheme, rtype, etype=None):