Exemplo n.º 1
0
def test_ignored_page(server):
    """ Should raise IgnoredURL if Ignored """
    address = server.router({
        '^/$': Page("").exists(),
    })

    l = Link(address)
    assert l.status == Status.UNDEFINED
    l.status = Status.IGNORED
    assert l.status == Status.IGNORED
    with pytest.raises(DeadlinksIgnoredURL):
        l.exists()

    with pytest.raises(TypeError):
        l.status = 3
Exemplo n.º 2
0
def test_existing_page(server):
    """ emulating slow server (responds after 1s) """

    address = server.router({
        '^/$': Page("").slow().exists(),
    })

    l = Link(address)
    assert l.status == Status.UNDEFINED
    assert l.exists()
    l.status = Status.FOUND
    assert l.exists()

    with pytest.raises(TypeError):
        l.status = 1
Exemplo n.º 3
0
def test_not_existing_page(server):
    """ emulating slow broken server """

    address = server.router({
        '^/$': Page("").unlock_after(3).slow().exists(),
    })

    l = Link(address)
    assert l.status == Status.UNDEFINED

    # timed out
    assert not l.exists(retries=2)
    # setting new status
    l.status = Status.NOT_FOUND

    # page is unlocked, but response is cached!
    assert not l.exists()

    with pytest.raises(TypeError):
        l.status = 2
Exemplo n.º 4
0
def test_redirected_page(server):
    """ Should raise IgnoredURL if Ignored """
    address = server.router({
        '^/$': Page("").redirects(pattern="https://example.com/?%s"),
    })

    l = Link(address)
    assert l.status == Status.UNDEFINED
    with pytest.raises(DeadlinksRedirectionURL):
        l.exists()

    with pytest.raises(TypeError):
        l.status = 0