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
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
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
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
def test_ok(self): assert Comment.add(blog_ident=self.bid)
def setUp(self): Comment.delete_all() Blog.delete_all() self.bid = Blog.add(title=u'foo').ident
def test_ARFKE(self): Comment.add(blog_ident='abcdefg')
def test_ARNFKE_with_fk_exc(self): Comment.add(blog_ident='abcdefg')
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)
def setUp(self): Comment.delete_all() Blog.delete_all()