Browse Source

add robot tests

Matej Cotman 11 years ago
parent
commit
6624dd51f5
4 changed files with 67 additions and 103 deletions
  1. 17
    0
      .travis.yml
  2. 6
    0
      searx/engines/dummy.py
  3. 8
    103
      searx/settings_robot.yml
  4. 36
    0
      searx/tests/robot/test_basic.robot

+ 17
- 0
.travis.yml View File

@@ -0,0 +1,17 @@
1
+language: python
2
+python:
3
+  - "2.7"
4
+before_install:
5
+  - "export DISPLAY=:99.0"
6
+  - "sh -e /etc/init.d/xvfb start"
7
+install:
8
+  - "make"
9
+script:
10
+  - "make tests"
11
+  - "make robot"
12
+notifications:
13
+  irc:
14
+    channels:
15
+      - "irc.freenode.org#searx"
16
+    template:
17
+      - "%{repository}/#%{build_number}/%{branch} (%{author}): %{message} %{build_url}"

+ 6
- 0
searx/engines/dummy.py View File

@@ -0,0 +1,6 @@
1
+def request(query, params):
2
+    return params
3
+
4
+
5
+def response(resp):
6
+    return []

+ 8
- 103
searx/settings_robot.yml View File

@@ -6,109 +6,14 @@ server:
6 6
     base_url: False
7 7
 
8 8
 engines:
9
-  - name : wikipedia
10
-    engine : mediawiki
11
-    url    : https://en.wikipedia.org/
12
-    number_of_results : 1
13
-
14
-  - name : bing
15
-    engine : bing
16
-    locale : en-US
17
-
18
-  - name : currency
19
-    engine : currency_convert
9
+  - name : general_dummy
10
+    engine : dummy
20 11
     categories : general
21 12
 
22
-  - name : deviantart
23
-    engine : deviantart
24
-    categories : images
25
-
26
-  - name : ddg definitions
27
-    engine : duckduckgo_definitions
28
-
29
-  - name : duckduckgo
30
-    engine : duckduckgo
31
-    locale : en-us
32
-
33
-  - name : filecrop
34
-    engine : filecrop
35
-    categories : files
36
-
37
-  - name : flickr
38
-    engine : flickr
39
-    categories : images
40
-
41
-  - name : github
42
-    engine : github
43
-    categories : it
44
-
45
-  - name : google
46
-    engine        : json_engine
47
-    search_url    : https://ajax.googleapis.com/ajax/services/search/web?v=2.0&start=0&rsz=large&safe=off&filter=off&q={query}
48
-    categories    : general
49
-    url_query     : /responseData/results/unescapedUrl
50
-    content_query : /responseData/results/content
51
-    title_query   : /responseData/results/titleNoFormatting
52
-
53
-  - name : google images
54
-    engine : google_images
55
-    categories : images
56
-
57
-  - name : piratebay
58
-    engine : piratebay
59
-    categories : videos, music, files
60
-
61
-  - name : soundcloud
62
-    engine : soundcloud
63
-    categories : music
64
-
65
-  - name : stackoverflow
66
-    engine : stackoverflow
67
-    categories : it
68
-
69
-  - name : startpage
70
-    engine : startpage
71
-    base_url : 'https://startpage.com/'
72
-    search_url : 'https://startpage.com/do/search'
73
-
74
-  - name : ixquick
75
-    engine : startpage
76
-    base_url : 'https://www.ixquick.com/'
77
-    search_url : 'https://www.ixquick.com/do/search'
78
-
79
-  - name : twitter
80
-    engine : twitter
81
-    categories : social media
82
-
83
-  - name : urbandictionary
84
-    engine        : xpath
85
-    search_url    : http://www.urbandictionary.com/define.php?term={query}
86
-    url_xpath     : //div[@class="word"]//a/@href
87
-    title_xpath   : //div[@class="word"]//a
88
-    content_xpath : //div[@class="definition"]
89
-
90
-  - name : yahoo
91
-    engine           : xpath
92
-    search_url       : http://search.yahoo.com/search?p={query}
93
-    results_xpath    : //div[@class="res"]
94
-    url_xpath        : .//h3/a/@href
95
-    title_xpath      : .//h3/a
96
-    content_xpath    : .//div[@class="abstr"]
97
-    suggestion_xpath : //div[@id="satat"]//a
98
-
99
-  - name : youtube
100
-    engine : youtube
101
-    categories : videos
102
-
103
-  - name : dailymotion
104
-    engine : dailymotion
105
-    locale : en_US
106
-    categories : videos
13
+  - name : dummy_dummy
14
+    engine : dummy
15
+    categories : dummy
107 16
 
108
-  - name : vimeo
109
-    engine : vimeo
110
-    categories : videos
111
-    results_xpath : //div[@id="browse_content"]/ol/li
112
-    url_xpath : ./a/@href
113
-    title_xpath : ./a/div[@class="data"]/p[@class="title"]/text()
114
-    content_xpath : ./a/img/@src
17
+locales:
18
+    en : English
19
+    hu : Magyar

+ 36
- 0
searx/tests/robot/test_basic.robot View File

@@ -9,3 +9,39 @@ Front page
9 9
     Page Should Contain  about
10 10
     Page Should Contain  preferences
11 11
 
12
+About page
13
+    Click Element  link=about
14
+    Page Should Contain  Why use Searx?
15
+    Page Should Contain Element  link=search engines
16
+
17
+Engines page
18
+    Go To  http://localhost:11111/engines
19
+    Page Should Contain  Currently used search engines
20
+    Page Should Contain  dummy_dummy
21
+    Page Should Contain  general_dummy
22
+
23
+Preferences page
24
+    Click Element  link=preferences
25
+    Page Should Contain  Preferences
26
+    Page Should Contain  Default categories
27
+
28
+Switch category
29
+    Go To  http://localhost:11111/preferences
30
+    Page Should Contain Checkbox  category_general
31
+    Page Should Contain Checkbox  category_dummy
32
+    Click Element  xpath=//*[.="general"]
33
+    Click Element  xpath=//*[.="dummy"]
34
+    Submit Form  id=search_form
35
+    Location Should Be  http://localhost:11111/
36
+    Checkbox Should Not Be Selected  category_general
37
+    Checkbox Should Be Selected  category_dummy
38
+
39
+Change language
40
+    Page Should Contain  about
41
+    Page Should Contain  preferences
42
+    Go To  http://localhost:11111/preferences
43
+    Select From List  locale  hu
44
+    Submit Form  id=search_form
45
+    Location Should Be  http://localhost:11111/
46
+    Page Should Contain  rólunk
47
+    Page Should Contain  beállítások