def test_login_success(client): username = "******" email = "*****@*****.**" password = "******" signup_user(client=client, username=username, email=email, password=password) response = login_user(client=client, username=username, password=password) assert_success_200(response) data = json.loads(response.data) assert data["token"]
def test_signup_username_already_used(client): username = "******" password = "******" signup_user(client=client, username=username, email="*****@*****.**", password=password) response = signup_user(client=client, username=username, email="*****@*****.**", password=password) assert_error(response, 422) data = json.loads(response.data) assert data["errorCode"] == "INVALID_FIELD" assert "Username is already used" in data["errorMessage"]
def test_login_bad_credentials(client): username = "******" email = "*****@*****.**" password = "******" signup_user(client=client, username=username, email=email, password=password) response = login_user(client=client, username=username, password="******") assert_error(response, 401) data = json.loads(response.data) assert data["errorCode"] == "INVALID_CREDENTIALS" assert not "token" in data
def test_signup_invalid_email(client): response = signup_user( client=client, username="******", email="mailexample.com", password="******", ) assert_error_invalid_field(response, "email")
def test_signup_invalid_username_forbidden_chars(client): response = signup_user( client=client, username="******", email="*****@*****.**", password="******", ) assert_error_invalid_field(response, "username")
def test_signup_success(client): response = signup_user( client=client, username="******", email="*****@*****.**", password="******", ) assert_success_200(response) data = json.loads(response.data) assert data["success"] == True
def test_signup_invalid_password_too_short(client): response = signup_user(client=client, username="******", email="*****@*****.**", password="******") assert_error_invalid_field(response, "password")
def test_signup_invalid_username_too_short(client): response = signup_user(client=client, username="******", email="*****@*****.**", password="******") assert_error_invalid_field(response, "username")
def test_signup_missing_password(client): response = signup_user(client=client, username="******", email="*****@*****.**", password=None) assert_error_missing_field(response, "password")
def test_signup_missing_email(client): response = signup_user(client=client, username="******", email=None, password="******") assert_error_missing_field(response, "email")
def test_signup_missing_username(client): response = signup_user(client=client, username=None, email="*****@*****.**", password="******") assert_error_missing_field(response, "username")