Beispiel #1
0
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
Beispiel #2
0
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
Beispiel #3
0
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."
Beispiel #4
0
def test_insert_vote_with_invalid_number_1(test_db):
    (data, code) = Lupi.insert_vote('X', 'a')
    assert code == 412
    assert data == "Invalid number."
Beispiel #5
0
def test_insert_vote_without_name(test_db):
    (data, code) = Lupi.insert_vote('', 1)
    assert code == 412
    assert data == "Name is required."
Beispiel #6
0
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."
Beispiel #7
0
def test_insert_vote_without_active_round(test_db):
    (data, code) = Lupi.insert_vote('A', 1)
    assert code == 404
    assert data == "No active round."
Beispiel #8
0
def vote(vote):
    name = vote.get("name")
    number = vote.get("number")

    return Lupi.insert_vote(name, number)