forked from Archives/searxng
commit
ab4456b0d0
@ -1,2 +0,0 @@
|
|||||||
# compatibility with searx/searx
|
|
||||||
from searx.network import raise_for_httperror
|
|
@ -1,5 +1,47 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
|
import aiounittest
|
||||||
|
|
||||||
os.environ['SEARX_DEBUG'] = '1'
|
os.environ['SEARX_DEBUG'] = '1'
|
||||||
os.environ['SEARX_DISABLE_ETC_SETTINGS'] = '1'
|
os.environ['SEARX_DISABLE_ETC_SETTINGS'] = '1'
|
||||||
os.environ.pop('SEARX_SETTINGS_PATH', None)
|
os.environ.pop('SEARX_SETTINGS_PATH', None)
|
||||||
|
|
||||||
|
|
||||||
|
class SearxTestLayer:
|
||||||
|
"""Base layer for non-robot tests."""
|
||||||
|
|
||||||
|
__name__ = 'SearxTestLayer'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUp(cls):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDown(cls):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def testSetUp(cls):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def testTearDown(cls):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SearxTestCase(aiounittest.AsyncTestCase):
|
||||||
|
"""Base test case for non-robot tests."""
|
||||||
|
|
||||||
|
layer = SearxTestLayer
|
||||||
|
|
||||||
|
def setattr4test(self, obj, attr, value):
|
||||||
|
"""
|
||||||
|
setattr(obj, attr, value)
|
||||||
|
but reset to the previous value in the cleanup.
|
||||||
|
"""
|
||||||
|
previous_value = getattr(obj, attr)
|
||||||
|
|
||||||
|
def cleanup_patch():
|
||||||
|
setattr(obj, attr, previous_value)
|
||||||
|
self.addCleanup(cleanup_patch)
|
||||||
|
setattr(obj, attr, value)
|
||||||
|
@ -1,76 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
url = "http://localhost:11111/"
|
|
||||||
|
|
||||||
|
|
||||||
def test_index(browser):
|
|
||||||
# Visit URL
|
|
||||||
browser.visit(url)
|
|
||||||
assert browser.is_text_present('about')
|
|
||||||
|
|
||||||
|
|
||||||
def test_404(browser):
|
|
||||||
# Visit URL
|
|
||||||
browser.visit(url + 'missing_link')
|
|
||||||
assert browser.is_text_present('Page not found')
|
|
||||||
|
|
||||||
|
|
||||||
def test_about(browser):
|
|
||||||
browser.visit(url)
|
|
||||||
browser.click_link_by_text('about')
|
|
||||||
assert browser.is_text_present('Why use it?')
|
|
||||||
|
|
||||||
|
|
||||||
def test_preferences(browser):
|
|
||||||
browser.visit(url)
|
|
||||||
browser.click_link_by_text('preferences')
|
|
||||||
assert browser.is_text_present('Preferences')
|
|
||||||
assert browser.is_text_present('Cookies')
|
|
||||||
|
|
||||||
assert browser.is_element_present_by_xpath('//label[@for="checkbox_dummy"]')
|
|
||||||
|
|
||||||
|
|
||||||
def test_preferences_engine_select(browser):
|
|
||||||
browser.visit(url)
|
|
||||||
browser.click_link_by_text('preferences')
|
|
||||||
|
|
||||||
assert browser.is_element_present_by_xpath('//a[@href="#tab_engine"]')
|
|
||||||
browser.find_by_xpath('//a[@href="#tab_engine"]').first.click()
|
|
||||||
|
|
||||||
assert not browser.find_by_xpath('//input[@id="engine_general_dummy__general"]').first.checked
|
|
||||||
browser.find_by_xpath('//label[@for="engine_general_dummy__general"]').first.check()
|
|
||||||
browser.find_by_xpath('//input[@value="save"]').first.click()
|
|
||||||
|
|
||||||
# waiting for the redirect - without this the test is flaky..
|
|
||||||
sleep(1)
|
|
||||||
|
|
||||||
browser.visit(url)
|
|
||||||
browser.click_link_by_text('preferences')
|
|
||||||
browser.find_by_xpath('//a[@href="#tab_engine"]').first.click()
|
|
||||||
|
|
||||||
assert browser.find_by_xpath('//input[@id="engine_general_dummy__general"]').first.checked
|
|
||||||
|
|
||||||
|
|
||||||
def test_preferences_locale(browser):
|
|
||||||
browser.visit(url)
|
|
||||||
browser.click_link_by_text('preferences')
|
|
||||||
|
|
||||||
browser.find_by_xpath('//a[@href="#tab_ui"]').first.click()
|
|
||||||
browser.select('locale', 'hu')
|
|
||||||
browser.find_by_xpath('//input[@value="save"]').first.click()
|
|
||||||
|
|
||||||
# waiting for the redirect - without this the test is flaky..
|
|
||||||
sleep(1)
|
|
||||||
|
|
||||||
browser.visit(url)
|
|
||||||
browser.click_link_by_text('beállítások')
|
|
||||||
browser.is_text_present('Beállítások')
|
|
||||||
|
|
||||||
|
|
||||||
def test_search(browser):
|
|
||||||
browser.visit(url)
|
|
||||||
browser.fill('q', 'test search query')
|
|
||||||
browser.find_by_xpath('//button[@type="submit"]').first.click()
|
|
||||||
assert browser.is_text_present('didn\'t find any results')
|
|
@ -0,0 +1,78 @@
|
|||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# lint: pylint
|
||||||
|
# pylint: disable=missing-module-docstring,missing-function-docstring
|
||||||
|
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
url = "http://localhost:11111/"
|
||||||
|
|
||||||
|
|
||||||
|
def test_index(browser):
|
||||||
|
# Visit URL
|
||||||
|
browser.visit(url)
|
||||||
|
assert browser.is_text_present('about')
|
||||||
|
|
||||||
|
|
||||||
|
def test_404(browser):
|
||||||
|
# Visit URL
|
||||||
|
browser.visit(url + 'missing_link')
|
||||||
|
assert browser.is_text_present('Page not found')
|
||||||
|
|
||||||
|
|
||||||
|
def test_about(browser):
|
||||||
|
browser.visit(url)
|
||||||
|
browser.click_link_by_text('about')
|
||||||
|
assert browser.is_text_present('Why use it?')
|
||||||
|
|
||||||
|
|
||||||
|
def test_preferences(browser):
|
||||||
|
browser.visit(url)
|
||||||
|
browser.click_link_by_text('preferences')
|
||||||
|
assert browser.is_text_present('Preferences')
|
||||||
|
assert browser.is_text_present('Cookies')
|
||||||
|
|
||||||
|
assert browser.is_element_present_by_xpath('//label[@for="checkbox_dummy"]')
|
||||||
|
|
||||||
|
|
||||||
|
def test_preferences_engine_select(browser):
|
||||||
|
browser.visit(url)
|
||||||
|
browser.click_link_by_text('preferences')
|
||||||
|
|
||||||
|
assert browser.is_element_present_by_xpath('//a[@href="#tab_engine"]')
|
||||||
|
browser.find_by_xpath('//a[@href="#tab_engine"]').first.click()
|
||||||
|
|
||||||
|
assert not browser.find_by_xpath('//input[@id="engine_general_dummy__general"]').first.checked
|
||||||
|
browser.find_by_xpath('//label[@for="engine_general_dummy__general"]').first.check()
|
||||||
|
browser.find_by_xpath('//input[@value="save"]').first.click()
|
||||||
|
|
||||||
|
# waiting for the redirect - without this the test is flaky..
|
||||||
|
sleep(1)
|
||||||
|
|
||||||
|
browser.visit(url)
|
||||||
|
browser.click_link_by_text('preferences')
|
||||||
|
browser.find_by_xpath('//a[@href="#tab_engine"]').first.click()
|
||||||
|
|
||||||
|
assert browser.find_by_xpath('//input[@id="engine_general_dummy__general"]').first.checked
|
||||||
|
|
||||||
|
|
||||||
|
def test_preferences_locale(browser):
|
||||||
|
browser.visit(url)
|
||||||
|
browser.click_link_by_text('preferences')
|
||||||
|
|
||||||
|
browser.find_by_xpath('//a[@href="#tab_ui"]').first.click()
|
||||||
|
browser.select('locale', 'hu')
|
||||||
|
browser.find_by_xpath('//input[@value="save"]').first.click()
|
||||||
|
|
||||||
|
# waiting for the redirect - without this the test is flaky..
|
||||||
|
sleep(1)
|
||||||
|
|
||||||
|
browser.visit(url)
|
||||||
|
browser.click_link_by_text('beállítások')
|
||||||
|
browser.is_text_present('Beállítások')
|
||||||
|
|
||||||
|
|
||||||
|
def test_search(browser):
|
||||||
|
browser.visit(url)
|
||||||
|
browser.fill('q', 'test search query')
|
||||||
|
browser.find_by_xpath('//button[@type="submit"]').first.click()
|
||||||
|
assert browser.is_text_present('didn\'t find any results')
|
Loading…
Reference in New Issue