コード例 #1
0
def test_execucao_sem_parametro():
    """Testa se home é executado através da função rotear depois de mapeado
    para o path '/' """
    @rota('/')
    def home():
        return 'home executada'

    assert home() == rotear('/') == 'home executada'
コード例 #2
0
def test_rota_inexistente():
    with pytest.raises(RotaInexistente) as excinfo:
        rotear('/inexistente')

    assert str(excinfo.value) == 'Rota inexistente: /inexistente'
コード例 #3
0
def test_parametros_errados():
    with pytest.raises(TypeError):
        rotear('/carro')
コード例 #4
0
def test_execucao_com_parametro_posicional_e_nomeado():
    assert carro('Celta', 99) == rotear(
        '/carro', 'Celta', 99) == 'Celta ano 99'
コード例 #5
0
def test_execucao_com_parametros_nomeados():
    assert carro('Gol', 2000) == rotear(
        '/carro', ano=2000, nome='Gol') == 'Gol ano 2000'
コード例 #6
0
def test_execucao_com_parametros_posicionais():
    assert carro('Fusca', 88) == rotear(
        '/carro', 'Fusca', 88) == 'Fusca ano 88'
コード例 #7
0
def test_execucao_com_parametro_nomeado():
    assert usuario('Foo') == rotear('/usuario', nome='Foo') == 'salvando Foo'
コード例 #8
0
def test_execucao_com_parametro_posicional():
    assert usuario('Renzo') == rotear('/usuario', 'Renzo') == 'salvando Renzo'