1 # -*- coding: utf-8 -*- |
1 # -*- coding: utf-8 -*- |
2 """functional tests for core hooks |
2 """functional tests for core hooks |
3 |
3 |
4 note: most schemahooks.py hooks are actually tested in unittest_migrations.py |
4 note: most schemahooks.py hooks are actually tested in unittest_migrations.py |
|
5 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
5 """ |
6 """ |
6 |
7 |
7 from logilab.common.testlib import TestCase, unittest_main |
8 from logilab.common.testlib import TestCase, unittest_main |
8 from cubicweb.devtools.apptest import RepositoryBasedTC, get_versions |
9 from cubicweb.devtools.apptest import RepositoryBasedTC, get_versions |
9 |
10 |
452 self.failUnless(self.index_exists('Affaire', 'sujet', unique=True)) |
453 self.failUnless(self.index_exists('Affaire', 'sujet', unique=True)) |
453 self.commit() |
454 self.commit() |
454 self.failIf(self.schema['Affaire'].has_unique_values('sujet')) |
455 self.failIf(self.schema['Affaire'].has_unique_values('sujet')) |
455 self.failIf(self.index_exists('Affaire', 'sujet', unique=True)) |
456 self.failIf(self.index_exists('Affaire', 'sujet', unique=True)) |
456 |
457 |
|
458 def test_required_change_1(self): |
|
459 self.execute('SET DEF cardinality "?1" ' |
|
460 'WHERE DEF relation_type RT, DEF from_entity E,' |
|
461 'RT name "nom", E name "Personne"') |
|
462 self.commit() |
|
463 # should now be able to add personne without nom |
|
464 self.execute('INSERT Personne X') |
|
465 self.commit() |
|
466 |
|
467 def test_required_change_2(self): |
|
468 self.execute('SET DEF cardinality "11" ' |
|
469 'WHERE DEF relation_type RT, DEF from_entity E,' |
|
470 'RT name "prenom", E name "Personne"') |
|
471 self.commit() |
|
472 # should not be able anymore to add personne without prenom |
|
473 self.assertRaises(ValidationError, self.execute, 'INSERT Personne X: X nom "toto"') |
|
474 |
457 |
475 |
458 class WorkflowHooksTC(RepositoryBasedTC): |
476 class WorkflowHooksTC(RepositoryBasedTC): |
459 |
477 |
460 def setUp(self): |
478 def setUp(self): |
461 RepositoryBasedTC.setUp(self) |
479 RepositoryBasedTC.setUp(self) |