Skip to content

Commit e3e633d

Browse files
committed
Changed skipif condition and split a test
1 parent 3a005f4 commit e3e633d

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

tests/test_registration.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import sys
12
import time
23
from unittest.mock import Mock, patch
34

45
from flask.testing import FlaskClient
56
import pytest
67

7-
from lms.lmsweb import config_file
88
from lms.lmsweb.config import CONFIRMATION_TIME, MAIL_DEFAULT_SENDER
99
from lms.lmsdb.models import User
1010
from lms.models.users import generate_user_token
@@ -135,7 +135,11 @@ def test_expired_token(client: FlaskClient):
135135

136136
@staticmethod
137137
@pytest.mark.skipif(
138-
condition=not config_file.is_file(),
138+
condition=(
139+
sys.platform != 'darwin'
140+
and sys.platform != 'linux'
141+
and sys.platform != 'win32'
142+
),
139143
reason='should run with configuration file and correct mail info',
140144
)
141145
def test_successful_registration(client: FlaskClient, captured_templates):

tests/test_users.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ def test_forgot_my_password_invalid_mail(
122122
assert template.name == "resetpassword.html"
123123

124124
@staticmethod
125-
def test_forgot_my_password(client: FlaskClient, captured_templates):
125+
def test_forgot_my_password_invalid_recover(
126+
client: FlaskClient, captured_templates,
127+
):
126128
user = conftest.create_student_user(index=1)
127129
client.post('/reset-password', data={
128130
'email': user.mail_address,
@@ -146,6 +148,16 @@ def test_forgot_my_password(client: FlaskClient, captured_templates):
146148
template, _ = captured_templates[-1]
147149
assert template.name == "recoverpassword.html"
148150

151+
@staticmethod
152+
def test_forgot_my_password(client: FlaskClient, captured_templates):
153+
user = conftest.create_student_user(index=1)
154+
client.post('/reset-password', data={
155+
'email': user.mail_address,
156+
}, follow_redirects=True)
157+
template, _ = captured_templates[-1]
158+
assert template.name == "login.html"
159+
160+
token = generate_user_token(user)
149161
client.post(f'/recover-password/{user.id}/{token}', data={
150162
'password': 'new pass',
151163
'confirm': 'new pass',

0 commit comments

Comments
 (0)