def test_moderator_cannot_update_community(self): """ a community moderator should not be able to update a community """ user = make_user() headers = make_authentication_headers_for_user(user) other_user = make_user() community = make_community(creator=other_user) user.join_community_with_name(community_name=community.name) other_user.add_moderator_with_username_to_community_with_name( username=user.username, community_name=community.name) new_community_name = make_community_name() data = {'name': new_community_name} url = self._get_url(community_name=community.name) response = self.client.patch(url, data, **headers) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) community.refresh_from_db() self.assertNotEqual(community.name, new_community_name)
def test_can_update_administrated_community_name(self): """ should be able to update an administrated community name """ user = make_user() headers = make_authentication_headers_for_user(user) community = make_community(creator=user) new_community_name = make_community_name() data = {'name': new_community_name} url = self._get_url(community_name=community.name) response = self.client.patch(url, data, **headers) self.assertEqual(response.status_code, status.HTTP_200_OK) community.refresh_from_db() self.assertEqual(community.name, new_community_name)