Complete the code to check if the login function returns True for valid credentials.
assert login('user1', 'password123') == [1]
The login function should return True when the credentials are correct, so the assertion checks for that.
Complete the code to test that the login function raises an exception for empty username.
with pytest.raises([1]): login('', 'password123')
The login function should raise a ValueError when the username is empty, indicating invalid input.
Fix the error in the test that checks login failure with wrong password.
assert login('user1', [1]) == False
The test should use a wrong password like 'wrongpass' to check that login fails and returns False.
Fill both blanks to create a test that checks if the login function rejects SQL injection attempts.
assert login([1], [2]) == False
The username is 'admin' and the password is an SQL injection string ' OR '1'='1'. The test checks that login rejects this attack and returns False.
Fill all three blanks to create a test that verifies the lockout after 3 failed login attempts.
for _ in range([1]): assert login('user2', [2]) == False assert login('user2', [3]) == 'locked'
The test tries to login 3 times with a wrong password 'wrongpass' and expects failure. Then it tries again and expects the account to be 'locked'.