コード例 #1
0
def _(browser=browser):
    content = ContentFactory.create(name="Introdução ao Flask")

    browser.visit(url_for("contents.show", content_slug=content.slug))

    assert browser.is_text_present(content.author.name)
    assert browser.is_text_present(content.author.description)
コード例 #2
0
def _(browser=browser):
    content = ContentFactory.create(name="Introdução ao Flask")

    browser.visit(url_for("contents.show", content_slug=content.slug))
    timestamp = format_datetime(content.updated_on, "medium")
    assert browser.is_text_present(
        f"O conteúdo apresentado foi atualizado em {timestamp} e poderá ser modificado a qualquer momento sem aviso prévio."
    )
コード例 #3
0
def _(browser=browser):
    content = ContentFactory.create(name="Introdução ao Flask")

    browser.visit(url_for("home.index"))
    browser.find_by_text(content.name).first.click()

    assert browser.url == f"/conteudo/{content.slug}"
    assert browser.status_code.is_success()
    assert browser.is_text_present(content.name)
コード例 #4
0
def _(browser=browser):
    s = Source(name="Apostila de flask", link="https://negros.dev/apostila-flask.pdf")
    s2 = Source(name="Apostila de flask", link="https://negros.dev/apostila-flask.pdf")

    content = ContentFactory.create(name="Introdução ao Flask", sources=[s, s2])

    browser.visit(url_for("contents.show", content_slug=content.slug))

    assert browser.is_text_present(s.name)
    assert browser.is_text_present(s2.name)
コード例 #5
0
def _(browser=browser):
    user = UserFactory.create(password="******", role=ERole.ADMIN)

    browser.visit(url_for("auth.login"))
    browser.fill("email", user.email)
    browser.fill("password", "admin1254")
    browser.find_by_value("Entrar").click()

    assert browser.is_text_present(user.email)
    assert browser.is_text_present("sair")
コード例 #6
0
def _(browser=browser):
    contents = ContentFactory.create_batch(10)

    content_found = contents[5]

    browser.visit(url_for("home.index"))
    browser.find_by_name("content_name").fill(content_found.name)
    browser.find_by_value("BUSCAR").click()

    assert browser.is_text_present(content_found.name)
コード例 #7
0
def _(browser=browser):
    user = UserFactory.create(password="******", role=ERole.ADMIN)

    browser.visit(url_for("auth.login"))
    browser.fill("email", user.email)
    browser.fill("password", "admin1254")
    browser.find_by_value("Entrar").click()

    browser.visit(url_for("auth.login"))

    assert browser.url == "http://localhost/"
コード例 #8
0
def _(browser=browser):
    user = UserFactory.create(password="******", role=ERole.STAFF)

    browser.visit(url_for("auth.login"))
    browser.fill("email", user.email)
    browser.fill("password", "admin1254")
    browser.find_by_value("Entrar").click()
    browser.visit(url_for("admin.index"))

    assert browser.status_code.code == 403
    assert browser.is_text_present(
        "você não possui acesso suficiente para acessar está página."
    )
コード例 #9
0
def _(browser=browser):
    content1 = ContentFactory.create(
        created_on=datetime.strptime("08/10/21 08:00", "%d/%m/%y %H:%M"))
    content2 = ContentFactory.create(
        created_on=datetime.strptime("10/10/21 21:23", "%d/%m/%y %H:%M"))
    content3 = ContentFactory.create(
        created_on=datetime.strptime("11/10/21 10:35", "%d/%m/%y %H:%M"))
    content4 = ContentFactory.create(
        created_on=datetime.strptime("08/10/21 11:11", "%d/%m/%y %H:%M"))

    browser.visit(url_for("home.index"))

    assert content1.name in str(
        browser.find_by_css("#contents > ol > li:nth-child(1)").first.text)
    assert content4.name in str(
        browser.find_by_css("#contents > ol > li:nth-child(2)").first.text)
    assert content2.name in str(
        browser.find_by_css("#contents > ol > li:nth-child(3)").first.text)
    assert content3.name in str(
        browser.find_by_css("#contents > ol > li:nth-child(4)").first.text)
コード例 #10
0
def _(browser=browser):
    content = ContentFactory.create(name="Testando aplicações flask")

    browser.visit(url_for("home.index"))

    assert browser.is_text_present(content.name)
コード例 #11
0
def _(browser=browser):
    browser.visit(url_for("home.index"))

    assert browser.url == "/"
    assert browser.status_code.is_success()
    assert browser.is_text_present("Conteúdos em vídeos")