Example #1
0
    def test_create_profile(self, profile: Profile, rf: RequestFactory,
                            mailoutbox):
        view = ProfileViewSet()
        request = rf.get("/fake-url/")
        request.user = profile.user

        profile_data = ProfileFactory()
        profile_dict = {
            "phone": "9329275526",
            "website": "http://livingston.biz",
            "twitter": "paul58",
            "facebook": "fday",
            "linkedin": "wpalmer",
            "name": "Long Name with lots of letters",
            "email": "*****@*****.**",
            "tags": ["tech, 'something else'', "],
            "bio":
            "Themselves TV western under. Tv can beautiful we throughout politics treat both. Fear speech left get answer over century.",
            "visible": False,
        }

        request.data = profile_dict

        response = view.create(request)
        assert response.status_code == 201
        assert len(mailoutbox) == 0
Example #2
0
    def test_create_staff_profile(self, profile: Profile,
                                  moderator_group: Group, rf: RequestFactory):
        view = ProfileViewSet()
        request = rf.get("/fake-url/")
        request.user = profile.user

        profile_data = ProfileFactory()
        profile_dict = {
            "phone": "9329275526",
            "website": "http://livingston.biz",
            "twitter": "paul58",
            "facebook": "fday",
            "linkedin": "wpalmer",
            "name": "Long Name with lots of letters",
            "email": "*****@*****.**",
            "tags": ["tech, 'something else'', "],
            "bio":
            "Themselves TV western under. Tv can beautiful we throughout politics treat both. Fear speech left get answer over century.",
            "visible": False,
            "admin": True,
        }

        request.data = profile_dict

        response = view.create(request)
        new_profile = Profile.objects.get(pk=response.data["id"])

        # add the user log into the backend?
        assert new_profile.user.is_staff
        # are they in the required group to administer users?
        assert moderator_group in new_profile.user.groups.all()

        assert response.status_code == 201