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
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()
def test_get_unit_details(self): site = USite.objects.create(name="site") unit = utils.create_unit(site=site) units = sl.NextScheduledServiceEventsDueDatesReport().get_unit_service_area__unit_details([unit.pk]) assert units == ('Unit(s)', '%s - %s' % (unit.site.name, unit.name))
def test_get_unit__site_details(self): site = USite.objects.create(name="site") sites = sl.NextScheduledServiceEventsDueDatesReport().get_unit_service_area__unit__site_details([site, 'null']) assert sites == ('Site(s)', 'site, Other')
def test_next_due_dates_get_filename(self): assert ( sl.NextScheduledServiceEventsDueDatesReport().get_filename('pdf') == 'next-due-dates-for-scheduled-service-events.pdf' )
def test_get_queryset(self): assert ( sl.NextScheduledServiceEventsDueDatesReport().get_queryset().model._meta.model_name == "serviceeventschedule" )