def test_object_created_by_superuser_is_automatically_approved(self): person = Person( first_name='Joe', middle_name='Herbert', last_name='Schmoe', suffix='PhD', ) person.save(self.superuser) self.assertTrue(person.is_public)
def test_save_person_populates_created_by(self): person = Person( first_name='Joe', middle_name='Herbert', last_name='Schmoe', suffix='PhD', ) person.save(self.volunteer_user) self.assertEqual(person.created_by, self.volunteer_user)
def test_save_person_does_not_initially_populate_updated_by(self): person = Person( first_name='Joe', middle_name='Herbert', last_name='Schmoe', suffix='PhD', ) person.save(self.volunteer_user) self.assertIsNone(person.updated_by)
def test_volunteer_user_can_see_unapproved_objects_they_created(self): person = Person( first_name='Joe', middle_name='Herbert', last_name='Schmoe', suffix='PhD', ) person.save(self.volunteer_user) self.assertItemsEqual([person], Person.objects.for_user(self.volunteer_user))
def test_unapproved_objects_created_by_volunteer_are_not_public(self): person = Person( first_name='Joe', middle_name='Herbert', last_name='Schmoe', suffix='PhD', ) person.save(self.volunteer_user) self.assertFalse(Person.objects.public())
def test_logged_in_volunteer_user_can_see_unapproved_objects_others_created(self): person = Person( first_name='Joe', middle_name='Herbert', last_name='Schmoe', suffix='PhD', ) person.save(self.volunteer_user) # just using AnonymousUser here because being a 'volunteer' essentially # means you have no special permissions... self.assertItemsEqual([person], Person.objects.for_user(AnonymousUser()))
def test_save_prevents_volunteer_from_doing_object_approval(self): person = Person( first_name='Joe', middle_name='Herbert', last_name='Schmoe', suffix='PhD', is_public=True, ) person.save(self.volunteer_user) person = Person.objects.all()[0] self.assertFalse(person.is_public)
def test_logged_in_volunteer_user_can_see_unapproved_objects_others_created( self): person = Person( first_name='Joe', middle_name='Herbert', last_name='Schmoe', suffix='PhD', ) person.save(self.volunteer_user) # just using AnonymousUser here because being a 'volunteer' essentially # means you have no special permissions... self.assertItemsEqual([person], Person.objects.for_user(AnonymousUser()))
def test_update_is_public_to_true_populates_approved_by__for_superusers( self): person = Person( first_name='Joe', middle_name='Herbert', last_name='Schmoe', suffix='PhD', ) person.save(self.superuser) person.middle_name = 'Ignatius' person.is_public = True person.save(self.superuser) self.assertEqual(person.approved_by, self.superuser)
def test_update_is_public_to_true_doesnt_populate_approved_by__for_users_in_wrong_group( self): person = Person( first_name='Joe', middle_name='Herbert', last_name='Schmoe', suffix='PhD', ) person.save(self.volunteer_user) person.middle_name = 'Ignatius' person.is_public = True person.save(self.volunteer_user) self.assertIsNone(person.approved_by)
def test_update_is_public_to_true_populates_approved_by__for_superusers(self): person = Person( first_name='Joe', middle_name='Herbert', last_name='Schmoe', suffix='PhD', ) person.save(self.superuser) person.middle_name = 'Ignatius' person.is_public = True person.save(self.superuser) self.assertEqual(person.approved_by, self.superuser)
def test_update_is_public_to_true_doesnt_populate_approved_by__for_users_in_wrong_group(self): person = Person( first_name='Joe', middle_name='Herbert', last_name='Schmoe', suffix='PhD', ) person.save(self.volunteer_user) person.middle_name = 'Ignatius' person.is_public = True person.save(self.volunteer_user) self.assertIsNone(person.approved_by)