def test_get_user_ids(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) assert str(uid0) in [user_id for user_id in card.get_user_ids()]
def test_get_cards_by_list_id(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) assert card_id in [card.id for card in Card.get_cards_by_list_id(lid0)]
def test_get_and_test_description(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.set_description('desc') assert 'desc' in card.get_description()
def test_set_and_get_card(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) assert card.title == 'card0' assert card.list_id == lid0
def get_version(db_conn, kind, id_): if kind == 'card': card = Card.get(db_conn, id=id_) return flip_card_into_kind(card) elif kind == 'unit': return Unit.get(db_conn, id=id_) elif kind == 'set': return Set.get(db_conn, id=id_)
def get_version(kind, id_): if kind == 'card': return Card.get(id=id_) # TODO-1 This needs to also get the right card kind... elif kind == 'unit': return Unit.get(id=id_) elif kind == 'set': return Set.get(id=id_)
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 api_get_card(card_id = None): if card_id == None: return jsonify({'code': 400, 'message': 'Bad Request'}) else: card = Card.get(long(card_id)) if card == None: return jsonify({'code': 404, 'message': 'Page Not Found'}) _list = List.get(card.list_id) return render_template('card.html', card=card, list=_list, edit_card_desc_form=EditCardDescForm(), add_comment_form=AddCommentForm());
def api_edit_card(card_id = None): if card_id == None: return jsonify({'code': 400, 'message': 'Bad Request'}) else: card = Card.get(long(card_id)) if card == None: return jsonify({'code': 404, 'message': 'Page Not Found'}) try: desc = request.form['desc'] card.set_description(desc) except KeyError: return jsonify({'code': 400, 'message': 'Bad Request'}) return jsonify({'code': 200, 'card_id':card_id})
def api_add_comment(card_id=None): if card_id == None: return jsonify({'code': 400, 'message': 'Bad Request'}) else: card = Card.get(long(card_id)) if card == None: return jsonify({'code': 404, 'message': 'Page Not Found'}) try: content = request.form['comment'] except: return jsonify({'code': 400, 'message': 'Bad Request'}) comment = Comment.add(long(card_id), current_user.id, content) return jsonify({'card_id': card_id})
def test_add_and_get_cards(self): uid0 = User.add("test_user1", "password", "*****@*****.**") user0 = User.get(uid0) uid1 = User.add("test_user2", "password", "*****@*****.**") user1 = User.get(uid1) bid0 = Board.add("board1", "A") lid0 = List.add("List0", bid0) caid0 = Card.add("card1", lid0, uid0) caid1 = Card.add("card2", lid0, uid1) card0 = Card.get(caid0) print caid0, user0.get_card_ids() assert str(caid0) in user0.get_card_ids() assert str(caid1) not in user0.get_card_ids()
user1.add_board(board0) user1.add_board(board1) user2.add_board(board0) user0.set_avatar('http://127.0.0.1:5000/_uploads/images/avatar_1.png') user1.set_avatar('http://127.0.0.1:5000/_uploads/images/avatar_2.png') lid0 = List.add("To Do", bid0) lid1 = List.add("Doing", bid0) lid2 = List.add("Done", bid0) caid0 = Card.add("card1", lid0, uid0) caid1 = Card.add("card2", lid0, uid0) caid2 = Card.add("card3", lid1, uid0) card0 = Card.get(caid0) card0.add_user(user1) card0.add_user(user2) coid0 = Comment.add(caid0, uid0, "comment1") coid1 = Comment.add(caid0, uid1, "comment2") coid2 = Comment.add(caid0, uid2, "comment3") ''' # -*- coding: utf-8 -*- from __future__ import absolute_import from models.user import User from models.board import Board from models.list import List