コード例 #1
0
ファイル: activity_test.py プロジェクト: nlisgo/h
    def test_it_allows_to_specify_the_page_size(self, pyramid_request, query):
        pyramid_request.params['page_size'] = 100
        activity.search(pyramid_request)

        query.execute.assert_called_once_with(pyramid_request,
                                              query.extract.return_value,
                                              page_size=100)
コード例 #2
0
ファイル: activity_test.py プロジェクト: nlisgo/h
    def test_it_uses_default_page_size_when_value_is_a_string(self, pyramid_request, query):
        pyramid_request.params['page_size'] = 'foobar'
        activity.search(pyramid_request)

        query.execute.assert_called_once_with(pyramid_request,
                                              query.extract.return_value,
                                              page_size=activity.PAGE_SIZE)
コード例 #3
0
    def test_it_uses_default_page_size_when_value_is_a_string(self, pyramid_request, query):
        pyramid_request.params['page_size'] = 'foobar'
        activity.search(pyramid_request)

        query.execute.assert_called_once_with(pyramid_request,
                                              query.extract.return_value,
                                              page_size=activity.PAGE_SIZE)
コード例 #4
0
    def test_it_allows_to_specify_the_page_size(self, pyramid_request, query):
        pyramid_request.params['page_size'] = 100
        activity.search(pyramid_request)

        query.execute.assert_called_once_with(pyramid_request,
                                              query.extract.return_value,
                                              page_size=100)
コード例 #5
0
ファイル: activity_test.py プロジェクト: fangang123/h
    def test_it_checks_for_redirects(self, pyramid_request, query):
        pyramid_request.feature.flags['search_page'] = True

        search(pyramid_request)

        query.check_url.assert_called_once_with(pyramid_request,
                                                query.extract.return_value)
コード例 #6
0
    def test_it_uses_passed_in_page_size_for_pagination(self, pyramid_request, paginate):
        pyramid_request.params['page_size'] = 100
        activity.search(pyramid_request)

        paginate.assert_called_once_with(pyramid_request,
                                         mock.ANY,
                                         page_size=100)
コード例 #7
0
ファイル: activity_test.py プロジェクト: nlisgo/h
    def test_it_uses_passed_in_page_size_for_pagination(self, pyramid_request, paginate):
        pyramid_request.params['page_size'] = 100
        activity.search(pyramid_request)

        paginate.assert_called_once_with(pyramid_request,
                                         mock.ANY,
                                         page_size=100)
コード例 #8
0
ファイル: activity_test.py プロジェクト: fangang123/h
    def test_it_executes_a_search_query(self, pyramid_request, query):
        pyramid_request.feature.flags['search_page'] = True

        search(pyramid_request)

        query.execute.assert_called_once_with(pyramid_request,
                                              query.extract.return_value,
                                              page_size=PAGE_SIZE)
コード例 #9
0
ファイル: activity_test.py プロジェクト: fangang123/h
    def test_is_uses_passed_in_page_size_for_pagination(
            self, pyramid_request, paginate):
        pyramid_request.feature.flags['search_page'] = True

        pyramid_request.params['page_size'] = 100
        search(pyramid_request)

        paginate.assert_called_once_with(pyramid_request,
                                         mock.ANY,
                                         page_size=100)
コード例 #10
0
ファイル: activity_test.py プロジェクト: tetratorus/h
    def test_it_returns_usernames(self, pyramid_request, query):
        """
        It should return a list of usernames to the template.

        query.execute() returns userids, search() should insert new values with
        just the username parts.

        """
        query.execute.return_value = mock.Mock(
            aggregations={
                'users': [
                    {
                        'user': '******'
                    },
                    {
                        'user': '******'
                    },
                    {
                        'user': '******'
                    },
                ]
            })

        result = activity.search(pyramid_request)

        usernames = [
            user['username'] for user in result['aggregations']['users']
        ]
        assert usernames == ['test_user_1', 'test_user_2', 'test_user_3']
コード例 #11
0
ファイル: activity_test.py プロジェクト: tetratorus/h
    def test_it_returns_group_suggestions(self, factories, pyramid_request,
                                          query):
        """It should return a list of group_suggestsions to the template."""
        fake_group_1 = factories.Group()
        fake_group_2 = factories.Group()
        fake_group_3 = factories.Group()
        pyramid_request.authenticated_user.groups = [
            fake_group_1, fake_group_2, fake_group_3
        ]

        result = activity.search(pyramid_request)

        assert result['groups_suggestions'] == [
            {
                'name': fake_group_1.name,
                'pubid': fake_group_1.pubid
            },
            {
                'name': fake_group_2.name,
                'pubid': fake_group_2.pubid
            },
            {
                'name': fake_group_3.name,
                'pubid': fake_group_3.pubid
            },
        ]
コード例 #12
0
    def test_it_returns_userids(self, pyramid_request, query):
        """
        It should return a list of userids to the template.

        query.execute() returns userids as "user", search() should rename these
        to "userid".

        """
        query.execute.return_value = mock.Mock(
            aggregations={
                'users': [
                    {'user': '******'},
                    {'user': '******'},
                    {'user': '******'},
                ]
            }
        )

        result = activity.search(pyramid_request)

        userids = [user['userid'] for user in result['aggregations']['users']]
        assert userids == [
            'acct:[email protected]',
            'acct:[email protected]',
            'acct:[email protected]',
        ]
コード例 #13
0
ファイル: activity_test.py プロジェクト: tetratorus/h
    def test_it_does_not_crash_if_there_are_no_users(self, pyramid_request,
                                                     query):
        """
        It shouldn't crash if query.execute() returns no users.

        Sometimes there is no "users" key in the aggregations.

        """
        query.execute.return_value = mock.Mock(aggregations={})

        result = activity.search(pyramid_request)

        assert 'users' not in result['aggregations']
コード例 #14
0
ファイル: activity_test.py プロジェクト: nlisgo/h
    def test_it_returns_group_suggestions(self,
                                          factories,
                                          pyramid_request,
                                          query):
        """It should return a list of group_suggestsions to the template."""
        fake_group_1 = factories.Group()
        fake_group_2 = factories.Group()
        fake_group_3 = factories.Group()
        pyramid_request.authenticated_user.groups = [
            fake_group_1, fake_group_2, fake_group_3]

        result = activity.search(pyramid_request)

        assert result['groups_suggestions'] == [
            {'name': fake_group_1.name, 'pubid': fake_group_1.pubid},
            {'name': fake_group_2.name, 'pubid': fake_group_2.pubid},
            {'name': fake_group_3.name, 'pubid': fake_group_3.pubid},
        ]
コード例 #15
0
ファイル: activity_test.py プロジェクト: nlisgo/h
    def test_it_returns_404_when_feature_turned_off(self, pyramid_request):
        pyramid_request.feature.flags['search_page'] = False

        with pytest.raises(httpexceptions.HTTPNotFound):
            activity.search(pyramid_request)
コード例 #16
0
ファイル: activity_test.py プロジェクト: nlisgo/h
    def test_it_checks_for_redirects(self, pyramid_request, query):
        activity.search(pyramid_request)

        query.check_url.assert_called_once_with(pyramid_request,
                                                query.extract.return_value)
コード例 #17
0
ファイル: activity_test.py プロジェクト: nlisgo/h
    def test_it_executes_a_search_query(self, pyramid_request, query):
        activity.search(pyramid_request)

        query.execute.assert_called_once_with(pyramid_request,
                                              query.extract.return_value,
                                              page_size=activity.PAGE_SIZE)
コード例 #18
0
    def test_it_executes_a_search_query(self, pyramid_request, query):
        activity.search(pyramid_request)

        query.execute.assert_called_once_with(pyramid_request,
                                              query.extract.return_value,
                                              page_size=activity.PAGE_SIZE)
コード例 #19
0
    def test_it_checks_for_redirects(self, pyramid_request, query):
        activity.search(pyramid_request)

        query.check_url.assert_called_once_with(pyramid_request,
                                                query.extract.return_value)
コード例 #20
0
    def test_it_returns_404_when_feature_turned_off(self, pyramid_request):
        pyramid_request.feature.flags['search_page'] = False

        with pytest.raises(httpexceptions.HTTPNotFound):
            activity.search(pyramid_request)
コード例 #21
0
ファイル: activity_test.py プロジェクト: nlisgo/h
 def test_it_generates_username_links(self, pyramid_request):
     result = activity.search(pyramid_request)
     user_link = result['user_link']('acct:[email protected]')
     assert user_link == 'http://example.com/users/jim.smith/search'
コード例 #22
0
ファイル: activity_test.py プロジェクト: nlisgo/h
 def test_it_generates_usernames(self, pyramid_request):
     result = activity.search(pyramid_request)
     username = result['username_from_id']('acct:[email protected]')
     assert username == 'jim.smith'
コード例 #23
0
ファイル: activity_test.py プロジェクト: nlisgo/h
 def test_it_generates_tag_links(self, pyramid_request):
     result = activity.search(pyramid_request)
     tag_link = result['tag_link']('foo')
     assert tag_link == 'http://example.com/search?q=tag%3Afoo'