Exemplo n.º 1
0
def users() -> List[User]:
    return [
        User.objects.create_user(
            username=f"test{i}", password=generate_password(f"test{i}")
        )
        for i in range(3)
    ]
Exemplo n.º 2
0
def test_get_course_list(client, users, courses):
    user = users[0]

    client.login(username=user.username,
                 password=generate_password(user.username))

    courses_ = [course for course in courses if course.author == user]

    resp = client.get(reverse("course_flow:course-list"))
    data = resp.json()

    assert len(courses_) == len(data["courses"])
    assert all(course.id in (c["id"] for c in data["courses"])
               for course in courses_)
Exemplo n.º 3
0
def test_generate_password():
    username = "******"

    assert len(generate_password(username)) == 64
    assert generate_password(username) == generate_password(username)
    assert generate_password(username) != generate_password(username + "_")
Exemplo n.º 4
0
def user() -> User:
    return User.objects.create_user(username="******",
                                    password=generate_password("test"))