39 lines
893 B
Python
39 lines
893 B
Python
import pytest
|
|
from fasthtml.fastapp import fast_app
|
|
|
|
from myfasthtml.auth.routes import setup_auth_routes
|
|
from myfasthtml.auth.utils import create_auth_beforeware
|
|
from myfasthtml.core.testclient import MyTestClient
|
|
|
|
|
|
@pytest.fixture()
|
|
def app():
|
|
beforeware = create_auth_beforeware()
|
|
test_app, test_rt = fast_app(before=beforeware)
|
|
setup_auth_routes(test_app, test_rt)
|
|
return test_app
|
|
|
|
|
|
@pytest.fixture()
|
|
def rt(app):
|
|
return app.route
|
|
|
|
|
|
@pytest.fixture()
|
|
def user(app):
|
|
user = MyTestClient(app)
|
|
return user
|
|
|
|
def test_i_can_see_login_page(user):
|
|
user.open("/login")
|
|
user.should_see("Sign In")
|
|
user.should_see("Register here")
|
|
|
|
def test_i_cannot_login_with_wrong_credentials(user):
|
|
user.open("/login")
|
|
user.fill_form({
|
|
"username": "wrong",
|
|
"password": ""
|
|
})
|
|
user.click("button")
|
|
user.should_see("Invalid credentials") |