Commit 58ab3723 authored by Cornee Traas's avatar Cornee Traas
Browse files

FIx failing tests

parent ac942fad
......@@ -140,12 +140,18 @@ def test_user_viewset_create(admin_api_client, course, role):
@pytest.mark.django_db
@pytest.mark.parametrize("role", [User.TEACHER, User.QDT])
def test_user_viewset_user_is_not_a_superuser(admin_api_client, role):
def test_user_viewset_user_is_not_a_superuser(admin_api_client, role, course):
"""
Test that a new user with a non-admin role is not a superuser.
"""
response = admin_api_client.post(
reverse("users-api:user-list"), {"email": "new@example.com", "role": role}
reverse("users-api:user-list"),
{
"email": "new@example.com",
"role": role,
"courses": [CourseSerializer(course).data],
},
format="json",
)
assert response.status_code == 201, response.content
user = User.objects.get(pk=response.data["pk"])
......@@ -161,7 +167,8 @@ def test_user_viewset_create_admin(admin_api_client):
"""
response = admin_api_client.post(
reverse("users-api:user-list"),
{"email": "admin2@example.com", "role": User.ADMIN},
{"email": "admin2@example.com", "role": User.ADMIN, "courses": []},
format="json",
)
assert response.status_code == 201, response.content
user = User.objects.get(pk=response.data["pk"])
......@@ -258,11 +265,19 @@ def test_user_viewset_full_update(admin_api_client, teacher, course):
@pytest.mark.django_db
def test_create_user_send_email(admin_api_client, mailoutbox):
def test_create_user_send_email(admin_api_client, course, mailoutbox):
"""
Test that creating a user sends an activation email.
"""
admin_api_client.post(reverse("users-api:user-list"), {"email": "new@example.com"})
admin_api_client.post(
reverse("users-api:user-list"),
{
"email": "new@example.com",
"role": User.TEACHER,
"courses": [CourseSerializer(course).data],
},
format="json",
)
assert len(mailoutbox) == 1, "no mails sent"
m = mailoutbox[0]
assert m.subject == "An account has been created", "subject does not match"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment