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

[test] Extract a separate fixture for test related to concept scheme constraints

parent 49d12f273da2
......@@ -24,29 +24,32 @@ from cubicweb.schema import ERQLExpression, RRQLExpression
import testutils
class SchemaTC(CubicWebTC):
def test_code_lists_constraints_simple(self):
class SchemaConceptConstraintsTC(CubicWebTC):
def setup_database(self):
with self.admin_access.client_cnx() as cnx:
create = cnx.create_entity
digest_scheme = create('ConceptScheme', title=u'Digest algorithms')
digest_concept = digest_scheme.add_concept(label=u'md5')
reply_scheme = create('ConceptScheme', title=u'Reply code algorithms')
reply_concept = reply_scheme.add_concept(label=u'ok')
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()
self.mt_scheme = mt_scheme.eid
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:
bdo = testutils.create_transfer_to_bdo(cnx)
bdo.container[0].cw_set(seda_reply_code_list_version=reply_scheme,
seda_message_digest_algorithm_code_list_version=digest_scheme)
bdo.container[0].cw_set(seda_reply_code_list_version=self.mt_scheme,
seda_message_digest_algorithm_code_list_version=self.enc_scheme)
cnx.commit()
bdo.cw_set(seda_algorithm=reply_concept)
bdo.cw_set(seda_algorithm=self.mt_concept)
with self.assertRaises(ValidationError) as cm:
cnx.commit()
self.assertIn('seda_algorithm-subject', cm.exception.errors)
bdo.cw_set(seda_algorithm=digest_concept)
bdo.cw_set(seda_algorithm=self.enc_concept)
cnx.commit()
def test_code_lists_constraints_complex(self):
......@@ -73,6 +76,9 @@ class SchemaTC(CubicWebTC):
create('SEDAMimeType', seda_mime_type_from=bdo, seda_mime_type_to=mt_concept)
cnx.commit()
class SchemaTC(CubicWebTC):
def test_component_archive_unit_rule_constraint(self):
with self.admin_access.client_cnx() as cnx:
for rule_type in ('access', 'appraisal'):
......
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