• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

inspirehep / inspire-next / 12556

pending completion
12556

Pull #3459

travis-ci

web-flow
792 testlib: enable scenario recording in client

Adds a client function for recording new interactions.

Adds a helper in the form of a decorator (@with_mitmproxy) to abstract
E2E test scenario management.

Signed-off-by: Szymon Łopaciuk <szymon@lopaciuk.eu>
Pull Request #3459: 792 testlib: add mitmproxy scenario recording client

41 of 41 new or added lines in 1 file covered. (100.0%)

5082 of 9589 relevant lines covered (53.0%)

1.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/inspirehep/modules/search/search_factory.py
1
# -*- coding: utf-8 -*-
2
#
3
# This file is part of INSPIRE.
4
# Copyright (C) 2014-2017 CERN.
5
#
6
# INSPIRE is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# INSPIRE is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with INSPIRE. If not, see <http://www.gnu.org/licenses/>.
18
#
19
# In applying this license, CERN does not waive the privileges and immunities
20
# granted to it by virtue of its status as an Intergovernmental Organization
21
# or submit itself to any jurisdiction.
22

23
"""INSPIRE search factory used in invenio-records-rest."""
4✔
24

25
from __future__ import absolute_import, division, print_function
4✔
26

27
import json
4✔
28

29
from flask import current_app, request
4✔
30

31
from invenio_records_rest.errors import InvalidQueryRESTError
4✔
32
from invenio_records_rest.facets import default_facets_factory
4✔
33
from invenio_records_rest.sorter import default_sorter_factory
4✔
34

35
from inspirehep.modules.search import IQ
4✔
36

37

38
def inspire_search_factory(self, search):
4✔
39
    """Parse query using Inspire-Query-Parser.
40

41
    :param self: REST view.
42
    :param search: Elastic search DSL search instance.
43
    :returns: Tuple with search instance and URL arguments.
44
    """
45
    query_string = request.values.get('q', '')
1✔
46

47
    try:
1✔
48
        search = search.query(IQ(query_string, search))
1✔
49
    except SyntaxError:
×
50
        current_app.logger.debug(
×
51
            "Failed parsing query: {0}".format(
52
                request.values.get('q', '')),
53
            exc_info=True)
54
        raise InvalidQueryRESTError()
×
55
    finally:
56
        if current_app.debug:
1✔
57
                current_app.logger.debug(
1✔
58
                    json.dumps(search.to_dict(), indent=4)
59
                )
60

61
    search_index = search._index[0]
1✔
62
    search, urlkwargs = default_facets_factory(search, search_index)
1✔
63
    search, sortkwargs = default_sorter_factory(search, search_index)
1✔
64
    for key, value in sortkwargs.items():
1✔
65
        urlkwargs.add(key, value)
1✔
66

67
    urlkwargs.add('q', query_string)
1✔
68
    return search, urlkwargs
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc