# Path: planb/factories.py
# class BackupRunFactory(DjangoModelFactory):
#     fileset = factory.SubFactory(FilesetFactory)
# 
#     duration = factory.Faker('pyint')
#     success = factory.Faker('pybool')
#     total_size_mb = factory.Faker('pyint')
# 
#     @factory.lazy_attribute
#     def snapshot_size_mb(self):
#         return random.randint(0, self.total_size_mb)
# 
#     attributes = 'do_snapshot_size_listing: false'
#     snapshot_size_listing = ''
# 
#     class Meta:
#         model = 'planb.BackupRun'
# 
# class FilesetFactory(DjangoModelFactory):
#     host_prefix = factory.Faker('hostname', levels=0)
#     host_suffix = factory.Faker('domain_word')
#     tld = factory.Faker('tld')
# 
#     @factory.lazy_attribute
#     def friendly_name(self):
#         # Set friendly name as the full hostname within the hostgroup domain.
#         return '.'.join((
#             self.host_prefix, self.host_suffix, self.hostgroup.name, self.tld))
# 
#     storage_alias = 'dummy'
#     hostgroup = factory.SubFactory(HostGroupFactory)
# 
#     class Meta:
#         model = 'planb.Fileset'
#         exclude = ['host_prefix', 'host_suffix', 'tld']
# 
# class HostGroupFactory(DjangoModelFactory):
#     name = factory.Faker('domain_word')
# 
#     class Meta:
#         model = 'planb.HostGroup'
#         django_get_or_create = ('name',)
# 
# class UserFactory(DjangoModelFactory):
#     class Meta:
#         model = 'auth.User'
#         inline_args = ('username', 'email', 'password')
# 
#     username = factory.Faker('user_name')
#     email = factory.Faker('email')
#     password = factory.Faker('password')
#     is_active = True
# 
#     @classmethod
#     def _create(cls, model_class, username, email, password, **kwargs):
#         instance = model_class.objects._create_user(
#             username, email, password, **kwargs)
#         instance.raw_password = password
#         return instance
# 
# Path: planb/models.py
# BOGODATE = datetime(1970, 1, 2, tzinfo=timezone.utc)
# 
# Path: planb/tests/base.py
# class PlanbTestCase(TestCase):
#     def setUp(self):
#         super().setUp()
# 
#         # Reset storage_pools, otherwise we might get stale data from
#         # previous dummy's. This is a dict, that everyone has loaded
#         # already. Flush the contents of the dict.
#         for storage in storage_pools.values():
#             storage.close()
#         storage_pools.clear()
#         storage_pools.update(load_storage_pools())


from django.template import Context, Template
from django.utils import timezone
from planb.factories import (
    BackupRunFactory, FilesetFactory, HostGroupFactory, UserFactory)
from planb.models import BOGODATE
from planb.tests.base import PlanbTestCase
        }
        response = self.client.post(
            '/planb/hostgroup/{}/change/'.format(hostgroup.pk), data,
            follow=True)
        self.assertContains(
            response,
            'A rename task has been queued for all filesets in the hostgroup')

        # Test rename task spawn after fileset name change.
        data = {
            'friendly_name': 'my-host',
            'hostgroup': hostgroup.pk,
        }
        response = self.client.post(
            '/planb/fileset/{}/change/'.format(fileset.pk), data, follow=True)
        self.assertContains(
            response, 'A rename task has been queued for the fileset')

    def test_global_messages_templatetag(self):
        context = Context()
        template = Template('{% load planb %}{% global_messages %}')

        self.assertEqual(template.render(context), '')

        # Hack to trigger email updates doesn't show messages.
        FilesetFactory(first_fail=BOGODATE)

        self.assertEqual(template.render(context), '')

        first_fail = timezone.now()

# Path: planb/factories.py
# class BackupRunFactory(DjangoModelFactory):
#     fileset = factory.SubFactory(FilesetFactory)
# 
#     duration = factory.Faker('pyint')
#     success = factory.Faker('pybool')
#     total_size_mb = factory.Faker('pyint')
# 
#     @factory.lazy_attribute
#     def snapshot_size_mb(self):
#         return random.randint(0, self.total_size_mb)
# 
#     attributes = 'do_snapshot_size_listing: false'
#     snapshot_size_listing = ''
# 
#     class Meta:
#         model = 'planb.BackupRun'
# 
# class FilesetFactory(DjangoModelFactory):
#     host_prefix = factory.Faker('hostname', levels=0)
#     host_suffix = factory.Faker('domain_word')
#     tld = factory.Faker('tld')
# 
#     @factory.lazy_attribute
#     def friendly_name(self):
#         # Set friendly name as the full hostname within the hostgroup domain.
#         return '.'.join((
#             self.host_prefix, self.host_suffix, self.hostgroup.name, self.tld))
# 
#     storage_alias = 'dummy'
#     hostgroup = factory.SubFactory(HostGroupFactory)
# 
#     class Meta:
#         model = 'planb.Fileset'
#         exclude = ['host_prefix', 'host_suffix', 'tld']
# 
# class HostGroupFactory(DjangoModelFactory):
#     name = factory.Faker('domain_word')
# 
#     class Meta:
#         model = 'planb.HostGroup'
#         django_get_or_create = ('name',)
# 
# class UserFactory(DjangoModelFactory):
#     class Meta:
#         model = 'auth.User'
#         inline_args = ('username', 'email', 'password')
# 
#     username = factory.Faker('user_name')
#     email = factory.Faker('email')
#     password = factory.Faker('password')
#     is_active = True
# 
#     @classmethod
#     def _create(cls, model_class, username, email, password, **kwargs):
#         instance = model_class.objects._create_user(
#             username, email, password, **kwargs)
#         instance.raw_password = password
#         return instance
# 
# Path: planb/models.py
# BOGODATE = datetime(1970, 1, 2, tzinfo=timezone.utc)
# 
# Path: planb/tests/base.py
# class PlanbTestCase(TestCase):
#     def setUp(self):
#         super().setUp()
# 
#         # Reset storage_pools, otherwise we might get stale data from
#         # previous dummy's. This is a dict, that everyone has loaded
#         # already. Flush the contents of the dict.
#         for storage in storage_pools.values():
#             storage.close()
#         storage_pools.clear()
#         storage_pools.update(load_storage_pools())


# Path: planb/tests/test_interface.py
from django.template import Context, Template
from django.utils import timezone
from planb.factories import (
    BackupRunFactory, FilesetFactory, HostGroupFactory, UserFactory)
from planb.models import BOGODATE
from planb.tests.base import PlanbTestCase

        }
        response = self.client.post(
            '/planb/hostgroup/{}/change/'.format(hostgroup.pk), data,
            follow=True)
        self.assertContains(
            response,
            'A rename task has been queued for all filesets in the hostgroup')

        # Test rename task spawn after fileset name change.
        data = {
            'friendly_name': 'my-host',
            'hostgroup': hostgroup.pk,
        }
        response = self.client.post(
            '/planb/fileset/{}/change/'.format(fileset.pk), data, follow=True)
        self.assertContains(
            response, 'A rename task has been queued for the fileset')

    def test_global_messages_templatetag(self):
        context = Context()
        template = Template('{% load planb %}{% global_messages %}')

        self.assertEqual(template.render(context), '')

        # Hack to trigger email updates doesn't show messages.
        FilesetFactory(first_fail=BOGODATE)

        self.assertEqual(template.render(context), '')

        first_fail = timezone.now()

        hostgroup = HostGroupFactory()