def test_get_cards(self): bid0 = Board.add("board1", "A") lid0 = List.add("List0", bid0) list0 = List.get(lid0) lid1 = List.add("List1", bid0) list1 = List.get(lid1) uid0 = User.add("test1", "password", "*****@*****.**") caid0 = Card.add("card1", lid0, uid0) caid1 = Card.add("card2", lid1, uid0) assert caid0 in [card.id for card in list0.get_cards()] assert caid1 not in [card.id for card in list0.get_cards()]
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_comments_by_card_id(self): uid0 = User.add("test1", "password", "*****@*****.**") bid0 = Board.add("board1", "A") lid0 = List.add("To Do", bid0) caid0 = Card.add("card1", lid0, uid0) caid1 = Card.add("card2", lid0, uid0) coid0 = Comment.add(caid0, uid0, "comment1") coid1 = Comment.add(caid1, uid0, "comment2") comment0 = Comment.get(coid0) comment1 = Comment.get(coid1) assert coid0 in [comment.id for comment in Comment.get_comments_by_card_id(caid0)] assert coid1 not in [comment.id for comment in Comment.get_comments_by_card_id(caid0)]
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()
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 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 test_add_and_get(self): uid0 = User.add("test1", "password", "*****@*****.**") bid0 = Board.add("board1", "A") lid0 = List.add("To Do", bid0) caid0 = Card.add("card1", lid0, uid0) coid0 = Comment.add(caid0, uid0, "comment1") comment0 = Comment.get(coid0) assert caid0 == comment0.card_id assert uid0 == comment0.user_id assert "comment1" == comment0.content
def api_card(list_id = None): if request.method == 'GET': list_id = request.args.get('list_id') if list_id != None: cards = Card.get_cards_by_list_id(list_id) return jsonify(json_list=[card.serialize() for card in cards]) else: return jsonify({'code': 404, 'message': 'Card ID not valid.'}) else: try: list_id = long(request.form['list_id']) title = request.form['title'] except KeyError: return jsonify({'code': 400, 'message': 'Bad Request'}) return jsonify({"card_id": Card.add(title, list_id, current_user.id)})
board1.add_user(user1) user0.add_board(board0) user0.add_board(board1) 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 -*-