Swift-Query / tests /verify_login.py
Darshan Kumar R
Deploy to Hugging Face Spaces (Clean)
ed0b977
Raw History Blame Contribute Delete
1.54 kB
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()