72 (u'Date',), (u'Datetime',), |
72 (u'Date',), (u'Datetime',), |
73 (u'Decimal',),(u'Float',), |
73 (u'Decimal',),(u'Float',), |
74 (u'Int',), |
74 (u'Int',), |
75 (u'Interval',), (u'Password',), |
75 (u'Interval',), (u'Password',), |
76 (u'String',), (u'Time',)]) |
76 (u'String',), (u'Time',)]) |
|
77 sql = ("SELECT etype.cw_eid, etype.cw_name, cstr.cw_eid, rel.eid_to " |
|
78 "FROM cw_CWUniqueTogetherConstraint as cstr, " |
|
79 " relations_relation as rel, " |
|
80 " cw_CWEType as etype " |
|
81 "WHERE cstr.cw_eid = rel.eid_from " |
|
82 " AND cstr.cw_constraint_of = etype.cw_eid " |
|
83 " AND etype.cw_name = 'Personne' " |
|
84 ";") |
|
85 cu = self.session.system_sql(sql) |
|
86 rows = cu.fetchall() |
|
87 self.assertEquals(len(rows), 3) |
|
88 self.test_unique_together() |
77 finally: |
89 finally: |
78 self.repo.set_schema(origshema) |
90 self.repo.set_schema(origshema) |
|
91 |
|
92 def test_unique_together(self): |
|
93 person = self.repo.schema.eschema('Personne') |
|
94 self.assertEquals(len(person._unique_together), 1) |
|
95 self.assertUnorderedIterableEquals(person._unique_together[0], |
|
96 ('nom', 'prenom', 'inline2')) |
79 |
97 |
80 def test_schema_has_owner(self): |
98 def test_schema_has_owner(self): |
81 repo = self.repo |
99 repo = self.repo |
82 cnxid = repo.connect(self.admlogin, password=self.admpassword) |
100 cnxid = repo.connect(self.admlogin, password=self.admpassword) |
83 self.failIf(repo.execute(cnxid, 'CWEType X WHERE NOT X owned_by U')) |
101 self.failIf(repo.execute(cnxid, 'CWEType X WHERE NOT X owned_by U')) |
383 rset = self.execute('Any P WHERE A todo_by P, A eid %(x)s', |
401 rset = self.execute('Any P WHERE A todo_by P, A eid %(x)s', |
384 {'x': note.eid}) |
402 {'x': note.eid}) |
385 self.assertEquals(len(rset), 1) |
403 self.assertEquals(len(rset), 1) |
386 self.assertEquals(rset.rows[0][0], p2.eid) |
404 self.assertEquals(rset.rows[0][0], p2.eid) |
387 |
405 |
|
406 def test_delete_if_object_inlined_singlecard(self): |
|
407 req = self.request() |
|
408 c = req.create_entity('Card', title=u'Carte') |
|
409 req.create_entity('Personne', nom=u'Vincent', fiche=c) |
|
410 req.create_entity('Personne', nom=u'Florent', fiche=c) |
|
411 self.commit() |
|
412 self.assertEquals(len(c.reverse_fiche), 1) |
388 |
413 |
389 def test_set_attributes_in_before_update(self): |
414 def test_set_attributes_in_before_update(self): |
390 # local hook |
415 # local hook |
391 class DummyBeforeHook(Hook): |
416 class DummyBeforeHook(Hook): |
392 __regid__ = 'dummy-before-hook' |
417 __regid__ = 'dummy-before-hook' |