Skip to content

Commit 3a005f4

Browse files
committed
Added skipif for sending mail test and split a test function
1 parent ee88ddd commit 3a005f4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

tests/test_registration.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from flask.testing import FlaskClient
55
import pytest
66

7+
from lms.lmsweb import config_file
78
from lms.lmsweb.config import CONFIRMATION_TIME, MAIL_DEFAULT_SENDER
89
from lms.lmsdb.models import User
910
from lms.models.users import generate_user_token
@@ -133,6 +134,10 @@ def test_expired_token(client: FlaskClient):
133134
assert success_login_response.status_code == 200
134135

135136
@staticmethod
137+
@pytest.mark.skipif(
138+
condition=not config_file.is_file(),
139+
reason='should run with configuration file and correct mail info',
140+
)
136141
def test_successful_registration(client: FlaskClient, captured_templates):
137142
conftest.enable_mail_sending()
138143
client.post('/signup', data={

tests/test_users.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,18 @@ def test_valid_change_password(captured_templates):
112112
assert check_logout_response.status_code == 302
113113

114114
@staticmethod
115-
def test_forgot_my_password(client: FlaskClient, captured_templates):
116-
user = conftest.create_student_user(index=1)
115+
def test_forgot_my_password_invalid_mail(
116+
client: FlaskClient, captured_templates,
117+
):
117118
client.post('/reset-password', data={
118119
'email': 'fake-mail@mail.com',
119120
}, follow_redirects=True)
120121
template, _ = captured_templates[-1]
121122
assert template.name == "resetpassword.html"
122123

124+
@staticmethod
125+
def test_forgot_my_password(client: FlaskClient, captured_templates):
126+
user = conftest.create_student_user(index=1)
123127
client.post('/reset-password', data={
124128
'email': user.mail_address,
125129
}, follow_redirects=True)

0 commit comments

Comments
 (0)