def test_mark_as_deleted(self): user = UserFactory() other_user = UserFactory() org = OrganizationFactory(editors=[user]) discussion_only_user = DiscussionFactory( user=user, subject=org, discussion=[ MessageDiscussionFactory(posted_by=user), MessageDiscussionFactory(posted_by=user) ]) discussion_with_other = DiscussionFactory( user=other_user, subject=org, discussion=[ MessageDiscussionFactory(posted_by=other_user), MessageDiscussionFactory(posted_by=user) ]) user_follow_org = Follow.objects.create(follower=user, following=org) user_followed = Follow.objects.create(follower=other_user, following=user) user.mark_as_deleted() org.reload() assert len(org.members) == 0 assert Discussion.objects(id=discussion_only_user.id).first() is None discussion_with_other.reload() assert discussion_with_other.discussion[1].content == 'DELETED' assert Follow.objects(id=user_follow_org.id).first() is None assert Follow.objects(id=user_followed.id).first() is None assert user.slug == 'deleted'
def test_mark_as_deleted_slug_multiple(self): user = UserFactory() other_user = UserFactory() user.mark_as_deleted() other_user.mark_as_deleted() assert user.slug == 'deleted' assert other_user.slug == 'deleted-1'
def test_deleted_user(self, api): '''Should raise a HTTP 401 if the user is deleted''' user = UserFactory() user.mark_as_deleted() with api.user(user) as user: response = api.post(url_for('api.fake'), headers={'X-API-KEY': user.apikey}) assert401(response) assert response.content_type == 'application/json' assert 'message' in response.json