Commit e9fb93f8 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

Stop importing testutils functions one by one

use module prefixed style notation.
parent 6b6c20bc189f
......@@ -30,7 +30,7 @@ from cubicweb.devtools.testlib import CubicWebTC
from cubes.seda.xsd2yams import XSDMMapping
from cubes.seda.entities.profile_generation import _path_target_values
from testutils import create_archive_unit, create_data_object, scheme_for_rtype, scheme_for_type
import testutils
class XmlTestMixin(object):
......@@ -255,7 +255,7 @@ class PathTargetValuesTC(CubicWebTC):
self.assertEqual(target_value[0].eid, kt.eid)
self.assertEqual(target_value[1], None)
kt_scheme = scheme_for_rtype(cnx, 'seda_keyword_type_to', u'theme')
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]
......@@ -305,7 +305,7 @@ class SEDA2ExportTCMixIn(object):
def test_skipped_mandatory_complex(self):
with self.admin_access.client_cnx() as cnx:
transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
create_data_object(transfer, id=u"bdo1", filename=u'fixed.txt')
testutils.create_data_object(transfer, id=u"bdo1", filename=u'fixed.txt')
profile = self.profile_etree(transfer)
fname = self.get_element(profile, 'Filename')
self.assertElementDefinition(fname, {'name': 'Filename',
......@@ -367,11 +367,12 @@ class SEDA2ExportTCMixIn(object):
with self.admin_access.client_cnx() as cnx:
create = cnx.create_entity
scheme = scheme_for_rtype(cnx, 'seda_keyword_type_to', u'theme')
scheme = testutils.scheme_for_rtype(cnx, 'seda_keyword_type_to', u'theme')
kw_type = scheme.reverse_in_scheme[0]
transfer = create('SEDAArchiveTransfer', title=u'test profile')
unit, unit_alt, unit_alt_seq = create_archive_unit(transfer, user_cardinality=u'0..n')
unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(
transfer, user_cardinality=u'0..n')
content = create('SEDAContent', seda_content=unit_alt_seq)
kw = create('SEDAKeyword', seda_keyword=content)
create('SEDAKeywordContent', reverse_seda_keyword_content=kw,
......@@ -495,7 +496,7 @@ class SEDA2XSDExportTC(SEDA2ExportTCMixIn, XMLSchemaTestMixin, CubicWebTC):
"""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('Agent', name=u'Archival inc.',
archival_org = cnx.create_entity('AuthorityRecord', name=u'Archival inc.',
reverse_seda_archival_agency=transfer)
profile = self.profile_etree(transfer)
enum_elts = self.xpath(profile,
......@@ -515,7 +516,8 @@ class SEDA2RNGExportTC(SEDA2ExportTCMixIn, RelaxNGTestMixin, CubicWebTC):
def test_data_duplicates(self):
with self.admin_access.client_cnx() as cnx:
transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
unit, unit_alt, unit_alt_seq = create_archive_unit(transfer, user_cardinality=u'0..n')
unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(
transfer, user_cardinality=u'0..n')
content = cnx.create_entity('SEDAContent', seda_content=unit_alt_seq)
cnx.create_entity('SEDATitle', seda_title=content)
profile = self.profile_etree(transfer)
......@@ -541,16 +543,16 @@ class SEDAExportFuncTCMixIn(object):
reverse_seda_seq_access_rule_rule=access_rule)
create('SEDAStartDate', user_cardinality=u'0..1', seda_start_date=access_rule_seq)
# binary data object
bdo = create_data_object(transfer, id=u"bdo1", user_cardinality=u'0..n',
seda_algorithm=some_concept)
bdo = testutils.create_data_object(transfer, id=u"bdo1", user_cardinality=u'0..n',
seda_algorithm=some_concept)
create('SEDAFormatLitteral', seda_format_litteral=bdo)
create('SEDAEncoding', seda_encoding_from=bdo)
create('SEDAUri', seda_uri=bdo.seda_alt_binary_data_object_attachment)
# first level archive unit
unit, unit_alt, unit_alt_seq = create_archive_unit(transfer, user_cardinality=u'0..n',
user_annotation=u'Composant ISAD(G)')
unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(
transfer, user_cardinality=u'0..n', user_annotation=u'Composant ISAD(G)')
# sub archive unit
# create_archive_unit(unit_alt_seq, user_cardinality=u'0..n')
# testutils.create_archive_unit(unit_alt_seq, user_cardinality=u'0..n')
# management
appraisal_rule = create('SEDAAppraisalRule', seda_appraisal_rule=unit_alt_seq)
appraisal_rule_seq = create('SEDASeqAppraisalRuleRule',
......@@ -675,7 +677,7 @@ class OldSEDAExportMixin(object):
('seda_rule', 'SEDASeqAccessRuleRule', u'AR038'),
('seda_final_action', 'SEDAAppraisalRule', u'detruire'),
]:
scheme = scheme_for_type(cnx, rtype, etype, value)
scheme = testutils.scheme_for_type(cnx, rtype, etype, value)
concepts[value] = scheme.reverse_in_scheme[0]
agent = create('Agent', name=u'bob')
......@@ -703,8 +705,8 @@ class OldSEDAExportMixin(object):
seda_seq_appraisal_rule_rule=appraisal_rule_rule,
user_annotation=u'detruire le document')
_, _, unit_alt_seq = create_archive_unit(transfer, id=u'au1',
user_cardinality=u'1..n')
_, _, unit_alt_seq = testutils.create_archive_unit(transfer, id=u'au1',
user_cardinality=u'1..n')
content = create('SEDAContent',
user_cardinality=u'1',
......@@ -739,8 +741,8 @@ class OldSEDAExportMixin(object):
reverse_seda_when=create('SEDAwhen'))
# Add sub archive unit
_, _, subunit_alt_seq = create_archive_unit(unit_alt_seq, id=u'au2',
user_cardinality=u'1..n')
_, _, subunit_alt_seq = testutils.create_archive_unit(unit_alt_seq, id=u'au2',
user_cardinality=u'1..n')
content = create('SEDAContent', seda_content=subunit_alt_seq)
create('SEDATitle', seda_title=content)
......@@ -759,9 +761,9 @@ class OldSEDAExportMixin(object):
# Add minimal document to first level archive
ref = create('SEDADataObjectReference', seda_data_object_reference=unit_alt_seq)
bdo = create_data_object(transfer, id=u"bdo1", user_cardinality=u'0..n',
filename=u'this_is_the_filename.pdf',
reverse_seda_data_object_reference_id=ref)
bdo = testutils.create_data_object(transfer, id=u"bdo1", user_cardinality=u'0..n',
filename=u'this_is_the_filename.pdf',
reverse_seda_data_object_reference_id=ref)
create('SEDAFormatId',
user_cardinality=u'1',
......@@ -773,8 +775,8 @@ class OldSEDAExportMixin(object):
seda_encoding_to=concepts['6'])
# Add another sub archive unit
_, _, subunit2_alt_seq = create_archive_unit(unit_alt_seq, id=u'au3',
user_cardinality=u'1..n')
_, _, subunit2_alt_seq = testutils.create_archive_unit(unit_alt_seq, id=u'au3',
user_cardinality=u'1..n')
content = create('SEDAContent', seda_content=subunit2_alt_seq)
create('SEDATitle', seda_title=content)
......@@ -839,7 +841,7 @@ class OldSEDARNGExportTC(RelaxNGTestMixin, OldSEDAExportMixin, CubicWebTC):
simplified_profile=True)
create('SEDAComment', seda_comment=transfer)
unit, unit_alt, unit_alt_seq = create_archive_unit(transfer)
unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(transfer)
content = create('SEDAContent', seda_content=unit_alt_seq)
create('SEDATitle', seda_title=content)
create('SEDAArchivalAgreement', seda_archival_agreement=transfer)
......@@ -856,7 +858,8 @@ class OldSEDARNGExportTC(RelaxNGTestMixin, OldSEDAExportMixin, CubicWebTC):
reverse_seda_seq_access_rule_rule=access_rule)
create('SEDAStartDate', seda_start_date=access_rule_seq)
subunit, subunit_alt, subunit_alt_seq = create_archive_unit(unit_alt_seq, id=u'subunit')
subunit, subunit_alt, subunit_alt_seq = testutils.create_archive_unit(
unit_alt_seq, id=u'subunit')
subcontent = create('SEDAContent', seda_content=subunit_alt_seq)
create('SEDATitle', seda_title=subcontent)
create('SEDATransferringAgencyArchiveUnitIdentifier',
......@@ -867,7 +870,7 @@ class OldSEDARNGExportTC(RelaxNGTestMixin, OldSEDAExportMixin, CubicWebTC):
create('SEDAKeywordContent', reverse_seda_keyword_content=kw)
create('SEDAKeywordReference', seda_keyword_reference_from=kw)
bdo = create_data_object(transfer)
bdo = testutils.create_data_object(transfer)
create('SEDADataObjectReference',
seda_data_object_reference=subunit_alt_seq,
seda_data_object_reference_id=bdo)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment