# Path: post_office/admin.py
# class EmailTemplateAdminForm(forms.ModelForm):
#     language = forms.ChoiceField(
#         choices=settings.LANGUAGES,
#         required=False,
#         label=_("Language"),
#         help_text=_("Render template in alternative language"),
#     )
# 
#     class Meta:
#         model = EmailTemplate
#         fields = ['name', 'description', 'subject', 'content', 'html_content', 'language',
#                   'default_template']
# 
#     def __init__(self, *args, **kwargs):
#         instance = kwargs.get('instance')
#         super().__init__(*args, **kwargs)
#         if instance and instance.language:
#             self.fields['language'].disabled = True


from django.forms import formset_factory
from django.test import TestCase, Client
from django.contrib.auth import get_user_model
from django.urls import reverse
from post_office.admin import EmailTemplateAdminForm



User = get_user_model()


class EmailTemplateFormTest(TestCase):
    def setUp(self) -> None:
        self.form_set = formset_factory(EmailTemplateAdminForm,
                                        extra=2)
        self.client = Client()
        self.user = User.objects.create_superuser(username='testuser', password='abc123456', email="testemail@test.com")
        self.client.force_login(self.user)


# Path: post_office/admin.py
# class EmailTemplateAdminForm(forms.ModelForm):
#     language = forms.ChoiceField(
#         choices=settings.LANGUAGES,
#         required=False,
#         label=_("Language"),
#         help_text=_("Render template in alternative language"),
#     )
# 
#     class Meta:
#         model = EmailTemplate
#         fields = ['name', 'description', 'subject', 'content', 'html_content', 'language',
#                   'default_template']
# 
#     def __init__(self, *args, **kwargs):
#         instance = kwargs.get('instance')
#         super().__init__(*args, **kwargs)
#         if instance and instance.language:
#             self.fields['language'].disabled = True


# Path: post_office/tests/test_forms.py
from django.forms import formset_factory
from django.test import TestCase, Client
from django.contrib.auth import get_user_model
from django.urls import reverse
from post_office.admin import EmailTemplateAdminForm




User = get_user_model()


class EmailTemplateFormTest(TestCase):
    def setUp(self) -> None:
        self.form_set = formset_factory(EmailTemplateAdminForm,
                                        extra=2)
        self.client = Client()
        self.user = User.objects.create_superuser(username='testuser', password='abc123456', email="testemail@test.com")
        self.client.force_login(self.user)


    def test_can_create_a_email_template_with_the_same_attributes(self):