Mmaiqai.com
🔐 Automation Testing · Chương 11 · Mục 11.2

AUTH-01: đăng nhập đúng

Tạo file tests/test_03_auth.py:

FILE tests/test_03_auth.py
"""Bo test day du cho POST /auth - theo bang test case AUTH-01..05 o docs/test-cases-restful-booker.md."""
 
 
def test_auth_01_dung_username_va_password(api_context):
"""AUTH-01: dung username + password -> HTTP 200, body co token."""
response = api_context.post("/auth", data={"username": "admin", "password": "password123"})
assert response.status == 200 # dang nhap dung phai tra HTTP 200
assert "token" in response.json() # body phai co token