def test_insert_vote_draw(test_db): (data, code) = Lupi.insert_vote('A', 3) assert code == 201 assert data["round_id"] == 2 (data, code) = Lupi.insert_vote('B', 5) assert code == 201 assert data["round_id"] == 2 (data, code) = Lupi.insert_vote('C', 3) assert code == 201 assert data["round_id"] == 2 (data, code) = Lupi.insert_vote('D', 5) assert code == 201 assert data["round_id"] == 2
def test_insert_vote(test_db): (data, code) = Lupi.insert_vote('A', 3) assert code == 201 assert data["round_id"] == 1 (data, code) = Lupi.insert_vote('B', 5) assert code == 201 assert data["round_id"] == 1 (data, code) = Lupi.insert_vote('C', 3) assert code == 201 assert data["round_id"] == 1 (data, code) = Lupi.insert_vote('D', 4) assert code == 201 assert data["round_id"] == 1 (data, code) = Lupi.insert_vote('E', 2) assert code == 201 assert data["round_id"] == 1 (data, code) = Lupi.insert_vote('F', 6) assert code == 201 assert data["round_id"] == 1
def test_insert_vote_with_invalid_number_2(test_db): (data, code) = Lupi.insert_vote('X', -1) assert code == 412 assert data == "The number must be a positive integer."
def test_insert_vote_with_invalid_number_1(test_db): (data, code) = Lupi.insert_vote('X', 'a') assert code == 412 assert data == "Invalid number."
def test_insert_vote_without_name(test_db): (data, code) = Lupi.insert_vote('', 1) assert code == 412 assert data == "Name is required."
def test_insert_vote_with_used_name(test_db): (data, code) = Lupi.insert_vote('A', 1) assert code == 412 assert data == "The given name is used in this round."
def test_insert_vote_without_active_round(test_db): (data, code) = Lupi.insert_vote('A', 1) assert code == 404 assert data == "No active round."
def vote(vote): name = vote.get("name") number = vote.get("number") return Lupi.insert_vote(name, number)