def incr_decr_get_comment(self): uid0 = User.add("test1", "password", "*****@*****.**") bid0 = Board.add("board1", "A") lid0 = List.add("To Do", bid0) card_id = Card.add("card0", lid0, uid0) card = Card.get(card_id) Card.incr_comment(card_id) assert 1 == card.get_comment_count() Card.desc_comment(card_id) assert 0 == card.get_comment_count()
def add(cls, card_id, user_id, content): comment = cls(card_id = card_id, user_id = user_id, content = content) from models.card import Card Card.incr_comment(card_id) try: mysql_session.add(comment) mysql_session.commit() except Exception as e: mysql_session.rollback() print "error in mysql commit:", e raise finally: mysql_session.close() return comment.id