[PATCH 1 of 3 saem] [test] Extract method to iter on XSD representations of a profile

Sylvain Thenault sylvain.thenault at logilab.fr
Fri May 19 10:51:44 CEST 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1495115410 -7200
#      Thu May 18 15:50:10 2017 +0200
# Node ID 1f47e9aee55b3efeac0ec3491e2ab412ca35b130
# Parent  7aca90bfbdf3aae98f434400e1368428443441bf
# Available At http://hg.logilab.org/review/cubes/saem_ref
#              hg pull http://hg.logilab.org/review/cubes/saem_ref -r 1f47e9aee55b
[test] Extract method to iter on XSD representations of a profile

diff --git a/test/test_seda.py b/test/test_seda.py
--- a/test/test_seda.py
+++ b/test/test_seda.py
@@ -57,35 +57,38 @@ class CWURIURLTC(unittest.TestCase):
                          'whatever')
 
 
 class SEDAExportTC(CubicWebTC):
 
+    def iter_seda_xsd(self, transfer):
+        """Yield XSD representations of the transfer for SEDA 0.2 then 1.0,
+        within a subTest.
+        """
+        for adapter_id in ('SEDA-0.2.xsd', 'SEDA-1.0.xsd'):
+            with self.subTest(adapter=adapter_id):
+                adapter = transfer.cw_adapt_to(adapter_id)
+                yield adapter.dump()
+
     def test_include_profile_ark(self):
         with self.admin_access.client_cnx() as cnx:
             transfer = testutils.seda_transfer(cnx)
             testutils.create_archive_unit(transfer)
             cnx.commit()
-            for adapter_id in ('SEDA-0.2.xsd', 'SEDA-1.0.xsd'):
-                with self.subTest(adapter=adapter_id):
-                    adapter = transfer.cw_adapt_to(adapter_id)
-                    xml = adapter.dump()
-                    self.assertIn('ArchivalProfile', xml)
-                    self.assertIn(transfer.ark, xml)
+            for xml in self.iter_seda_xsd(transfer):
+                self.assertIn('ArchivalProfile', xml)
+                self.assertIn(transfer.ark, xml)
 
     def test_include_agent_ark(self):
         with self.admin_access.client_cnx() as cnx:
             record = testutils.authority_record(cnx, u'DGSI')
 
             transfer = testutils.seda_transfer(cnx)
             _, _, unit_alt_seq = testutils.create_archive_unit(transfer)
             cnx.create_entity('SEDAOriginatingAgency', seda_originating_agency_from=unit_alt_seq,
                               seda_originating_agency_to=record)
 
-            for adapter_id in ('SEDA-0.2.xsd', 'SEDA-1.0.xsd'):
-                with self.subTest(adapter=adapter_id):
-                    adapter = transfer.cw_adapt_to(adapter_id)
-                    xml = adapter.dump()
-                    self.assertIn(record.ark, xml)
+            for xml in self.iter_seda_xsd(transfer):
+                self.assertIn(record.ark, xml)
 
 
 if __name__ == '__main__':
     unittest.main()


More information about the saem-devel mailing list