Exemplo n.º 1
0
    def setUpClass(cls):
        engine_list = [{
            'engine': 'dummy',
            'name': 'engine1',
            'shortcut': 'e1'
        }]

        initialize(engine_list)
Exemplo n.º 2
0
    def test_bang_autocomplete_empty(self):
        initialize()
        query = RawTextQuery('the query !', [])
        self.assertEqual(query.autocomplete_list,
                         ['!images', '!wikipedia', '!osm'])

        query = RawTextQuery('the query ?', ['osm'])
        self.assertEqual(query.autocomplete_list, ['?images', '?wikipedia'])
Exemplo n.º 3
0
    def test_bang_autocomplete(self):
        initialize(TEST_ENGINES)
        query = RawTextQuery('the query !dum', [])
        self.assertEqual(query.autocomplete_list, ['!dummy_engine'])

        query = RawTextQuery('!dum the query', [])
        self.assertEqual(query.autocomplete_list, [])
        self.assertEqual(query.getQuery(), '!dum the query')
Exemplo n.º 4
0
    def test_bang_autocomplete_empty(self):
        with patch.object(searx.engines, 'initialize_engines',
                          searx.engines.load_engines):
            initialize()
            query = RawTextQuery('the query !', [])
            self.assertEqual(query.autocomplete_list,
                             ['!images', '!wikipedia', '!osm'])

            query = RawTextQuery('the query ?', ['osm'])
            self.assertEqual(query.autocomplete_list,
                             ['?images', '?wikipedia'])
Exemplo n.º 5
0
    def test_bang(self):
        initialize(TEST_ENGINES)

        for bang in TestBang.SPECIFIC_BANGS + TestBang.NOT_SPECIFIC_BANGS:
            with self.subTest(msg="Check bang", bang=bang):
                query_text = TestBang.THE_QUERY + ' ' + bang
                query = RawTextQuery(query_text, [])

                self.assertEqual(query.getFullQuery(),
                                 bang + ' ' + TestBang.THE_QUERY)
                self.assertEqual(query.query_parts, [bang])
                self.assertEqual(query.user_query_parts,
                                 TestBang.THE_QUERY.split(' '))
Exemplo n.º 6
0
# see https://flask.palletsprojects.com/en/1.1.x/cli/
# True if "FLASK_APP=searx/webapp.py FLASK_ENV=development flask run"
flask_run_development = \
    os.environ.get("FLASK_APP") is not None\
    and os.environ.get("FLASK_ENV") == 'development'\
    and is_flask_run_cmdline()

# True if reload feature is activated of werkzeug, False otherwise (including uwsgi, etc..)
#  __name__ != "__main__" if searx.webapp is imported (make test, make docs, uwsgi...)
# see run() at the end of this file : searx_debug activates the reload feature.
werkzeug_reloader = flask_run_development or (searx_debug and __name__ == "__main__")

# initialize the engines except on the first run of the werkzeug server.
if not werkzeug_reloader\
   or (werkzeug_reloader and os.environ.get("WERKZEUG_RUN_MAIN") == "true"):
    initialize()

babel = Babel(app)

rtl_locales = ['ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'fa_IR', 'glk', 'he',
               'ku', 'mzn', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']

# used when translating category names
_category_names = (gettext('files'),
                   gettext('general'),
                   gettext('music'),
                   gettext('social media'),
                   gettext('images'),
                   gettext('videos'),
                   gettext('it'),
                   gettext('news'),
Exemplo n.º 7
0
 def test_bang_not_found(self):
     initialize(TEST_ENGINES)
     query = RawTextQuery('the query !bang_not_found', [])
     self.assertEqual(query.getFullQuery(), 'the query !bang_not_found')