Spaces:
Runtime error
Runtime error
Download tests/verify_login.py from Darshankumarr03/Swift-Query: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/spaces/Darshankumarr03/Swift-Query/resolve/main/tests/verify_login.py
- Command line
-
hf download hf://spaces/Darshankumarr03/Swift-Query/tests/verify_login.py
-
curl -L -o verify_login.py https://huggingface.co/spaces/Darshankumarr03/Swift-Query/resolve/main/tests/verify_login.py
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() | |