'Test that content is properly made anonymous.
Content should be anonymous iff the anonymous field is true or the
anonymous_to_peers field is true and the requester does not have a
privileged role.
role_name is the name of the requester\'s role.
anonymous is the value of the anonymous field in the content.
anonymous_to_peers is the value of the anonymous_to_peers field in the
content.
expected_serialized_anonymous is whether the content should actually be
anonymous in the API output when requested by a user with the given
role.'

@ddt.data((FORUM_ROLE_ADMINISTRATOR, True, False, True), (FORUM_ROLE_ADMINISTRATOR, False, True, False), (FORUM_ROLE_MODERATOR, True, False, True), (FORUM_ROLE_MODERATOR, False, True, False), (FORUM_ROLE_COMMUNITY_TA, True, False, True), (FORUM_ROLE_COMMUNITY_TA, False, True, False), (FORUM_ROLE_STUDENT, True, False, True), (FORUM_ROLE_STUDENT, False, True, True))
@ddt.unpack
def test_anonymity(self, role_name, anonymous, anonymous_to_peers, expected_serialized_anonymous):

    self.create_role(role_name, [self.user])
    serialized = self.serialize(self.make_cs_content({'anonymous': anonymous, 'anonymous_to_peers': anonymous_to_peers}))
    actual_serialized_anonymous = (serialized['author'] is None)
    self.assertEqual(actual_serialized_anonymous, expected_serialized_anonymous)
