Beispiel #1
0
    def test_crud_report_template(self):
        # Create
        report_template = ReportTemplateFactory(name="Test Template")

        # Read
        self.assertEqual(report_template.name, "Test Template")
        self.assertEqual(report_template.pk, report_template.id)
        self.assertEqual(len(self.ReportTemplate.objects.all()), 1)
        self.assertEqual(self.ReportTemplate.objects.first(), report_template)
        assert os.path.exists(report_template.document.path)

        # Update
        report_template.name = "New Template"
        report_template.save()
        self.assertEqual(report_template.name, "New Template")
        assert os.path.exists(report_template.document.path)

        # Delete
        report_template.delete()
        assert not self.ReportTemplate.objects.all().exists()
        assert not os.path.exists(report_template.document.path)
Beispiel #2
0
 def test_delete_template_signal(self):
     template = ReportTemplateFactory()
     self.assertTrue(os.path.exists(template.document.path))
     template.delete()
     self.assertFalse(os.path.exists(template.document.path))