def test_project_cannot_be_modified_when_inactive(self): project = Project(name='Test', active=False).validate_and_save() # Should raise a generic validation error if attempting to # save on a inactive project with self.assertRaises(ValidationError) as context_manager: project.validate_and_save() self.assertValidationMessagePresent( context_manager.exception.error_dict, field='__all__', error_code='cannot_modify_when_inactive') # But should be able to save the change if it is # re-opening the project project.active = True project.validate_and_save() self.assertEqual(project.active, True)
def test_project_has_descriptive_string_representation(self): project = Project(name='Test') self.assertEqual(str(project), 'Test') project.active = False self.assertEqual(str(project), 'Test (Inactive)')