Exemplo n.º 1
0
    def test_pre_delete_field(self):

        project = ProjectFactory.create(status='active')
        category = CategoryFactory.create(project=project)
        field = TextFieldFactory.create(category=category)

        aq_project = AirQualityProjectFactory.create(
            status='active',
            project=project
        )
        aq_category = AirQualityCategoryFactory.create(
            category=category,
            project=aq_project
        )
        aq_field = AirQualityFieldFactory.create(
            field=field,
            category=aq_category
        )

        pre_delete_field(TextField, instance=field)

        reference = AirQualityProject.objects.get(pk=aq_project.id)
        self.assertEqual(reference.status, 'inactive')
        self.assertEqual(
            AirQualityField.objects.filter(pk=aq_field.id).exists(),
            False
        )
        self.assertEquals(len(mail.outbox), 1)
Exemplo n.º 2
0
    def test_post_save_when_category_made_inactive(self):

        project = ProjectFactory.create(status='active')
        category = CategoryFactory.create(project=project)

        aq_project = AirQualityProjectFactory.create(
            status='active',
            project=project
        )
        aq_category = AirQualityCategoryFactory.create(
            category=category,
            project=aq_project
        )

        category.status = 'inactive'
        category.save

        post_save_category(Category, instance=category)

        reference = AirQualityProject.objects.get(pk=aq_project.id)
        self.assertEqual(reference.status, 'inactive')
        self.assertEqual(
            AirQualityCategory.objects.filter(pk=aq_category.id).exists(),
            False
        )
        self.assertEquals(len(mail.outbox), 1)
    def test_pre_delete_project(self):

        project = ProjectFactory.create(status='active')
        aq_project = AirQualityProjectFactory.create(project=project)

        pre_delete_project(Project, instance=project)

        self.assertEqual(
            AirQualityProject.objects.filter(pk=aq_project.id).exists(), False)
        self.assertEquals(len(mail.outbox), 1)
Exemplo n.º 4
0
    def test_pre_delete_project(self):

        project = ProjectFactory.create(status='active')
        aq_project = AirQualityProjectFactory.create(project=project)

        pre_delete_project(Project, instance=project)

        self.assertEqual(
            AirQualityProject.objects.filter(pk=aq_project.id).exists(),
            False
        )
        self.assertEquals(len(mail.outbox), 1)
    def test_post_save_when_project_made_inactive(self):

        project = ProjectFactory.create(status='active')
        aq_project = AirQualityProjectFactory.create(project=project)

        project.status = 'inactive'
        project.save

        post_save_project(Project, instance=project)

        self.assertEqual(
            AirQualityProject.objects.filter(pk=aq_project.id).exists(), False)
        self.assertEquals(len(mail.outbox), 1)
    def test_pre_delete_category_when_no_aq_categort(self):

        project = ProjectFactory.create(status='active')
        category = CategoryFactory.create(project=project)

        aq_project = AirQualityProjectFactory.create(status='active',
                                                     project=project)

        pre_delete_category(Category, instance=category)

        reference = AirQualityProject.objects.get(pk=aq_project.id)
        self.assertEqual(reference.status, 'active')
        self.assertEquals(len(mail.outbox), 0)
    def test_pre_delete_field_when_no_aq_field(self):

        project = ProjectFactory.create(status='active')
        category = CategoryFactory.create(project=project)
        field = TextFieldFactory.create(category=category)

        aq_project = AirQualityProjectFactory.create(status='active',
                                                     project=project)
        AirQualityCategoryFactory.create(category=category, project=aq_project)

        pre_delete_field(TextField, instance=field)

        reference = AirQualityProject.objects.get(pk=aq_project.id)
        self.assertEqual(reference.status, 'active')
        self.assertEquals(len(mail.outbox), 0)
Exemplo n.º 8
0
    def test_post_save_when_project_made_inactive(self):

        project = ProjectFactory.create(status='active')
        aq_project = AirQualityProjectFactory.create(project=project)

        project.status = 'inactive'
        project.save

        post_save_project(Project, instance=project)

        self.assertEqual(
            AirQualityProject.objects.filter(pk=aq_project.id).exists(),
            False
        )
        self.assertEquals(len(mail.outbox), 1)
Exemplo n.º 9
0
    def test_pre_delete_category_when_no_aq_categort(self):

        project = ProjectFactory.create(status='active')
        category = CategoryFactory.create(project=project)

        aq_project = AirQualityProjectFactory.create(
            status='active',
            project=project
        )

        pre_delete_category(Category, instance=category)

        reference = AirQualityProject.objects.get(pk=aq_project.id)
        self.assertEqual(reference.status, 'active')
        self.assertEquals(len(mail.outbox), 0)
    def test_pre_delete_category(self):

        project = ProjectFactory.create(status='active')
        category = CategoryFactory.create(project=project)

        aq_project = AirQualityProjectFactory.create(status='active',
                                                     project=project)
        aq_category = AirQualityCategoryFactory.create(category=category,
                                                       project=aq_project)

        pre_delete_category(Category, instance=category)

        reference = AirQualityProject.objects.get(pk=aq_project.id)
        self.assertEqual(reference.status, 'inactive')
        self.assertEqual(
            AirQualityCategory.objects.filter(pk=aq_category.id).exists(),
            False)
        self.assertEquals(len(mail.outbox), 1)
Exemplo n.º 11
0
    def test_pre_delete_field_when_no_aq_field(self):

        project = ProjectFactory.create(status='active')
        category = CategoryFactory.create(project=project)
        field = TextFieldFactory.create(category=category)

        aq_project = AirQualityProjectFactory.create(
            status='active',
            project=project
        )
        AirQualityCategoryFactory.create(
            category=category,
            project=aq_project
        )

        pre_delete_field(TextField, instance=field)

        reference = AirQualityProject.objects.get(pk=aq_project.id)
        self.assertEqual(reference.status, 'active')
        self.assertEquals(len(mail.outbox), 0)
    def test_post_save_when_field_made_inactive(self):

        project = ProjectFactory.create(status='active')
        category = CategoryFactory.create(project=project)
        field = TextFieldFactory.create(category=category)

        aq_project = AirQualityProjectFactory.create(status='active',
                                                     project=project)
        aq_category = AirQualityCategoryFactory.create(category=category,
                                                       project=aq_project)
        aq_field = AirQualityFieldFactory.create(field=field,
                                                 category=aq_category)

        field.status = 'inactive'
        field.save

        post_save_field(TextField, instance=field)

        reference = AirQualityProject.objects.get(pk=aq_project.id)
        self.assertEqual(reference.status, 'inactive')
        self.assertEqual(
            AirQualityField.objects.filter(pk=aq_field.id).exists(), False)
        self.assertEquals(len(mail.outbox), 1)