# retoor <retoor@molodetz.nl>

import time
import requests
from tests.conftest import BASE_URL
def _session_validation():
    s = requests.Session()
    name = f"val_{int(time.time() * 1000)}"
    s.post(
        f"{BASE_URL}/auth/signup",
        data={
            "username": name,
            "email": f"{name}@t.dev",
            "password": "secret123",
            "confirm_password": "secret123",
            "birth_date": "1990-01-01",
            "accept_terms": "1",
        },
        allow_redirects=True,
    )
    return s


def test_signup_short_username_rerenders_with_message(app_server):
    r = requests.post(
        f"{BASE_URL}/auth/signup",
        data={
            "username": "ab",
            "email": "x@y.zz",
            "password": "secret123",
            "confirm_password": "secret123",
            "birth_date": "1990-01-01",
            "accept_terms": "1",
        },
        allow_redirects=False,
    )
    assert r.status_code == 400
    assert "Username must be between 3 and 32 characters" in r.text
