Ejemplo n.º 1
0
    def test_to_table(self):

        site = USite.objects.create(name="site")
        unit = utils.create_unit(site=site)
        usa = sl_utils.create_unit_service_area(unit=unit)
        sch1 = sl_utils.create_service_event_schedule(unit_service_area=usa)
        sch1.due_date = timezone.now() - timezone.timedelta(days=1)
        sch1.save()

        unit2 = utils.create_unit(site=None)
        usa2 = sl_utils.create_unit_service_area(unit=unit2)
        sl_utils.create_service_event_schedule(unit_service_area=usa2)

        rep = sl.NextScheduledServiceEventsDueDatesReport()
        rep.report_format = "csv"
        context = rep.get_context()
        table = rep.to_table(context)

        header_count = table.count([
            _("Unit"),
            _("Service Area"),
            _("Template Name"),
            _("Frequency"),
            _("Due Date"),
            _("Window"),
            _("Assigned To"),
            _("Perform")
        ])
        assert header_count == 2
Ejemplo n.º 2
0
    def test_to_table(self):

        site = USite.objects.create(name="site")
        unit = utils.create_unit(site=site)
        usa = sl_utils.create_unit_service_area(unit=unit)
        sl_utils.create_service_event_schedule(unit_service_area=usa)

        usa2 = sl_utils.create_unit_service_area()
        sl_utils.create_service_event_schedule(unit_service_area=usa2)

        rep = sl.ScheduledTemplatesReport(report_opts={'active': True})
        rep.report_format = "csv"
        context = rep.get_context()
        table = rep.to_table(context)

        header_row = table.index([
            _("Site"),
            _("Unit"),
            _("Service Area"),
            _("Template Name"),
            _("Frequency"),
            _("Assigned To"),
            _("Link"),
        ])
        assert len(table[header_row + 1:]) == 2
Ejemplo n.º 3
0
    def setUp(self):

        self.usa1 = utils.create_unit_service_area()
        self.usa2 = utils.create_unit_service_area()
        self.sch1 = utils.create_service_event_schedule(
            unit_service_area=self.usa1)
        self.sch2 = utils.create_service_event_schedule(
            unit_service_area=self.usa2)

        self.unit_group = UnitGroup.objects.create(name="test group")
        self.unit_group.units.add(self.usa1.unit)

        self.group = models.Group.objects.latest('pk')
        user = models.User.objects.latest('pk')
        user.groups.add(self.group)
        user.email = "*****@*****.**"
        user.save()

        self.recipients = RecipientGroup.objects.create(name="test group")
        self.recipients.groups.add(self.group)

        self.inactive_user = models.User.objects.create_user(
            'inactive', '*****@*****.**', 'password')
        self.inactive_user.groups.add(self.group)
        self.inactive_user.is_active = False
        self.inactive_user.save()

        self.notice = ServiceEventSchedulingNotice.objects.create(
            recipients=self.recipients,
            notification_type=ServiceEventSchedulingNotice.UPCOMING_AND_DUE,
            future_days=7,
            time="0:00",
        )
        # delete defaults schedules to make counting easier
        Schedule.objects.all().delete()
Ejemplo n.º 4
0
    def setUp(self):

        self.usa1 = utils.create_unit_service_area()
        self.usa2 = utils.create_unit_service_area()
        self.sch1 = utils.create_service_event_schedule(
            unit_service_area=self.usa1)
        self.sch2 = utils.create_service_event_schedule(
            unit_service_area=self.usa2)

        self.unit_group = UnitGroup.objects.create(name="test group")
        self.unit_group.units.add(self.usa1.unit)

        self.group = models.Group.objects.latest('pk')
        user = models.User.objects.latest('pk')
        user.groups.add(self.group)
        user.email = "*****@*****.**"
        user.save()

        self.recipients = RecipientGroup.objects.create(name="test group")
        self.recipients.groups.add(self.group)

        self.inactive_user = models.User.objects.create_user(
            'inactive', '*****@*****.**', 'password')
        self.inactive_user.groups.add(self.group)
        self.inactive_user.is_active = False
        self.inactive_user.save()

        # delete defaults schedules to make counting easier
        Schedule.objects.all().delete()
Ejemplo n.º 5
0
 def test_generate_summary_html(self):
     site = USite.objects.create(name="site")
     unit = utils.create_unit(site=site)
     usa = sl_utils.create_unit_service_area(unit=unit)
     sl_utils.create_service_event_schedule(unit_service_area=usa)
     rep = sl.ScheduledTemplatesReport()
     rep.report_format = "pdf"
     rep.to_html()
Ejemplo n.º 6
0
 def test_send_notice_no_recipients(self):
     utils.create_service_event_schedule()
     self.recipients.groups.clear()
     self.notice.send_empty = True
     self.notice.save()
     tasks.send_scheduling_notice(self.notice.pk)
     self.notice.refresh_from_db()
     assert self.notice.last_sent is None
     assert len(mail.outbox) == 0
Ejemplo n.º 7
0
 def test_generate_next_due_dates_html(self):
     site = USite.objects.create(name="site")
     unit = utils.create_unit(site=site)
     usa = sl_utils.create_unit_service_area(unit=unit)
     sch = sl_utils.create_service_event_schedule(unit_service_area=usa)
     sch.due_date = timezone.now() + timezone.timedelta(days=1)
     sch.save()
     rep = sl.NextScheduledServiceEventsDueDatesReport()
     rep.report_format = "pdf"
     rep.to_html()