Spaces:
Runtime error

File size: 1,537 Bytes
ed0b977
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from main import app

def verify_login():
    with app.test_client() as client:
        # Test 1: Successful Login
        response = client.post('/login/patient', data={
            'name': 'Darshan',
            'password': 'password'
        }, follow_redirects=True)
        
        response_text = response.data.decode('utf-8')
        if "Patient login successful!" in response_text:
            print("PASS: Login successful with correct credentials.")
        else:
            print("FAIL: Login failed with correct credentials.")
            
        # Test 2: Whitespace Handling (should pass now)
        response = client.post('/login/patient', data={
            'name': '  Darshan  ',
            'password': '  password  '
        }, follow_redirects=True)
        
        response_text = response.data.decode('utf-8')
        if "Patient login successful!" in response_text:
            print("PASS: Login successful with whitespace inputs.")
        else:
            print("FAIL: Login failed with whitespace inputs.")
            
        # Test 3: Wrong Password (logging check)
        response = client.post('/login/patient', data={
            'name': 'Darshan',
            'password': 'wrongpassword'
        }, follow_redirects=True)
        
        if "Invalid credentials" in response.data.decode('utf-8'):
            print("PASS: Login failed correctly with wrong password.")
        else:
             print("FAIL: Wrong password did not trigger error.")

if __name__ == "__main__":
    verify_login()