Example #1
0
    def test_it_returns_404_when_the_group_does_not_exist(self,
                                                          pyramid_request):
        pyramid_request.POST = NestedMultiDict({
            'group_leave': 'does_not_exist'})

        with pytest.raises(httpexceptions.HTTPNotFound):
            activity.group_leave(pyramid_request)
Example #2
0
    def test_it_returns_404_when_the_group_does_not_exist(self,
                                                          pyramid_request):
        pyramid_request.POST = NestedMultiDict({
            'group_leave': 'does_not_exist'})

        with pytest.raises(httpexceptions.HTTPNotFound):
            activity.group_leave(pyramid_request)
Example #3
0
    def test_it_leaves_the_group(self, group, groups_service, pyramid_config,
                                 pyramid_request):
        pyramid_config.testing_securitypolicy(group.members[-1].userid)

        activity.group_leave(pyramid_request)

        groups_service.member_leave.assert_called_once_with(
            group, group.members[-1].userid)
Example #4
0
    def test_it_returns_404_when_feature_turned_off(self, group,
                                                    pyramid_request):
        pyramid_request.feature.flags['search_page'] = False

        for user in (None, group.creator, group.members[-1]):
            pyramid_request.authenticated_user = user
            with pytest.raises(httpexceptions.HTTPNotFound):
                activity.group_leave(pyramid_request)
Example #5
0
    def test_it_returns_404_when_feature_turned_off(self,
                                                    group,
                                                    pyramid_request):
        pyramid_request.feature.flags['search_page'] = False

        for user in (None, group.creator, group.members[-1]):
            pyramid_request.authenticated_user = user
            with pytest.raises(httpexceptions.HTTPNotFound):
                activity.group_leave(pyramid_request)
Example #6
0
    def test_it_leaves_the_group(self,
                                 group,
                                 groups_service,
                                 pyramid_config,
                                 pyramid_request):
        pyramid_config.testing_securitypolicy(group.members[-1].userid)

        activity.group_leave(pyramid_request)

        groups_service.member_leave.assert_called_once_with(
            group, group.members[-1].userid)
Example #7
0
    def test_it_redirects_to_the_search_page(self, group, pyramid_request):
        # This should be in the redirect URL.
        pyramid_request.POST['q'] = 'foo bar gar'
        # This should *not* be in the redirect URL.
        pyramid_request.POST['group_leave'] = group.pubid
        result = activity.group_leave(pyramid_request)

        assert isinstance(result, httpexceptions.HTTPSeeOther)
        assert result.location == 'http://example.com/search?q=foo+bar+gar'
Example #8
0
    def test_it_redirects_to_the_search_page(self, group, pyramid_request):
        # This should be in the redirect URL.
        pyramid_request.POST['q'] = 'foo bar gar'
        # This should *not* be in the redirect URL.
        pyramid_request.POST['group_leave'] = group.pubid
        result = activity.group_leave(pyramid_request)

        assert isinstance(result, httpexceptions.HTTPSeeOther)
        assert result.location == 'http://example.com/search?q=foo+bar+gar'