From f03a0ece33f9dcd0e0918cf4fd1489444ee401dd Mon Sep 17 00:00:00 2001 From: Kostiantyn Stoliarskyi Date: Thu, 20 Apr 2023 16:42:47 +0300 Subject: [PATCH] fix tests --- app/templates/auth/login.html | 15 --------------- tests/conftest.py | 4 ++-- tests/test_auth.py | 6 +++--- tests/utils.py | 2 +- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/app/templates/auth/login.html b/app/templates/auth/login.html index 3a182f0..7cf41ad 100644 --- a/app/templates/auth/login.html +++ b/app/templates/auth/login.html @@ -24,23 +24,8 @@ {{form.password.label(class='block mb-2 text-sm font-medium text-gray-900 dark:text-white')}} {{form.password(class='bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500')}} - -
-
- - -
-
- - -
- - Lost Password? -
- -
Not registered yet?Create account
diff --git a/tests/conftest.py b/tests/conftest.py index b8ad40c..e7c8b55 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,7 +4,7 @@ from flask.testing import FlaskClient from app import create_app, db from app import models as m -from tests.utils import register +from tests.utils import create @pytest.fixture() @@ -27,7 +27,7 @@ def client(app: Flask): db.drop_all() db.create_all() - register() + create() yield client db.session.remove() diff --git a/tests/test_auth.py b/tests/test_auth.py index 2e3713b..64b4ce1 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -1,4 +1,4 @@ -from tests.utils import login +from tests.utils import login, create TEST_EMAIL = "test@gmail.com" @@ -12,11 +12,11 @@ def test_auth_pages(client): def test_login_and_logout(client): # Access to logout view before login should fail. - response = login(client, "sam") + response = login(client) assert b"Login successful." in response.data # Incorrect login credentials should fail. response = login(client, "sam", "wrongpassword") assert b"Wrong user ID or password." in response.data # Correct credentials should login - response = login(client, "sam") + response = login(client) assert b"Login successful." in response.data diff --git a/tests/utils.py b/tests/utils.py index c04ad1b..bda90e5 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -5,7 +5,7 @@ TEST_ADMIN_EMAIL = "bob@test.com" TEST_ADMIN_PASSWORD = "password" -def register( +def create( username=TEST_ADMIN_NAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD ): user = User(username=username, email=email)