Exemplo n.º 1
0
 def test_fk_prevent_insert(self):
     try:
         Comment.add(blog_ident=10000)
         assert False, 'expected FK exception'
     except Exception as e:
         db.sess.rollback()
         if not is_fk_exc(e, 'blog_ident', 'ident'):
             raise
Exemplo n.º 2
0
 def test_fk_prevent_parent_delete(self):
     b = Blog.add(title=u'foo')
     Comment.add(blog_ident=b.ident)
     try:
         Blog.delete(b.id)
         assert False, 'expected FK exception'
     except Exception as e:
         db.sess.rollback()
         if not is_fk_exc(e, 'blog_ident', 'ident'):
             raise
Exemplo n.º 3
0
 def test_fk_prevent_parent_update(self):
     if db.engine.dialect.name == 'sqlite':
         # not supported by SQLiteFKTG4SA
         # http://code.google.com/p/sqlitefktg4sa/issues/detail?id=3
         raise SkipTest
     b = Blog.add(title=u'foo')
     Comment.add(blog_ident=b.ident)
     b.ident = u'12345'
     try:
         db.sess.commit()
         assert False, 'expected FK exception'
     except Exception as e:
         db.sess.rollback()
         if not is_fk_exc(e, 'blog_ident', 'ident'):
             raise
Exemplo n.º 4
0
 def test_fk_prevent_update(self):
     c = Comment.add(blog_ident=self.bid)
     c.blog_ident = 10000
     try:
         db.sess.commit()
         assert False, 'expected FK exception'
     except Exception as e:
         db.sess.rollback()
         if not is_fk_exc(e, 'blog_ident', 'ident'):
             raise
Exemplo n.º 5
0
 def test_ok(self):
     assert Comment.add(blog_ident=self.bid)
Exemplo n.º 6
0
 def setUp(self):
     Comment.delete_all()
     Blog.delete_all()
     self.bid = Blog.add(title=u'foo').ident
Exemplo n.º 7
0
 def test_ARFKE(self):
     Comment.add(blog_ident='abcdefg')
Exemplo n.º 8
0
 def test_ARNFKE_with_fk_exc(self):
     Comment.add(blog_ident='abcdefg')
Exemplo n.º 9
0
 def test_ARNFKE_with_either_exc(self):
     # this test will generate the FK exception for SQLite
     # but a NULL exception for other DBs
     Comment.add(blog_ident=None)
Exemplo n.º 10
0
 def setUp(self):
     Comment.delete_all()
     Blog.delete_all()