def test_create_user_without_callbackurl(_not_logged_in_client):
    user_name = "demo"
    user = User()
    user.user = user_name
    user.argon_password = "******"
    user.email = "*****@*****.**"
    payload = user.as_dict()
    response = _not_logged_in_client.post("/user",
                                          json=payload,
                                          content_type="application/json")
    assert response.status_code == 400
def test_create_user_with_used_username(_not_logged_in_client):
    user_name = "demo"
    user = User()
    user.user = user_name
    user.argon_password = "******"
    user.email = "*****@*****.**"
    payload = user.as_dict()
    payload["confirmation_url"] = "http://phenopolis.org/confirm/"
    response = _not_logged_in_client.post("/user",
                                          json=payload,
                                          content_type="application/json")
    assert response.status_code == 500
def test_create_user_without_email(_not_logged_in_client):
    user_name = "test_register4"
    with session_scope() as db_session:
        try:
            user = User()
            user.user = user_name
            user.argon_password = "******"
            response = _not_logged_in_client.post(
                "/user", json=user.as_dict(), content_type="application/json")
            assert response.status_code == 400
        finally:
            # cleans the database
            _clean_test_users(db_session, user_name)
def test_create_user_with_used_email(_not_logged_in_client):
    user_name = "test_register5"
    with session_scope() as db_session:
        try:
            user = User()
            user.user = user_name
            user.argon_password = "******"
            user.email = "*****@*****.**"
            payload = user.as_dict()
            payload["confirmation_url"] = "http://phenopolis.org/confirm/"
            response = _not_logged_in_client.post(
                "/user", json=payload, content_type="application/json")
            assert response.status_code == 500
        finally:
            # cleans the database
            _clean_test_users(db_session, user_name)