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)
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_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)
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)