Пример #1
0
    def test_search_returns_annotation_count_for_group_members(self,
                                                               controller,
                                                               pyramid_request,
                                                               group,
                                                               search,
                                                               factories):
        user_1 = factories.User()
        user_2 = factories.User()
        group.members = [user_1, user_2]

        pyramid_request.user = group.members[-1]

        counts = {user_1.userid: 24, user_2.userid: 6}
        users_aggregation = [
            {'user': user_1.userid, 'count': counts[user_1.userid]},
            {'user': user_2.userid, 'count': counts[user_2.userid]},
        ]
        search.return_value = {
            'search_results': ActivityResults(total=200,
                                              aggregations={'users': users_aggregation},
                                              timeframes=[]),
        }

        result = controller.search()

        for member in result['group']['members']:
            assert member['count'] == counts[member['userid']]
Пример #2
0
    def test_search_returns_annotation_count_for_group_moderators(  # pylint:disable=unused-argument
            self, controller, test_group, test_user, search, factories):
        user_1 = test_group.creator
        user_2 = factories.User()

        counts = {user_1.userid: 24, user_2.userid: 6}
        users_aggregation = [
            {
                "user": user_1.userid,
                "count": counts[user_1.userid]
            },
            {
                "user": user_2.userid,
                "count": counts[user_2.userid]
            },
        ]
        search.return_value = {
            "search_results":
            ActivityResults(total=200,
                            aggregations={"users": users_aggregation},
                            timeframes=[])
        }

        result = controller.search()
        for moderator in result["group_users_args"][1]:
            assert moderator["count"] == counts[moderator["userid"]]
Пример #3
0
def search(patch):
    search = patch("h.views.activity.SearchController.search")
    search.return_value = {
        "search_results": ActivityResults(total=200, aggregations={}, timeframes=[]),
        "zero_message": "No annotations matched your search.",
    }
    return search
Пример #4
0
    def test_search_returns_annotation_count_for_group_members(
            self, controller, pyramid_request, group, search, factories):
        user_1 = factories.User()
        user_2 = factories.User()
        group.members = [user_1, user_2]

        pyramid_request.user = group.members[-1]

        counts = {user_1.userid: 24, user_2.userid: 6}
        users_aggregation = [
            {
                "user": user_1.userid,
                "count": counts[user_1.userid]
            },
            {
                "user": user_2.userid,
                "count": counts[user_2.userid]
            },
        ]
        search.return_value = {
            "search_results":
            ActivityResults(total=200,
                            aggregations={"users": users_aggregation},
                            timeframes=[])
        }

        result = controller.search()

        for member in result["group_users_args"][1]:
            assert member["count"] == counts[member["userid"]]
Пример #5
0
def search(patch):
    search = patch('h.views.activity.SearchController.search')
    search.return_value = {
        'search_results': ActivityResults(total=200,
                                          aggregations={},
                                          timeframes=[]),
        'zero_message': 'No annotations matched your search.',
    }
    return search