# Path: x509_pki/tests/factories.py
# class CertificateFactory(DjangoModelFactory):
#     class Meta:
#         model = Certificate
#         strategy = BUILD_STRATEGY
# 
#     type = CertificateTypes.ROOT
#     name = fake.sentence(nb_words=6, variable_nb_words=True)
#     dn = factory.LazyFunction(DistinguishedNameFactory)
#     parent = None
#     owner = factory.LazyFunction(UserFactory.default)
#     crl_distribution_url = "https://example.com/crl/cert.crl.pem"
#     ocsp_distribution_host = "https://example.com/ocsp/"
# 
#     created_at = factory.LazyFunction(lambda: arrow.get(timezone.now()).date())
#     expires_at = factory.LazyFunction(lambda: arrow.get(timezone.now()).shift(days=+1).date())
#     revoked_at = None
# 
# class DistinguishedNameFactory(DjangoModelFactory):
#     class Meta:
#         model = DistinguishedName
# 
#     countryName = factory.Faker("country_code")
#     stateOrProvinceName = factory.Faker("state")
#     localityName = factory.Faker("city")
#     organizationName = factory.Faker("company")
#     organizationalUnitName = fake.sentence(nb_words=3, variable_nb_words=True)
#     emailAddress = factory.Faker("email")
#     commonName = factory.Faker("domain_name")
#     subjectAltNames = factory.List([factory.Faker("domain_name") for _ in range(random.randint(1, 5))])
# 
# class UserFactory(DjangoModelFactory):
#     class Meta:
#         model = User
# 
#     email = factory.Faker("email")
#     username = factory.Faker("domain_word")
#     password = factory.PostGenerationMethodCall("set_password", "user123")
# 
#     first_name = factory.Faker("first_name")
#     last_name = factory.Faker("last_name")
# 
#     is_superuser = False
#     is_staff = False
#     is_active = True
# 
#     @classmethod
#     def default(cls):
#         try:
#             user = User.objects.get(username="jeroen")
#         except ObjectDoesNotExist:
#             user = UserFactory.create(username="jeroen")
#         return user


from django.test import TestCase
from x509_pki.tests.factories import CertificateFactory, DistinguishedNameFactory, UserFactory
# coding: utf-8



class FactoriesTest(TestCase):
    """
    Very simple tests to ensure the factories work as expected.
    """

    def test_user_factory(self):
        user = UserFactory()
        self.assertIsNotNone(user.username)
        self.assertIsNotNone(user.password)
        self.assertIsNotNone(user.first_name)
        self.assertIsNotNone(user.last_name)
        self.assertFalse(user.is_superuser)
        self.assertFalse(user.is_staff)
        self.assertTrue(user.is_active)

    def test_distinguished_name_factory(self):

# Path: x509_pki/tests/factories.py
# class CertificateFactory(DjangoModelFactory):
#     class Meta:
#         model = Certificate
#         strategy = BUILD_STRATEGY
# 
#     type = CertificateTypes.ROOT
#     name = fake.sentence(nb_words=6, variable_nb_words=True)
#     dn = factory.LazyFunction(DistinguishedNameFactory)
#     parent = None
#     owner = factory.LazyFunction(UserFactory.default)
#     crl_distribution_url = "https://example.com/crl/cert.crl.pem"
#     ocsp_distribution_host = "https://example.com/ocsp/"
# 
#     created_at = factory.LazyFunction(lambda: arrow.get(timezone.now()).date())
#     expires_at = factory.LazyFunction(lambda: arrow.get(timezone.now()).shift(days=+1).date())
#     revoked_at = None
# 
# class DistinguishedNameFactory(DjangoModelFactory):
#     class Meta:
#         model = DistinguishedName
# 
#     countryName = factory.Faker("country_code")
#     stateOrProvinceName = factory.Faker("state")
#     localityName = factory.Faker("city")
#     organizationName = factory.Faker("company")
#     organizationalUnitName = fake.sentence(nb_words=3, variable_nb_words=True)
#     emailAddress = factory.Faker("email")
#     commonName = factory.Faker("domain_name")
#     subjectAltNames = factory.List([factory.Faker("domain_name") for _ in range(random.randint(1, 5))])
# 
# class UserFactory(DjangoModelFactory):
#     class Meta:
#         model = User
# 
#     email = factory.Faker("email")
#     username = factory.Faker("domain_word")
#     password = factory.PostGenerationMethodCall("set_password", "user123")
# 
#     first_name = factory.Faker("first_name")
#     last_name = factory.Faker("last_name")
# 
#     is_superuser = False
#     is_staff = False
#     is_active = True
# 
#     @classmethod
#     def default(cls):
#         try:
#             user = User.objects.get(username="jeroen")
#         except ObjectDoesNotExist:
#             user = UserFactory.create(username="jeroen")
#         return user


# Path: x509_pki/tests/test_factories.py
from django.test import TestCase
from x509_pki.tests.factories import CertificateFactory, DistinguishedNameFactory, UserFactory

# coding: utf-8



class FactoriesTest(TestCase):
    """
    Very simple tests to ensure the factories work as expected.
    """

    def test_user_factory(self):
        user = UserFactory()
        self.assertIsNotNone(user.username)
        self.assertIsNotNone(user.password)
        self.assertIsNotNone(user.first_name)
        self.assertIsNotNone(user.last_name)
        self.assertFalse(user.is_superuser)
        self.assertFalse(user.is_staff)
        self.assertTrue(user.is_active)

    def test_distinguished_name_factory(self):

        dn = DistinguishedNameFactory()