Пример #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
Пример #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
Пример #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
Пример #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
Пример #5
0
 def test_ok(self):
     assert Comment.add(blog_ident=self.bid)
Пример #6
0
 def setUp(self):
     Comment.delete_all()
     Blog.delete_all()
     self.bid = Blog.add(title=u'foo').ident
Пример #7
0
 def test_ARFKE(self):
     Comment.add(blog_ident='abcdefg')
Пример #8
0
 def test_ARNFKE_with_fk_exc(self):
     Comment.add(blog_ident='abcdefg')
Пример #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)
Пример #10
0
 def setUp(self):
     Comment.delete_all()
     Blog.delete_all()