(tests) fix tests after adding slugs to domains

- slug readonly on admin
- fix test to expect slug in payload, when retrieving a domain
This commit is contained in:
Marie PUPO JEAMMET
2024-06-19 16:48:07 +02:00
committed by Sebastien Nobour
parent 93d4abee58
commit 19c36eafde
5 changed files with 24 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ Unit tests for the MailDomain model
"""
from django.core.exceptions import ValidationError
from django.utils.text import slugify
import pytest
@@ -10,7 +11,6 @@ from mailbox_manager import factories
pytestmark = pytest.mark.django_db
# NAME FIELD
@@ -24,3 +24,11 @@ def test_models_mail_domain__domain_name_should_not_be_null():
"""The domain name field should not be null."""
with pytest.raises(ValidationError, match="This field cannot be null."):
factories.MailDomainFactory(name=None)
def test_models_mail_domain__slug_inferred_from_name():
"""Passed slug is ignored. Slug is automatically generated from name."""
name = "N3w_D0main-Name$.com"
domain = factories.MailDomainFactory(name=name, slug="something else")
assert domain.slug == slugify(name)