Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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."
Ejemplo n.º 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."
Ejemplo n.º 5
0
def test_insert_vote_without_name(test_db):
    (data, code) = Lupi.insert_vote('', 1)
    assert code == 412
    assert data == "Name is required."
Ejemplo n.º 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."
Ejemplo n.º 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."
Ejemplo n.º 8
0
def vote(vote):
    name = vote.get("name")
    number = vote.get("number")

    return Lupi.insert_vote(name, number)