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)
def test_post_save_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) field.status = 'inactive' field.save post_save_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)
def test_post_save_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 ) field.status = 'inactive' field.save post_save_field(TextField, instance=field) reference = AirQualityProject.objects.get(pk=aq_project.id) self.assertEqual(reference.status, 'active') self.assertEquals(len(mail.outbox), 0)