def test_method_is_expired(self): creation = date.today() - timedelta(days=361) expiration = date.today() - timedelta(days=1) domain = DomainFactory(creation=creation, expiration=expiration, auto_renew=False) try: self.assertEqual(True, domain.is_expired()) domain.auto_renew = True domain.save() self.assertEqual(False, domain.is_expired()) domain.expiration = date.today() + timedelta(days=1) domain.save() self.assertEqual(False, domain.is_expired()) except Exception: self.fail("Domain model `is_expired` method failed unexpectedly!")
def test_crud(self): # Create domain = DomainFactory(name="ghostwriter.wiki") # Read self.assertEqual(domain.name, "ghostwriter.wiki") self.assertEqual(domain.pk, domain.id) self.assertQuerysetEqual( self.Domain.objects.all(), [f"<Domain: {domain.name} ({domain.health_status})>"], ) # Update domain.name = "SpecterOps. io" domain.save() self.assertEqual(domain.name, "specterops.io") # Delete domain.delete() assert not self.Domain.objects.all().exists()