Пример #1
0
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"]
Пример #2
0
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"]
Пример #3
0
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
Пример #4
0
def test_signup_invalid_email(client):
    response = signup_user(
        client=client,
        username="******",
        email="mailexample.com",
        password="******",
    )
    assert_error_invalid_field(response, "email")
Пример #5
0
def test_signup_invalid_username_forbidden_chars(client):
    response = signup_user(
        client=client,
        username="******",
        email="*****@*****.**",
        password="******",
    )
    assert_error_invalid_field(response, "username")
Пример #6
0
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
Пример #7
0
def test_signup_invalid_password_too_short(client):
    response = signup_user(client=client,
                           username="******",
                           email="*****@*****.**",
                           password="******")
    assert_error_invalid_field(response, "password")
Пример #8
0
def test_signup_invalid_username_too_short(client):
    response = signup_user(client=client,
                           username="******",
                           email="*****@*****.**",
                           password="******")
    assert_error_invalid_field(response, "username")
Пример #9
0
def test_signup_missing_password(client):
    response = signup_user(client=client,
                           username="******",
                           email="*****@*****.**",
                           password=None)
    assert_error_missing_field(response, "password")
Пример #10
0
def test_signup_missing_email(client):
    response = signup_user(client=client,
                           username="******",
                           email=None,
                           password="******")
    assert_error_missing_field(response, "email")
Пример #11
0
def test_signup_missing_username(client):
    response = signup_user(client=client,
                           username=None,
                           email="*****@*****.**",
                           password="******")
    assert_error_missing_field(response, "username")