corrige conflitos

This commit is contained in:
Junior
2025-03-06 12:10:17 -03:00
parent e952388d57
commit d3081f81f3
113 changed files with 4447 additions and 0 deletions

View File

@ -0,0 +1,35 @@
"""Module for all Form Tests."""
from django.utils.translation import gettext_lazy as _
from diários_oficiais_alems.users.forms import UserAdminCreationForm
from diários_oficiais_alems.users.models import User
class TestUserAdminCreationForm:
"""
Test class for all tests related to the UserAdminCreationForm
"""
def test_username_validation_error_msg(self, user: User):
"""
Tests UserAdminCreation Form's unique validator functions correctly by testing:
1) A new user with an existing username cannot be added.
2) Only 1 error is raised by the UserCreation Form
3) The desired error message is raised
"""
# The user already exists,
# hence cannot be created.
form = UserAdminCreationForm(
{
"username": user.username,
"password1": user.password,
"password2": user.password,
},
)
assert not form.is_valid()
assert len(form.errors) == 1
assert "username" in form.errors
assert form.errors["username"][0] == _("This username has already been taken.")