[PATCH 3 of 6 seda V2] [test/cleanup] Use .cnx instead of (repo/client)_cnx

Sylvain Thenault sylvain.thenault at logilab.fr
Tue Apr 11 15:22:17 CEST 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1491916779 -7200
#      Tue Apr 11 15:19:39 2017 +0200
# Node ID 260a3f3f99def154b7079522cfac722e3ffd0a78
# Parent  0bc3261c085382cb1d5aff5e79cdb30013d03a27
[test/cleanup] Use .cnx instead of (repo/client)_cnx

diff --git a/test/test_dataimport.py b/test/test_dataimport.py
--- a/test/test_dataimport.py
+++ b/test/test_dataimport.py
@@ -21,11 +21,11 @@ from cubicweb_seda import dataimport
 
 
 class ConcepSchemeImportTC(CubicWebTC):
 
     def test_import_seda_schemes(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             dataimport.import_seda_schemes(cnx, lcsv_import=dataimport.lcsv_check)
             self.assertEqual(len(cnx.find('ConceptScheme')), 18)
 
 
 if __name__ == '__main__':
diff --git a/test/test_diag.py b/test/test_diag.py
--- a/test/test_diag.py
+++ b/test/test_diag.py
@@ -21,11 +21,11 @@ from cubicweb_seda.testutils import crea
 
 
 class CompatAnalyzerTC(CubicWebTC):
 
     def test_rules(self):
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             create = cnx.create_entity
 
             transfer = create('SEDAArchiveTransfer', title=u'diagnosis testing')
             doctor = transfer.cw_adapt_to('ISEDACompatAnalyzer')
             cnx.commit()
@@ -77,11 +77,11 @@ class CompatAnalyzerTC(CubicWebTC):
             cnx.commit()
             self.assertDiagnostic(doctor, ['SEDA 2.0'],
                                   'rule_ref_non_rule_id')
 
     def test_custodial_history(self):
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             create = cnx.create_entity
 
             transfer = create('SEDAArchiveTransfer', title=u'diagnosis testing')
             unit, unit_alt, unit_alt_seq = create_archive_unit(transfer)
             access_rule = create('SEDAAccessRule',
@@ -113,20 +113,20 @@ class CompatAnalyzerTC(CubicWebTC):
             cnx.commit()
             self.assertDiagnostic(doctor, ['SEDA 2.0', 'SEDA 1.0', 'simplified'],
                                   'seda02_custodial_history_when')
 
     def test_archive_unit_reference_in_transfer(self):
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'diagnosis testing')
             create_archive_unit(transfer, archive_unit_reference=True)
 
             doctor = transfer.cw_adapt_to('ISEDACompatAnalyzer')
             cnx.commit()
             self.assertDiagnostic(doctor, ['SEDA 2.0'], 'use_archive_unit_ref')
 
     def test_archive_unit_reference_in_archive_unit(self):
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'diagnosis testing')
             unit, unit_alt, unit_alt_seq = create_archive_unit(transfer)
             create_archive_unit(unit_alt_seq, archive_unit_reference=True)
 
             doctor = transfer.cw_adapt_to('ISEDACompatAnalyzer')
diff --git a/test/test_entities.py b/test/test_entities.py
--- a/test/test_entities.py
+++ b/test/test_entities.py
@@ -50,11 +50,11 @@ class ContainerTC(CubicWebTC):
         entity = self.vreg['etypes'].etype_class('SEDAArchiveTransfer')(self)
         self.assertIsNotNone(entity.cw_adapt_to('IContainer'))
         self.assertIsNone(entity.cw_adapt_to('IContained'))
 
     def test_container_relation(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             create = cnx.create_entity
             transfer = create('SEDAArchiveTransfer', title=u'test profile')
             mtclv = create('SEDAMimeTypeCodeListVersion',
                            seda_mime_type_code_list_version_from=transfer)
             access_rule = create('SEDAAccessRule', seda_access_rule=transfer)
@@ -70,11 +70,11 @@ class ContainerTC(CubicWebTC):
                 entity.cw_clear_all_caches()
                 self.assertEqual(entity.cw_adapt_to('IContained').container.eid, transfer.eid)
 
     def test_archive_unit_container_clone(self):
         """Functional test for SEDA component clone."""
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             unit, unit_alt, unit_alt_seq = create_archive_unit(None, cnx=cnx)
             bdo = create_data_object(unit_alt_seq)
             cnx.commit()
 
             unit.cw_clear_all_caches()
@@ -114,11 +114,11 @@ class ContainerTC(CubicWebTC):
             cloned_bdo.cw_clear_all_caches()
             self.assertEqual(cloned_bdo.seda_binary_data_object[0].eid, transfer.eid)
 
     def test_archive_transfer_clone(self):
         """Functional test for SEDA profile cloning."""
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             scheme = cnx.create_entity('ConceptScheme', title=u'Algorithms')
             concept = scheme.add_concept(u'md5')
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             cnx.create_entity('SEDAMessageDigestAlgorithmCodeListVersion',
                               seda_message_digest_algorithm_code_list_version_from=transfer,
@@ -138,11 +138,11 @@ class ContainerTC(CubicWebTC):
             self.assertEqual(seq.title.title, 'hello')
             self.assertEqual(transfer.binary_data_objects[0].seda_algorithm[0].eid, concept.eid)
 
     def test_container_clone_clone(self):
         """Functional test for SEDA component clone."""
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             unit, unit_alt, unit_alt_seq = create_archive_unit(None, cnx=cnx)
             cnx.commit()
 
             cloned = cnx.create_entity(unit.cw_etype, user_annotation=u'x', clone_of=unit)
             cnx.commit()
@@ -220,11 +220,11 @@ class ITreeTC(CubicWebTC):
         else:
             parent_eid = None
         self.assertEqual(parent_eid, expected_eid)
 
     def test(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             au, alt, seq = create_archive_unit(transfer)
             do_ref = cnx.create_entity('SEDADataObjectReference',
                                        seda_data_object_reference=seq)
             bdo = create_data_object(transfer,
@@ -298,17 +298,17 @@ class ParentAndContainerTC(CubicWebTC):
 
 
 class CustomEntitiesTC(CubicWebTC):
 
     def test_title(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             for etype in ('SEDAArchiveUnit', 'SEDABinaryDataObject', 'SEDAPhysicalDataObject'):
                 ent = cnx.create_entity(etype, user_annotation=u'bla bla\nbli bli blo\n')
                 self.assertEqual(ent.dc_title(), u'bla bla')
 
     def test_climb_rule_holders(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             unit, _, unit_alt_seq = create_archive_unit(transfer)
             subunit, _, subunit_alt_seq = create_archive_unit(unit_alt_seq)
             cnx.commit()
 
diff --git a/test/test_hooks.py b/test/test_hooks.py
--- a/test/test_hooks.py
+++ b/test/test_hooks.py
@@ -25,11 +25,11 @@ from cubicweb_seda import testutils
 class ValidationHooksTC(CubicWebTC):
 
     assertValidationError = testutils.assertValidationError
 
     def test_ref_non_rule_constraints(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             create = cnx.create_entity
 
             access_scheme = create('ConceptScheme', title=u'access')
             access_concept = access_scheme.add_concept(label=u'anyone')
             reuse_scheme = create('ConceptScheme', title=u'reuse')
@@ -59,11 +59,11 @@ class ValidationHooksTC(CubicWebTC):
             non_rule.cw_set(seda_ref_non_rule_id_to=access_concept)
             cnx.commit()
 
     def test_empty_choice_created(self):
         """Check that a ValidationError is raised when an empty SEDAAlt... entity is created."""
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             # Create an empty SEDAAltAccessRulePreventInheritance
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             access_rule = cnx.create_entity('SEDAAccessRule', seda_access_rule=transfer)
             with self.assertValidationError(cnx) as cm:
                 cnx.create_entity('SEDAAltAccessRulePreventInheritance',
@@ -71,11 +71,11 @@ class ValidationHooksTC(CubicWebTC):
             self.assertIn('An alternative cannot be empty',
                           str(cm.exception))
 
     def test_valid_choice_created(self):
         """Check that everything goes fine when a valid SEDAAlt... entity is created."""
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             # Create an empty SEDAArchiveUnit
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             access_rule = cnx.create_entity('SEDAAccessRule', seda_access_rule=transfer)
             choice = cnx.create_entity('SEDAAltAccessRulePreventInheritance',
                                        reverse_seda_alt_access_rule_prevent_inheritance=access_rule)
@@ -85,11 +85,11 @@ class ValidationHooksTC(CubicWebTC):
 
     def test_last_item_in_choice_deleted(self):
         """Check that a ValidationError is raised when the last relation from a SEDAAlt... entity
         is deleted.
         """
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             # Create a valid SEDAAltAccessRulePreventInheritance
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             access_rule = cnx.create_entity('SEDAAccessRule', seda_access_rule=transfer)
             choice = cnx.create_entity('SEDAAltAccessRulePreventInheritance',
                                        reverse_seda_alt_access_rule_prevent_inheritance=access_rule)
@@ -105,11 +105,11 @@ class ValidationHooksTC(CubicWebTC):
 
     def test_item_in_choice_deleted_with_remaining_item(self):
         """Check that everything goes fine when the a relation from a SEDAAlt... entity
         is deleted but another relation remains.
         """
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             # Create a valid SEDAAltAccessRulePreventInheritance with two items
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             access_rule = cnx.create_entity('SEDAAccessRule', seda_access_rule=transfer)
             choice = cnx.create_entity('SEDAAltAccessRulePreventInheritance',
                                        reverse_seda_alt_access_rule_prevent_inheritance=access_rule)
@@ -124,11 +124,11 @@ class ValidationHooksTC(CubicWebTC):
 
 
 class SetDefaultHooksTC(CubicWebTC):
 
     def test_default_code_list_version(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             for rtype, etype in chain(zip(('seda_format_id_to', 'seda_mime_type_to',
                                            'seda_encoding_to'),
                                           repeat(None)),
                                       [('seda_algorithm', 'SEDABinaryDataObject'),
                                        ('seda_rule', 'SEDASeqAppraisalRuleRule'),
@@ -150,11 +150,11 @@ class SetDefaultHooksTC(CubicWebTC):
     def test_default_card_on_typed_data_object_ref(self):
         """When creating a SEDADataObjectReference in the context of a reference, its cardinality
         should always be 1 (by default any card is allowed since in may be used in the context of
         'main' reference).
         """
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(transfer)
             version_of = cnx.create_entity('SEDAIsVersionOf', seda_is_version_of=unit_alt_seq)
             alt2 = cnx.create_entity('SEDAAltIsVersionOfArchiveUnitRefId',
                                      reverse_seda_alt_is_version_of_archive_unit_ref_id=version_of)
@@ -166,11 +166,11 @@ class SetDefaultHooksTC(CubicWebTC):
     def test_simplified_profile_do_ref_sync(self):
         """When creating a SEDABinaryDataObject in a simplified profile from the ui, one only
         specifies user_cardinality for it, not for it's associated reference whose cardinality
         should have the same value.
         """
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile',
                                          simplified_profile=True)
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(transfer)
             bdo = testutils.create_data_object(unit_alt_seq, user_cardinality=u'1',
                                                seda_binary_data_object=transfer)
@@ -189,11 +189,11 @@ class SetDefaultHooksTC(CubicWebTC):
 class CheckProfileTC(CubicWebTC):
 
     assertValidationError = testutils.assertValidationError
 
     def test_base(self):
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'diagnosis testing')
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(transfer)
             access_rule = cnx.create_entity('SEDAAccessRule', seda_access_rule=unit_alt_seq)
             cnx.commit()
 
diff --git a/test/test_html_generation.py b/test/test_html_generation.py
--- a/test/test_html_generation.py
+++ b/test/test_html_generation.py
@@ -30,11 +30,11 @@ AttrDef = namedtuple('AttrDef', ['label'
 class SEDAHTMLExportFuncTC(SEDAExportFuncTCMixIn, XmlTestMixin, CubicWebTC):
     adapter_id = 'SEDA-2.0.html'
 
     def setup_database(self):
         super(SEDAHTMLExportFuncTC, self).setup_database()
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             scheme = cnx.find('ConceptScheme', title=u'Keyword Types').one()
             some_concept = scheme.reverse_in_scheme[0]
             lang_rtype = cnx.find('CWRType', name='seda_language_to').one()
             some_concept.scheme.cw_set(scheme_relation_type=lang_rtype)
             cnx.find('SEDALanguage').one().cw_set(seda_language_to=some_concept)
@@ -65,11 +65,11 @@ class SEDAHTMLExportFuncTC(SEDAExportFun
                     value = span.text
                 el_def[span.attrib['class']] = value
         return el_defs
 
     def test_profile1(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.entity_from_eid(self.transfer_eid)
             some_concept = cnx.entity_from_eid(self.concept_eid)
             profile = self.profile_etree(transfer)
             # ensure encoding is declared
             meta = self.xpath(profile, '/html/head/meta')[0]
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
@@ -220,11 +220,11 @@ class RelaxNGTestMixin(XmlTestMixin):
 
 class PathTargetValuesTC(CubicWebTC):
 
     def test_keyword_path(self):
         element_defs = iter(XSDMMapping('Keyword'))
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             create = cnx.create_entity
             kw = create('SEDAKeyword', user_cardinality=u'0..n')
             kt = create('SEDAKeywordType', seda_keyword_type_from=kw)
 
             edef = next(element_defs)
@@ -281,11 +281,11 @@ class PathTargetValuesTC(CubicWebTC):
             self.assertEqual(target_value[0], None)
             self.assertEqual(target_value[1], None)
 
     def test_internal_reference(self):
         element_defs = iter(XSDMMapping('DataObjectReference'))
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             create = cnx.create_entity
             transfer = create('SEDAArchiveTransfer', title=u'test profile')
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(
                 transfer)
             bdo = cnx.create_entity('SEDABinaryDataObject',
@@ -313,11 +313,11 @@ class PathTargetValuesTC(CubicWebTC):
 
 
 class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
 
     def test_skipped_mandatory_simple(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             profile = self.profile_etree(cnx.create_entity('SEDAArchiveTransfer',
                                                            title=u'test profile'))
             date = self.get_element(profile, 'Date')
             self.assertElementDefinition(date, {'name': 'Date',
                                                 'type': 'xsd:dateTime'})
@@ -334,11 +334,11 @@ class SEDA2RNGExportTC(RelaxNGTestMixin,
                  {'name': 'schemeName', 'use': 'optional', 'type': 'xsd:string'},
                  {'name': 'schemeURI', 'use': 'optional', 'type': 'xsd:anyURI'},
                  {'name': 'schemeVersionID', 'use': 'optional', 'type': 'xsd:token'}])
 
     def test_skipped_mandatory_complex(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             testutils.create_data_object(transfer, filename=u'fixed.txt')
             profile = self.profile_etree(transfer)
             fname = self.get_element(profile, 'Filename')
             self.assertElementDefinition(fname, {'name': 'Filename',
@@ -353,11 +353,11 @@ class SEDA2RNGExportTC(RelaxNGTestMixin,
                                        'type': 'xsd:string'},
                                       {'name': 'uri', 'use': 'optional',
                                        'type': 'xsd:anyURI'}])
 
     def test_fileinfo_card(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             bdo = cnx.create_entity('SEDABinaryDataObject',
                                     user_annotation=u'I am mandatory',
                                     seda_binary_data_object=transfer)
             appname = cnx.create_entity('SEDACreatingApplicationName',
@@ -377,11 +377,11 @@ class SEDA2RNGExportTC(RelaxNGTestMixin,
             profile = self.profile_etree(transfer)
             fileinfo = self.get_element(profile, 'FileInfo')
             self.assertElementDefinition(fileinfo, {'name': 'FileInfo'})
 
     def test_data_object_package_card(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             bdo = cnx.create_entity('SEDABinaryDataObject',
                                     user_annotation=u'I am mandatory',
                                     seda_binary_data_object=transfer)
 
@@ -393,11 +393,11 @@ class SEDA2RNGExportTC(RelaxNGTestMixin,
             profile = self.profile_etree(transfer)
             dop = self.get_element(profile, 'DataObjectPackage')
             self.assertElementDefinition(dop, {'name': 'DataObjectPackage'})
 
     def test_object_package_group(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             bdo = cnx.create_entity('SEDABinaryDataObject',
                                     user_annotation=u'I am number one',
                                     seda_binary_data_object=transfer)
             cnx.create_entity('SEDABinaryDataObject',
@@ -417,30 +417,30 @@ class SEDA2RNGExportTC(RelaxNGTestMixin,
             profile = self.profile_etree(transfer)
             dop = self.get_element(profile, 'DataObjectPackage')
             self.assertEqual(len(self.xpath(dop, './rng:group/*')), 3)
 
     def test_transfer_annotation(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             profile = self.profile_etree(cnx.create_entity('SEDAArchiveTransfer',
                                                            title=u'test profile',
                                                            user_annotation=u'some description'))
             docs = self.xpath(profile, '///xs:documentation')
             self.assertEqual(len(docs), 1)
             self.assertEqual(docs[0].text, 'some description')
 
     def test_transfer_signature(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             cnx.create_entity('SEDASignature', seda_signature=transfer)
             profile = self.profile_etree(transfer)
             signature = self.get_element(profile, 'Signature')
             self.assertElementDefinition(signature, {'name': 'Signature', 'type': 'OpenType',
                                                      'minOccurs': '0'})
             self.assertOpenTypeIsDefined(profile)
 
     def test_keyword(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             create = cnx.create_entity
 
             scheme = testutils.scheme_for_rtype(cnx, 'seda_keyword_type_to', u'theme')
             kw_type = scheme.reverse_in_scheme[0]
 
@@ -499,11 +499,11 @@ class SEDA2RNGExportTC(RelaxNGTestMixin,
             self.assertXSDAttributes(
                 kwr,
                 [{'name': 'schemeURI', 'fixed': scheme.cwuri}])
 
     def test_code_list(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             scheme = cnx.create_entity('ConceptScheme', title=u'Keyword Types')
             cnx.create_entity('SEDAMimeTypeCodeListVersion',
                               seda_mime_type_code_list_version_from=transfer,
                               seda_mime_type_code_list_version_to=scheme)
@@ -524,11 +524,11 @@ class SEDA2RNGExportTC(RelaxNGTestMixin,
                  {'name': 'listSchemeURI', 'use': 'optional', 'type': 'xsd:anyURI'},
                  {'name': 'listURI', 'use': 'optional', 'type': 'xsd:anyURI'},
                  {'name': 'listVersionID', 'use': 'optional', 'type': 'xsd:token'}])
 
     def test_seda2_concept(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             create = cnx.create_entity
             scheme = create('ConceptScheme', title=u'Digest algorithm')
             some_concept = scheme.add_concept(label=u'md5 algorithm', language_code=u'en')
             transfer = create('SEDAArchiveTransfer', title=u'test profile')
             cnx.create_entity('SEDAMessageDigestAlgorithmCodeListVersion',
@@ -560,11 +560,11 @@ class SEDA2RNGExportTC(RelaxNGTestMixin,
     def assertOpenTypeIsDefined(self, profile):
         open_types = self.xpath(profile, '//rng:define[@name="OpenType"]')
         self.assertEqual(len(open_types), 1)
 
     def test_data_duplicates(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(
                 transfer, user_cardinality=u'0..n')
             profile = self.profile_etree(transfer)
             title = self.get_element(profile, 'Title')
@@ -573,11 +573,11 @@ class SEDA2RNGExportTC(RelaxNGTestMixin,
 
 class SEDAExportFuncTCMixIn(object):
     """Test that SEDA profile export works correctly."""
 
     def setup_database(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             create = cnx.create_entity
             scheme = create('ConceptScheme', title=u'Keyword Types')
             # ensure we're able to export concept with unexpected language code
             some_concept = scheme.add_concept(label=u'md5', language_code=u'de')
 
@@ -642,11 +642,11 @@ class SEDAExportFuncTCMixIn(object):
         self.bdo_eid = bdo.eid
         self.au_eid = unit.eid
 
     def test_profile1(self):
         """Check a minimal SEDA profile validating BV2.0_min.xml."""
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             mda_scheme = cnx.find('ConceptScheme', title=u'Keyword Types').one()
             transfer = cnx.entity_from_eid(self.transfer_eid)
             root = self.profile_etree(transfer)
         self.check_xsd_profile(root, self.datapath('BV2.0_min.xml'),
                                mda_scheme_url=mda_scheme.cwuri)
@@ -687,11 +687,11 @@ class SEDARNGExportFuncTC(SEDAExportFunc
         self.assertEqual(set(elmt.attrib['type'] for elmt in ddt), set(['date', 'dateTime']))
 
 
 class OldSEDAExportMixin(object):
     def setup_database(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             create = cnx.create_entity
 
             concepts = {}
             for rtype, etype, value in [
                     ('seda_format_id_to', None, u'fmt/123'),
@@ -806,11 +806,11 @@ class OldSEDAExportMixin(object):
         self.bdo_eid = bdo.eid
         self.file_concept_eid = concepts['file'].eid
         self.agent_eid = agent.eid
 
     def _test_profile(self, adapter_id, expected_file):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.entity_from_eid(self.transfer_eid)
             file_concept = cnx.entity_from_eid(self.file_concept_eid)
             agent = cnx.entity_from_eid(self.agent_eid)
 
             adapter = transfer.cw_adapt_to(adapter_id)
@@ -866,11 +866,11 @@ class OldSEDARNGExportTC(RelaxNGTestMixi
     def test_seda_0_2_rng(self):
         self._test_profile('SEDA-0.2.rng', 'seda_02_export.rng')
 
     def test_seda_0_2_bordereau_ref(self):
         """Check a sample SEDA 0.2 profile validation."""
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             create = cnx.create_entity
 
             transfer = create('SEDAArchiveTransfer', title=u'test profile',
                               simplified_profile=True)
             create('SEDAComment', seda_comment=transfer)
diff --git a/test/test_schema.py b/test/test_schema.py
--- a/test/test_schema.py
+++ b/test/test_schema.py
@@ -26,11 +26,11 @@ from cubicweb_seda import testutils
 class SchemaConceptConstraintsTC(CubicWebTC):
 
     assertValidationError = testutils.assertValidationError
 
     def setup_database(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             mt_scheme = testutils.scheme_for_type(cnx, 'seda_mime_type_to', None)
             mt_concept = mt_scheme.add_concept(label=u'text/plain')
             enc_scheme = testutils.scheme_for_type(cnx, 'seda_encoding_to', None)
             enc_concept = enc_scheme.add_concept(label=u'utf-8')
             cnx.commit()
@@ -38,11 +38,11 @@ class SchemaConceptConstraintsTC(CubicWe
             self.mt_concept = mt_concept.eid
             self.enc_scheme = enc_scheme.eid
             self.enc_concept = enc_concept.eid
 
     def test_code_lists_constraints_simple(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             bdo = testutils.create_transfer_to_bdo(cnx)
             transfer = bdo.container[0]
             cnx.create_entity('SEDAMessageDigestAlgorithmCodeListVersion',
                               seda_message_digest_algorithm_code_list_version_from=transfer,
                               seda_message_digest_algorithm_code_list_version_to=self.enc_scheme)
@@ -68,17 +68,17 @@ class SchemaConceptConstraintsTC(CubicWe
                           seda_mime_type_from=bdo,
                           seda_mime_type_to=self.mt_concept)
         cnx.commit()
 
     def test_archive_transfer_mime_type_constraint(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             bdo = testutils.create_transfer_to_bdo(cnx)
             cnx.commit()  # will setup code list version
             self.assertMimeTypeConcept(bdo)
 
     def test_component_archive_unit_mime_type_constraint(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(None, cnx=cnx)
             bdo = testutils.create_data_object(unit_alt_seq)
             cnx.commit()
             self.assertMimeTypeConcept(bdo)
 
@@ -95,17 +95,17 @@ class SchemaConceptConstraintsTC(CubicWe
                           seda_encoding_from=bdo,
                           seda_encoding_to=self.enc_concept)
         cnx.commit()
 
     def test_archive_transfer_encoding_constraint(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             bdo = testutils.create_transfer_to_bdo(cnx)
             cnx.commit()   # will setup code list version
             self.assertEncodingConcept(bdo)
 
     def test_component_archive_unit_encoding_constraint(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(None, cnx=cnx)
             bdo = testutils.create_data_object(unit_alt_seq)
             cnx.commit()
             self.assertEncodingConcept(bdo)
 
@@ -118,22 +118,22 @@ class SchemaConceptConstraintsTC(CubicWe
 
         bdo.cw_set(seda_algorithm=self.enc_concept)
         cnx.commit()
 
     def test_archive_transfer_digest_algorithm_constraint(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             bdo = testutils.create_transfer_to_bdo(cnx)
             cnx.commit()  # commit first to get the container
             transfer = bdo.container[0]
             cnx.create_entity('SEDAMessageDigestAlgorithmCodeListVersion',
                               seda_message_digest_algorithm_code_list_version_from=transfer,
                               seda_message_digest_algorithm_code_list_version_to=self.enc_scheme)
             cnx.commit()
             self.assertDigestAlgorithmConcept(bdo)
 
     def test_component_archive_unit_digest_algorithm_constraint(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(None, cnx=cnx)
             bdo = testutils.create_data_object(unit_alt_seq)
             bdo_type = cnx.find('CWEType', name=u'SEDABinaryDataObject').one()
             alg_type = cnx.find('CWRType', name=u'seda_algorithm').one()
             cnx.entity_from_eid(self.enc_scheme).cw_set(scheme_entity_type=bdo_type,
@@ -145,11 +145,11 @@ class SchemaConceptConstraintsTC(CubicWe
 class SchemaTC(CubicWebTC):
 
     assertValidationError = testutils.assertValidationError
 
     def test_component_archive_unit_rule_constraint(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             for rule_type in ('access', 'appraisal'):
                 etype = 'SEDASeq{0}RuleRule'.format(rule_type.capitalize())
                 scheme = testutils.scheme_for_type(cnx, 'seda_rule', etype)
                 concept = scheme.add_concept(label=u'whatever')
                 cnx.commit()
@@ -204,11 +204,11 @@ class SchemaTC(CubicWebTC):
             self.assertEqual(rqlexpr2.expression,
                              'NOT EXISTS(X container C), U in_group G, '
                              'G name IN("managers", "users")')
 
     def test_rule_default_cardinality(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             for rule_type in ('access', 'appraisal'):
                 rule_etype = 'SEDA{0}Rule'.format(rule_type.capitalize())
                 rule_rtype = 'seda_{0}_rule'.format(rule_type)
                 rule = cnx.create_entity(rule_etype, **{rule_rtype: transfer})
@@ -220,11 +220,11 @@ class SchemaTC(CubicWebTC):
                 self.assertEqual(start_date.user_cardinality, '1')
 
     def test_fti(self):
         # "Reverse" text to be searched in order not to be troubled by other
         # entities that may live in the DB (e.g. Concepts) with similar text.
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'Profile')
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(
                 transfer, title=u'transfer name'[::-1])
             cnx.create_entity('SEDAAccessRule', seda_access_rule=unit_alt_seq,
                               user_annotation=u'some annotation'[::-1])
@@ -236,11 +236,11 @@ class SchemaTC(CubicWebTC):
                     rset = cnx.execute('Any X WHERE X has_text %(search)s',
                                        {'search': search[::-1]})
                     self.assertEqual([r for r, in rset.rows], [transfer.eid])
 
     def test_scheme_code_keyword_type_constraint(self):
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             ckt_scheme = testutils.scheme_for_type(cnx, 'seda_keyword_type_to', None)
             ckt_concept = ckt_scheme.add_concept(label=u'geoname')
             scheme = testutils.scheme_for_type(cnx, 'seda_mime_type_to', None)
             concept = scheme.add_concept(label=u'text/plain')
             cnx.commit()
@@ -271,14 +271,14 @@ class SecurityTC(CubicWebTC):
         with self.admin_access.cnx() as cnx:
             self.create_user(cnx, login='alice')
             cnx.commit()
 
     def test_profile(self):
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             self.create_user(cnx, login='bob')
             cnx.commit()
-        with self.new_access('alice').repo_cnx() as cnx:
+        with self.new_access('alice').cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'Alice Profile')
             testutils.create_archive_unit(transfer)
             testutils.create_authority_record(cnx, u'Archival inc.',
                                               reverse_seda_archival_agency=transfer)
             cnx.create_entity('SEDAComment', comment=u'Whooot.',
@@ -286,11 +286,11 @@ class SecurityTC(CubicWebTC):
             scheme = cnx.create_entity('ConceptScheme', title=u'Some vocabulary')
             cnx.create_entity('SEDAMimeTypeCodeListVersion',
                               seda_mime_type_code_list_version_from=transfer,
                               seda_mime_type_code_list_version_to=scheme)
             cnx.commit()
-        with self.new_access('bob').repo_cnx() as cnx:
+        with self.new_access('bob').cnx() as cnx:
             transfer = cnx.entity_from_eid(transfer.eid)
             # modification of the container
             with self.assertUnauthorized(cnx):
                 transfer.cw_set(title=u'Bob Profile')
             # modification of a contained entity
@@ -321,20 +321,20 @@ class SecurityTC(CubicWebTC):
             # deletion of the container
             with self.assertUnauthorized(cnx):
                 transfer.cw_delete()
 
     def test_archive_unit(self):
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(None, cnx=cnx)
             cnx.commit()
 
             # unit has no parent, modifications are allowed.
             unit.cw_set(user_annotation=u'argh')
             unit_alt_seq.reverse_seda_title[0].cw_set(title=u'gloup')
             cnx.commit()
 
-        with self.new_access('anon').client_cnx() as cnx:
+        with self.new_access('anon').cnx() as cnx:
             title = cnx.entity_from_eid(unit_alt_seq.reverse_seda_title[0].eid)
             unit = cnx.entity_from_eid(unit.eid)
             with self.assertUnauthorized(cnx):
                 title.cw_set(title=u'zorglub')
             with self.assertUnauthorized(cnx):
@@ -343,11 +343,11 @@ class SecurityTC(CubicWebTC):
                 cnx.create_entity('SEDADescription', seda_description=unit_alt_seq)
             with self.assertUnauthorized(cnx):
                 title.cw_delete()
             with self.assertUnauthorized(cnx):
                 unit.cw_delete()
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             unit = cnx.entity_from_eid(unit.eid)
             unit.cw_delete()
             cnx.commit()
 
     def test_users_can_create_unit(self):
@@ -355,15 +355,15 @@ class SecurityTC(CubicWebTC):
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(None, cnx=cnx)
             cnx.commit()
 
     def test_users_can_clone(self):
         """Functional test for SEDA component clone."""
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(None, cnx=cnx)
             cnx.commit()
 
-        with self.new_access('alice').repo_cnx() as cnx:
+        with self.new_access('alice').cnx() as cnx:
             unit = cnx.entity_from_eid(unit.eid)
             cloned = cnx.create_entity(unit.cw_etype, user_annotation=u'x', clone_of=unit)
             cnx.commit()
             cloned.cw_clear_all_caches()
 
diff --git a/test/test_views.py b/test/test_views.py
--- a/test/test_views.py
+++ b/test/test_views.py
@@ -34,11 +34,11 @@ def entity_fields(fields):
             if field.eidparam and not field.name.startswith('__')]
 
 
 class ManagementRulesTC(CubicWebTC):
     def test_rule_ref_vocabulary(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             create = cnx.create_entity
 
             access_scheme = create('ConceptScheme', title=u'access')
             access_concept = access_scheme.add_concept(label=u'anyone')
             cnx.commit()
@@ -70,11 +70,11 @@ class ManagementRulesTC(CubicWebTC):
             self.assertEqual(mgmt_rules._rule_ref_vocabulary(transfer, rule_alt.cw_etype),
                              [('<no value specified>', '__cubicweb_internal_field__'),
                               (access_concept.label(), text_type(access_concept.eid))])
 
     def test_archive_unit_component_rule_ref_vocabulary(self):
-        with self.admin_access.client_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(None, cnx=cnx)
             for rule_type in ('access', 'appraisal'):
                 etype = 'SEDASeq{0}RuleRule'.format(rule_type.capitalize())
                 scheme = testutils.scheme_for_type(cnx, 'seda_rule', etype)
                 concept = scheme.add_concept(label=u'whatever')
@@ -92,11 +92,11 @@ class PermissionsTC(CubicWebTC):
 
     def test_container_permissions(self):
         """Check that a user cannot edit a SEDA profile he/she did not create."""
         alice_login = 'alice'
         bob_login = 'bob'
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             self.create_user(cnx, login=alice_login)
             self.create_user(cnx, login=bob_login)
             cnx.commit()
         with self.new_access(alice_login).web_request() as req:
             alice_profile = req.create_entity('SEDAArchiveTransfer', title=u'Alice Profile')
@@ -121,11 +121,11 @@ class PermissionsTC(CubicWebTC):
 
 class RelationWidgetTC(CubicWebTC):
     """Functional test case about the relation widget."""
 
     def test_linkable_rset(self):
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'Test widget')
             bdo = cnx.create_entity('SEDABinaryDataObject',
                                     user_annotation=u'I am mandatory',
                                     seda_binary_data_object=transfer)
             bdo_alt = cnx.create_entity('SEDAAltBinaryDataObjectAttachment',
@@ -138,11 +138,11 @@ class RelationWidgetTC(CubicWebTC):
             req.form = {'relation': 'seda_algorithm:Concept:subject',
                         'container': text_type(transfer.eid)}
             view = self.vreg['views'].select('search_related_entities', req,
                                              rset=compressed.as_rset())
             self.failIf(view.linkable_rset())
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             scheme = cnx.create_entity('ConceptScheme', title=u'CompressionAlgorithm')
             scheme.add_concept(label=u'bz2')
             cnx.create_entity('SEDACompressionAlgorithmCodeListVersion',
                               seda_compression_algorithm_code_list_version_from=transfer,
                               seda_compression_algorithm_code_list_version_to=scheme)
@@ -294,11 +294,11 @@ class ArchiveTransferExportTC(CubicWebTC
 
 class SimplifiedFormsTC(CubicWebTC):
     """Functional test case about forms in the web interface."""
 
     def setup_database(self):
-        with self.admin_access.repo_cnx() as cnx:
+        with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'diagnosis testing',
                                          simplified_profile=True)
             archive_unit = testutils.create_archive_unit(transfer)[0]
 
             cnx.commit()


More information about the saem-devel mailing list