import httpx
import time

def test_login(email, password, expected_message):
    start = time.time()
    try:
        r = httpx.post("http://localhost:8002/api/v1/auth/login/", json={
            "email": email,
            "password": password
        }, timeout=10.0)
        dur = time.time() - start
        print(f"Testing {email} / {password} (took {dur:.2f}s):")
        print(f"  Status: {r.status_code}")
        print(f"  Response: {r.json()}")
        msg = r.json().get("message")
        if msg == expected_message:
            print("  => SUCCESS")
        else:
            print(f"  => FAIL (expected: '{expected_message}')")
    except Exception as e:
        print(f"  => ERROR: {e}")

print("--- Running Login Error Tests ---")
# Case 1: Both email and password are wrong
test_login("nonexistent@test.com", "completelywrongpass", "Invalid credentials")

# Case 2: Email does not exist, but password matches a registered user's password
test_login("nonexistent@test.com", "Admin@123", "Email does not exist")

# Case 3: Email exists, but password is wrong
test_login("kunal.verma@indovisionservices.in", "completelywrongpass", "Incorrect password")
