예제 #1
0
파일: groups_test.py 프로젝트: magnuslim/h
    def test_it_adds_user_from_request_params_to_group(self, group, user,
                                                       pyramid_request,
                                                       group_members_service):
        views.add_member(group, pyramid_request)

        group_members_service.member_join.assert_called_once_with(
            group, user.userid)
예제 #2
0
파일: groups_test.py 프로젝트: yumatch/h
    def test_it_validates_auth_client_and_user_authorities(
            self, group, user, pyramid_request, validate_auth_client_authority,
            auth_client):
        views.add_member(group, pyramid_request)

        validate_auth_client_authority.assert_called_once_with(
            auth_client, user.authority)
예제 #3
0
파일: groups_test.py 프로젝트: hypothesis/h
    def test_it_raises_HTTPNotFound_with_mismatched_user_and_group_authorities(
        self, factories, pyramid_request
    ):
        group = factories.Group(authority="different_authority.com")

        with pytest.raises(HTTPNotFound):
            views.add_member(group, pyramid_request)
예제 #4
0
파일: groups_test.py 프로젝트: timgates42/h
    def test_it_raises_HTTPNotFound_with_mismatched_user_and_group_authorities(
        self, factories, pyramid_request
    ):
        group = factories.Group(authority="different_authority.com")

        with pytest.raises(HTTPNotFound):
            views.add_member(group, pyramid_request)
예제 #5
0
파일: groups_test.py 프로젝트: yumatch/h
    def test_it_raises_ValidationError_with_mismatched_authorities(
            self, group, pyramid_request, validate_auth_client_authority):
        msg = "'authority' does not match authenticated client"
        validate_auth_client_authority.side_effect = ValidationError()

        with pytest.raises(ValidationError, message=msg):
            views.add_member(group, pyramid_request)
예제 #6
0
    def test_it_raises_HTTPNotFound_with_non_existent_user(
            self, context, pyramid_request, user_service):
        user_service.fetch.return_value = None

        pyramid_request.matchdict["userid"] = "some_user"

        with pytest.raises(HTTPNotFound):
            views.add_member(context, pyramid_request)
예제 #7
0
    def test_it_raises_HTTPNotFound_if_userid_malformed(
            self, context, pyramid_request, user_service):
        user_service.fetch.side_effect = ValueError("nope")

        pyramid_request.matchdict["userid"] = "invalidformat@wherever"

        with pytest.raises(
                HTTPNotFound):  # view handles ValueError and raises NotFound
            views.add_member(context, pyramid_request)
예제 #8
0
파일: groups_test.py 프로젝트: hypothesis/h
    def test_it_raises_HTTPNotFound_if_userid_malformed(
        self, group, pyramid_request, user_service
    ):

        user_service.fetch.side_effect = ValueError("nope")

        pyramid_request.matchdict["userid"] = "invalidformat@wherever"

        with pytest.raises(HTTPNotFound):  # view handles ValueError and raises NotFound
            views.add_member(group, pyramid_request)
예제 #9
0
파일: groups_test.py 프로젝트: hypothesis/h
    def test_it_raises_HTTPNotFound_with_non_existent_user(
        self, group, pyramid_request, user_service
    ):

        user_service.fetch.return_value = None

        pyramid_request.matchdict["userid"] = "some_user"

        with pytest.raises(HTTPNotFound):
            views.add_member(group, pyramid_request)
예제 #10
0
    def test_it_raises_HTTPNotFound_if_userid_malformed(
        self,
        group,
        pyramid_request,
        user_service,
    ):

        user_service.fetch.side_effect = ValueError('nope')

        pyramid_request.matchdict['userid'] = "invalidformat@wherever"

        with pytest.raises(
                HTTPNotFound):  # view handles ValueError and raises NotFound
            views.add_member(group, pyramid_request)
예제 #11
0
    def test_it_returns_HTTPNoContent_when_add_member_is_successful(
        self,
        group,
        pyramid_request,
    ):
        resp = views.add_member(group, pyramid_request)

        assert isinstance(resp, HTTPNoContent)
예제 #12
0
    def test_it_raises_HTTPNotFound_with_mismatched_user_and_group_authorities(
            self, context, pyramid_request):
        context.group.authority = "different_authority.com"

        with pytest.raises(HTTPNotFound):
            views.add_member(context, pyramid_request)
예제 #13
0
파일: groups_test.py 프로젝트: hypothesis/h
    def test_it_returns_HTTPNoContent_when_add_member_is_successful(
        self, group, pyramid_request
    ):
        resp = views.add_member(group, pyramid_request)

        assert isinstance(resp, HTTPNoContent)
예제 #14
0
파일: groups_test.py 프로젝트: yumatch/h
    def test_it_raises_ClientUnauthorized_with_bad_auth_client(
            self, group, pyramid_request, request_auth_client):
        request_auth_client.side_effect = ClientUnauthorized()

        with pytest.raises(ClientUnauthorized):
            views.add_member(group, pyramid_request)
예제 #15
0
파일: groups_test.py 프로젝트: yumatch/h
    def test_it_gets_the_auth_client_from_the_request(self, group,
                                                      pyramid_request,
                                                      request_auth_client):
        views.add_member(group, pyramid_request)

        request_auth_client.assert_called_once_with(pyramid_request)
예제 #16
0
파일: groups_test.py 프로젝트: hypothesis/h
    def test_it_fetches_user_from_the_request_params(
        self, group, user, pyramid_request, user_service
    ):
        views.add_member(group, pyramid_request)

        user_service.fetch.assert_called_once_with(user.userid)
예제 #17
0
파일: groups_test.py 프로젝트: timgates42/h
    def test_it_fetches_user_from_the_request_params(
        self, group, user, pyramid_request, user_service
    ):
        views.add_member(group, pyramid_request)

        user_service.fetch.assert_called_once_with(user.userid)
예제 #18
0
파일: groups_test.py 프로젝트: hypothesis/h
    def test_it_adds_user_from_request_params_to_group(
        self, group, user, pyramid_request, group_members_service
    ):
        views.add_member(group, pyramid_request)

        group_members_service.member_join.assert_called_once_with(group, user.userid)