50 class RepositoryTC(CubicWebTC): |
50 class RepositoryTC(CubicWebTC): |
51 """ singleton providing access to a persistent storage for entities |
51 """ singleton providing access to a persistent storage for entities |
52 and relation |
52 and relation |
53 """ |
53 """ |
54 |
54 |
55 def test_uniquetogether(self): |
55 def test_unique_together_constraint(self): |
56 self.execute('INSERT Societe S: S nom "Logilab", S type "SSLL", S cp "75013"') |
56 self.execute('INSERT Societe S: S nom "Logilab", S type "SSLL", S cp "75013"') |
57 with self.assertRaises(ValidationError) as wraperr: |
57 with self.assertRaises(ValidationError) as wraperr: |
58 self.execute('INSERT Societe S: S nom "Logilab", S type "SSLL", S cp "75013"') |
58 self.execute('INSERT Societe S: S nom "Logilab", S type "SSLL", S cp "75013"') |
59 self.assertEqual({'nom': u'violates unique_together constraints (cp, nom, type)', |
59 self.assertEqual( |
60 'cp': u'violates unique_together constraints (cp, nom, type)', |
60 {'cp': u'cp is part of violated unicity constraint', |
61 'type': u'violates unique_together constraints (cp, nom, type)'}, |
61 'nom': u'nom is part of violated unicity constraint', |
62 wraperr.exception.args[1]) |
62 'type': u'type is part of violated unicity constraint', |
63 |
63 'unicity constraint': u'some relations violate a unicity constraint'}, |
64 def test_unique_together(self): |
64 wraperr.exception.args[1]) |
|
65 |
|
66 def test_unique_together_schema(self): |
65 person = self.repo.schema.eschema('Personne') |
67 person = self.repo.schema.eschema('Personne') |
66 self.assertEqual(len(person._unique_together), 1) |
68 self.assertEqual(len(person._unique_together), 1) |
67 self.assertItemsEqual(person._unique_together[0], |
69 self.assertItemsEqual(person._unique_together[0], |
68 ('nom', 'prenom', 'inline2')) |
70 ('nom', 'prenom', 'inline2')) |
69 |
71 |