server/test/unittest_repository.py
branchstable
changeset 6208 07b176640a8c
parent 6188 e1c9610b2360
child 6225 a176e68b7d0d
child 6236 9138f23ee263
--- a/server/test/unittest_repository.py	Fri Sep 10 15:09:31 2010 +0200
+++ b/server/test/unittest_repository.py	Fri Sep 10 16:48:58 2010 +0200
@@ -74,9 +74,27 @@
                                               (u'Int',),
                                               (u'Interval',), (u'Password',),
                                               (u'String',), (u'Time',)])
+            sql = ("SELECT etype.cw_eid, etype.cw_name, cstr.cw_eid, rel.eid_to "
+                   "FROM cw_CWUniqueTogetherConstraint as cstr, "
+                   "     relations_relation as rel, "
+                   "     cw_CWEType as etype "
+                   "WHERE cstr.cw_eid = rel.eid_from "
+                   "  AND cstr.cw_constraint_of = etype.cw_eid "
+                   "  AND etype.cw_name = 'Personne' "
+                   ";")
+            cu = self.session.system_sql(sql)
+            rows = cu.fetchall()
+            self.assertEquals(len(rows), 3)
+            self.test_unique_together()
         finally:
             self.repo.set_schema(origshema)
 
+    def test_unique_together(self):
+        person = self.repo.schema.eschema('Personne')
+        self.assertEquals(len(person._unique_together), 1)
+        self.assertUnorderedIterableEquals(person._unique_together[0],
+                                           ('nom', 'prenom', 'inline2'))
+
     def test_schema_has_owner(self):
         repo = self.repo
         cnxid = repo.connect(self.admlogin, password=self.admpassword)