-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_authentication.py
More file actions
42 lines (30 loc) · 1.4 KB
/
test_authentication.py
File metadata and controls
42 lines (30 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import unittest
from app import app
class TestDataProcessing(unittest.TestCase):
def setUp(self):
app.testing = True
self.app = app.test_client()
def test_login_valid_credentials(self):
# Arrange
email = "test@example.com"
password = "password12345"
# Act
response = self.app.post("/login/", data=dict(email=email, password=password), follow_redirects=True)
# Assert
self.assertEqual(response.status_code, 200) # Перевірка, що статус-код 200 (OK)
self.assertEqual(response.request.path, "/login/") # Перевірка, що відбулося перенаправлення на "/login/"
class TestRegistration(unittest.TestCase):
def setUp(self):
app.testing = True
self.app = app.test_client()
def test_register_valid_credentials(self):
# Arrange
email = "test@example.com"
password = "password12345"
# Act
response = self.app.post("/register/", data=dict(email=email, password=password), follow_redirects=True)
# Assert
self.assertEqual(response.status_code, 200) # Перевірка, що статус-код 200 (OK)
self.assertEqual(response.request.path, "/register/") # Перевірка, що відбулося перенаправлення на "/register/"
if __name__ == "__main__":
unittest.main()