Пример #1
0
    def test_board(self):

        q = BoardQuery().get_all_boards()
        r = Database().run_query(q)
        self.assertEqual(r, [])

        bid1 = str(uuid.uuid1())
        q = BoardQuery().create_board({'id': bid1, 'title': 'Board#1'})
        Database().run_query(q)

        bid2 = str(uuid.uuid1())
        q = BoardQuery().create_board({'id': bid2, 'title': 'Board#2'})
        Database().run_query(q)

        q = BoardQuery().get_all_boards()
        r = Database().run_query(q)
        self.assertEqual(len(r), 2)

        q = BoardQuery().update_board({'title': 'Board#3'}, bid2)
        Database().run_query(q)
        q = BoardQuery().get_board_by_id(bid2)
        r = Database().run_query(q)
        self.assertEqual(r[0]['id'], bid2)
        self.assertEqual(r[0]['title'], 'Board#3')

        q = BoardQuery().delete_board(bid2)
        Database().run_query(q)
        q = BoardQuery().get_board_by_id(bid2)
        r = Database().run_query(q)
        self.assertEqual(r, [])
        q = BoardQuery().get_all_boards()
        r = Database().run_query(q)
        self.assertEqual(len(r), 1)
Пример #2
0
def delete_card(id):

	query = CardQuery().get_card_by_id(id)
	card = Database().run_query(query)
	if not card:
		abort(404)

	query = CardQuery().delete_card(id)
	Database().run_query(query)

	return "Delete successful"
Пример #3
0
def get_list(id):
    query = Query().get_list_by_id(id)
    list = Database().run_query(query)

    if not list:
        abort(404)

    query = CardQuery().get_list_cards(id)
    list[0]['cards'] = Database().run_query(query)

    return jsonify({'lists': list})
Пример #4
0
def delete_list(id):
    query = Query().get_list_by_id(id)
    list = Database().run_query(query)

    if not list:
        abort(404)

    query = Query().delete_list(id)
    Database().run_query(query)

    return "Delete successful"
Пример #5
0
def get_board(id):
    query = BoardQuery().get_board_by_id(id)
    board = Database().run_query(query)

    if not board:
        abort(404)

    query = Query().get_board_lists(id)
    lists = Database().run_query(query)
    for l in lists:
        query = CardQuery().get_list_cards(l['id'])
        l['cards'] = Database().run_query(query)

    board[0]['lists'] = lists
    return jsonify({'boards': board})
Пример #6
0
def create_board():
    data = request.get_json() or {}

    if 'title' not in data:
        abort(400)

    cid = str(uuid.uuid1())
    data['id'] = cid

    query = BoardQuery().create_board(data)
    Database().run_query(query)

    query = BoardQuery().get_board_by_id(cid)
    board = Database().run_query(query)

    return jsonify({'boards': board}), 201
Пример #7
0
def create_list():
    data = request.get_json() or {}

    if 'title' not in data or 'board_id' not in data:
        abort(400)

    cid = str(uuid.uuid1())
    data['id'] = cid

    query = Query().add_list(data)
    Database().run_query(query)

    query = Query().get_list_by_id(cid)
    list = Database().run_query(query)

    return jsonify({'lists': list}), 201
Пример #8
0
def create_card():

	data = request.get_json() or {}

	if 'title' not in data or 'list_id' not in data:
		abort(400)

	cid = str(uuid.uuid1())
	data['id'] = cid

	query = CardQuery().add_card(data)
	Database().run_query(query)

	query = CardQuery().get_card_by_id(cid)
	card = Database().run_query(query)

	return jsonify({'cards': card}), 201
Пример #9
0
def get_card(id):
	query = CardQuery().get_card_by_id(id)
	card = Database().run_query(query)

	if not card:
		abort(404)

	return jsonify({'cards': card})
Пример #10
0
def update_card(id):

	data = request.get_json() or {}
	if not data:
		abort(400)

	query = CardQuery().get_card_by_id(id)
	card = Database().run_query(query)

	if not card:
		abort(404)

	query = CardQuery().edit_card(data, id)
	Database().run_query(query)

	query = CardQuery().get_card_by_id(id)
	card = Database().run_query(query)

	return jsonify({'cards': card})
Пример #11
0
def update_board(id):
    data = request.get_json() or {}

    if not data:
        abort(400)

    query = BoardQuery().get_board_by_id(id)
    board = Database().run_query(query)

    if not board:
        abort(404)

    query = BoardQuery().update_board(data, id)
    Database().run_query(query)

    query = BoardQuery().get_board_by_id(id)
    board = Database().run_query(query)

    return jsonify({'boards': board})
Пример #12
0
def update_list(id):
    data = request.get_json() or {}

    if not data:
        abort(400)

    query = Query().get_list_by_id(id)
    list = Database().run_query(query)

    if not list:
        abort(404)

    query = Query().edit_list(data, id)
    Database().run_query(query)

    query = Query().get_list_by_id(id)
    list = Database().run_query(query)

    return jsonify({'lists': list})
Пример #13
0
def get_cards():
	query = CardQuery().get_all_cards()
	cards = Database().run_query(query)

	return jsonify({'cards': cards})
Пример #14
0
def get_boards():
    query = BoardQuery().get_all_boards()
    boards = Database().run_query(query)

    return jsonify({'boards': boards})
Пример #15
0
 def tearDown(self):
     Database().run_query("DROP TABLE card")
     Database().run_query("DROP TABLE list")
     Database().run_query("DROP TABLE board")
     Database().close_connection()