def test_delete_model(self, pa, db):
        """Deleting a profile deletes the associated user, too."""
        p = factories.ProfileFactory.create()
        pa.delete_model(mock.Mock(), p)

        assert utils.deleted(p)
        assert utils.deleted(p.user)
Example #2
0
    def test_delete_model(self, pa, db):
        """Deleting a profile deletes the associated user, too."""
        p = factories.ProfileFactory.create()
        pa.delete_model(mock.Mock(), p)

        assert utils.deleted(p)
        assert utils.deleted(p.user)
Example #3
0
    def test_delete_relationships_from_list(self, no_csrf_client):
        """A user may delete their own relationship via list URL."""
        rel = factories.RelationshipFactory.create()
        other_rel = factories.RelationshipFactory.create(
            from_profile=rel.elder)

        no_csrf_client.delete(
            self.list_url() + "?student=%s" % rel.student.pk,
            user=rel.elder.user,
            status=204,
            )

        assert utils.deleted(rel)
        assert not utils.deleted(other_rel)
Example #4
0
    def test_delete_group(self, no_csrf_client):
        """Owner of a group can delete it."""
        group = factories.GroupFactory.create()

        no_csrf_client.delete(
            self.detail_url(group), user=group.owner.user, status=204)

        assert utils.deleted(group)
Example #5
0
    def test_cannot_delete_other_rel(self, no_csrf_client):
        """Another user may not delete a relationship that is not theirs."""
        rel = factories.RelationshipFactory.create()
        other = factories.ProfileFactory.create()

        no_csrf_client.delete(self.detail_url(rel), user=other.user, status=404)

        assert not utils.deleted(rel)
Example #6
0
    def test_delete_relationship(self, no_csrf_client):
        """A user may delete their own relationship."""
        rel = factories.RelationshipFactory.create()

        no_csrf_client.delete(
            self.detail_url(rel), user=rel.elder.user, status=204)

        assert utils.deleted(rel)
Example #7
0
    def test_relationship_deleted(self, db):
        """Deleting a relationship does not delete posts in that village."""
        rel = factories.RelationshipFactory.create()
        post = factories.PostFactory.create(
            student=rel.student, relationship=rel)

        rel.delete()

        assert not utils.deleted(post)
Example #8
0
    def test_relationship_deleted(self, db):
        """Deleting a relationship does not delete posts in that village."""
        rel = factories.RelationshipFactory.create()
        post = factories.PostFactory.create(student=rel.student,
                                            relationship=rel)

        rel.delete()

        assert not utils.deleted(post)
Example #9
0
    def test_delete_group_requires_owner(self, no_csrf_client):
        """Non-owner cannot delete a group, even if school staff."""
        group = factories.GroupFactory.create()
        profile = factories.ProfileFactory.create(school=group.owner.school)

        no_csrf_client.delete(
            self.detail_url(group), user=profile.user, status=404)

        assert not utils.deleted(group)
    def test_profile_deletion(self, db):
        """Can delete group-owning profile."""
        g = factories.GroupFactory.create()
        g.owner.delete()

        assert utils.deleted(g)
Example #11
0
    def test_profile_deletion(self, db):
        """Can delete group-owning profile."""
        g = factories.GroupFactory.create()
        g.owner.delete()

        assert utils.deleted(g)