__init__.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # -*- coding: utf-8 -*-
  2. from time import sleep
  3. url = "http://localhost:11111/"
  4. def test_index(browser):
  5. # Visit URL
  6. browser.visit(url)
  7. assert browser.is_text_present('searx')
  8. def test_404(browser):
  9. # Visit URL
  10. browser.visit(url + 'missing_link')
  11. assert browser.is_text_present('Page not found')
  12. def test_about(browser):
  13. browser.visit(url)
  14. browser.links.find_by_href('/about').click()
  15. assert browser.is_text_present('Why use searx?')
  16. def test_preferences(browser):
  17. browser.visit(url)
  18. browser.links.find_by_href('/preferences').click()
  19. assert browser.is_text_present('Preferences')
  20. assert browser.is_text_present('Cookies')
  21. assert browser.is_element_present_by_xpath('//label[@for="checkbox_dummy"]')
  22. def test_preferences_engine_select(browser):
  23. browser.visit(url)
  24. browser.links.find_by_href('/preferences').click()
  25. assert browser.is_element_present_by_xpath('//a[@href="#tab_engine"]')
  26. browser.find_by_xpath('//a[@href="#tab_engine"]').first.click()
  27. assert not browser.find_by_xpath('//input[@id="engine_general_dummy__general"]').first.checked
  28. browser.find_by_xpath('//label[@for="engine_general_dummy__general"]').first.check()
  29. browser.find_by_xpath('//input[@value="save"]').first.click()
  30. # waiting for the redirect - without this the test is flaky..
  31. sleep(1)
  32. browser.visit(url)
  33. browser.links.find_by_href('/preferences').click()
  34. browser.find_by_xpath('//a[@href="#tab_engine"]').first.click()
  35. assert browser.find_by_xpath('//input[@id="engine_general_dummy__general"]').first.checked
  36. def test_preferences_locale(browser):
  37. browser.visit(url)
  38. browser.links.find_by_href('/preferences').click()
  39. browser.select('locale', 'hu')
  40. browser.find_by_xpath('//input[@value="save"]').first.click()
  41. # waiting for the redirect - without this the test is flaky..
  42. sleep(1)
  43. browser.visit(url)
  44. browser.links.find_by_text('beállítások').click()
  45. browser.is_text_present('Beállítások')
  46. def test_search(browser):
  47. browser.visit(url)
  48. browser.fill('q', 'test search query')
  49. browser.find_by_xpath('//button[@type="submit"]').first.click()
  50. assert browser.is_text_present('didn\'t find any results')