Merge lp:~marcustomlinson/unity-js-scopes/add-harness-tests into lp:unity-js-scopes
- add-harness-tests
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 113 | ||||
Proposed branch: | lp:~marcustomlinson/unity-js-scopes/add-harness-tests | ||||
Merge into: | lp:unity-js-scopes | ||||
Diff against target: |
615 lines (+507/-1) 16 files modified
CMakeLists.txt (+9/-0) debian/control (+2/-1) src/bindings/CMakeLists.txt (+16/-0) src/launcher/CMakeLists.txt (+10/-0) tests/CMakeLists.txt (+1/-0) tests/owm_scope/CMakeLists.txt (+2/-0) tests/owm_scope/scope/CMakeLists.txt (+11/-0) tests/owm_scope/scope/owm_scope.ini (+5/-0) tests/owm_scope/scope/owm_scope.js (+197/-0) tests/owm_scope/tests/CMakeLists.txt (+22/-0) tests/owm_scope/tests/server/forecast/London,uk.json (+1/-0) tests/owm_scope/tests/server/forecast/Manchester,uk.json (+1/-0) tests/owm_scope/tests/server/server.py (+78/-0) tests/owm_scope/tests/server/weather/London,uk.json (+1/-0) tests/owm_scope/tests/server/weather/Manchester,uk.json (+1/-0) tests/owm_scope/tests/test-scope.py (+150/-0) |
||||
To merge this branch: | bzr merge lp:~marcustomlinson/unity-js-scopes/add-harness-tests | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
WebApps | Pending | ||
Review via email: mp+276953@code.launchpad.net |
Commit message
Add initial integration level tests using the scope-harness testing framework
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
- 108. By Marcus Tomlinson
-
Added missing copyrights
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:108
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 109. By Marcus Tomlinson
-
Add google-mock to dependancies
- 110. By Marcus Tomlinson
-
Actually, add cmake-extras
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:110
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 111. By Marcus Tomlinson
-
Add google-mock to dependancies
- 112. By Marcus Tomlinson
-
Add python3-
scope-harness dependancy - 113. By Marcus Tomlinson
-
Clean up
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:111
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:113
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2015-10-25 19:03:30 +0000 | |||
3 | +++ CMakeLists.txt 2015-11-09 15:16:03 +0000 | |||
4 | @@ -69,3 +69,12 @@ | |||
5 | 69 | DESTINATION /usr/share/qtcreator/templates/wizards/ubuntu) | 69 | DESTINATION /usr/share/qtcreator/templates/wizards/ubuntu) |
6 | 70 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/qtc-templates/scope-js | 70 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/qtc-templates/scope-js |
7 | 71 | DESTINATION /usr/ubuntu-sdk-ide/share/qtcreator/templates/wizards/ubuntu) | 71 | DESTINATION /usr/ubuntu-sdk-ide/share/qtcreator/templates/wizards/ubuntu) |
8 | 72 | |||
9 | 73 | # Set up the tests | ||
10 | 74 | enable_testing() | ||
11 | 75 | add_subdirectory(tests) | ||
12 | 76 | |||
13 | 77 | add_custom_target( | ||
14 | 78 | check | ||
15 | 79 | ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure | ||
16 | 80 | ) | ||
17 | 72 | 81 | ||
18 | === modified file 'debian/control' | |||
19 | --- debian/control 2015-10-27 14:43:23 +0000 | |||
20 | +++ debian/control 2015-11-09 15:16:03 +0000 | |||
21 | @@ -5,9 +5,10 @@ | |||
22 | 5 | Build-Depends: bzr, | 5 | Build-Depends: bzr, |
23 | 6 | cmake (>= 2.8.9), | 6 | cmake (>= 2.8.9), |
24 | 7 | debhelper (>= 9), | 7 | debhelper (>= 9), |
25 | 8 | g++, | ||
26 | 8 | pkg-config, | 9 | pkg-config, |
27 | 9 | python3, | 10 | python3, |
29 | 10 | g++, | 11 | python3-scope-harness, |
30 | 11 | libboost-filesystem-dev, | 12 | libboost-filesystem-dev, |
31 | 12 | libunity-scopes-dev, | 13 | libunity-scopes-dev, |
32 | 13 | Standards-Version: 3.9.5 | 14 | Standards-Version: 3.9.5 |
33 | 14 | 15 | ||
34 | === modified file 'src/bindings/CMakeLists.txt' | |||
35 | --- src/bindings/CMakeLists.txt 2015-10-08 20:34:00 +0000 | |||
36 | +++ src/bindings/CMakeLists.txt 2015-11-09 15:16:03 +0000 | |||
37 | @@ -87,6 +87,22 @@ | |||
38 | 87 | ${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NODEJS_ADDON_BIN_NAME}.node | 87 | ${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NODEJS_ADDON_BIN_NAME}.node |
39 | 88 | ) | 88 | ) |
40 | 89 | 89 | ||
41 | 90 | add_custom_command( | ||
42 | 91 | TARGET ${SCOPE_NODEJS_ADDON_BIN_NAME} POST_BUILD | ||
43 | 92 | COMMAND ${CMAKE_COMMAND} -E make_directory | ||
44 | 93 | "${CMAKE_BINARY_DIR}/tests/node_modules/unity-js-scopes/lib" | ||
45 | 94 | |||
46 | 95 | COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
47 | 96 | "${CMAKE_CURRENT_BINARY_DIR}/unity_js_scopes_bindings.node" | ||
48 | 97 | "${CMAKE_BINARY_DIR}/tests/node_modules/unity-js-scopes" | ||
49 | 98 | COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
50 | 99 | "${CMAKE_CURRENT_SOURCE_DIR}/index.js" | ||
51 | 100 | "${CMAKE_BINARY_DIR}/tests/node_modules/unity-js-scopes" | ||
52 | 101 | COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
53 | 102 | "${CMAKE_CURRENT_SOURCE_DIR}/lib/scope-core.js" | ||
54 | 103 | "${CMAKE_BINARY_DIR}/tests/node_modules/unity-js-scopes/lib" | ||
55 | 104 | ) | ||
56 | 105 | |||
57 | 90 | install(DIRECTORY ${CMAKE_SOURCE_DIR}/deps/io.js/deps/npm | 106 | install(DIRECTORY ${CMAKE_SOURCE_DIR}/deps/io.js/deps/npm |
58 | 91 | DESTINATION /node_modules | 107 | DESTINATION /node_modules |
59 | 92 | USE_SOURCE_PERMISSIONS | 108 | USE_SOURCE_PERMISSIONS |
60 | 93 | 109 | ||
61 | === modified file 'src/launcher/CMakeLists.txt' | |||
62 | --- src/launcher/CMakeLists.txt 2015-09-30 06:10:51 +0000 | |||
63 | +++ src/launcher/CMakeLists.txt 2015-11-09 15:16:03 +0000 | |||
64 | @@ -68,5 +68,15 @@ | |||
65 | 68 | ${Boost_LIBRARIES} | 68 | ${Boost_LIBRARIES} |
66 | 69 | ) | 69 | ) |
67 | 70 | 70 | ||
68 | 71 | add_custom_command( | ||
69 | 72 | TARGET ${LAUNCHER_EXECUTABLE_NAME} POST_BUILD | ||
70 | 73 | COMMAND ${CMAKE_COMMAND} -E make_directory | ||
71 | 74 | "${CMAKE_BINARY_DIR}/tests/node_modules/unity-js-scopes/bin" | ||
72 | 75 | |||
73 | 76 | COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
74 | 77 | "${CMAKE_CURRENT_BINARY_DIR}/unity-js-scopes-launcher" | ||
75 | 78 | "${CMAKE_BINARY_DIR}/tests/node_modules/unity-js-scopes/bin" | ||
76 | 79 | ) | ||
77 | 80 | |||
78 | 71 | install(TARGETS ${LAUNCHER_EXECUTABLE_NAME} | 81 | install(TARGETS ${LAUNCHER_EXECUTABLE_NAME} |
79 | 72 | RUNTIME DESTINATION /usr/bin) | 82 | RUNTIME DESTINATION /usr/bin) |
80 | 73 | 83 | ||
81 | === added file 'tests/CMakeLists.txt' | |||
82 | --- tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
83 | +++ tests/CMakeLists.txt 2015-11-09 15:16:03 +0000 | |||
84 | @@ -0,0 +1,1 @@ | |||
85 | 1 | add_subdirectory(owm_scope) | ||
86 | 0 | 2 | ||
87 | === added directory 'tests/owm_scope' | |||
88 | === added file 'tests/owm_scope/CMakeLists.txt' | |||
89 | --- tests/owm_scope/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
90 | +++ tests/owm_scope/CMakeLists.txt 2015-11-09 15:16:03 +0000 | |||
91 | @@ -0,0 +1,2 @@ | |||
92 | 1 | add_subdirectory(scope) | ||
93 | 2 | add_subdirectory(tests) | ||
94 | 0 | 3 | ||
95 | === added directory 'tests/owm_scope/scope' | |||
96 | === added file 'tests/owm_scope/scope/CMakeLists.txt' | |||
97 | --- tests/owm_scope/scope/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
98 | +++ tests/owm_scope/scope/CMakeLists.txt 2015-11-09 15:16:03 +0000 | |||
99 | @@ -0,0 +1,11 @@ | |||
100 | 1 | configure_file( | ||
101 | 2 | "owm_scope.ini" | ||
102 | 3 | "${CMAKE_CURRENT_BINARY_DIR}/owm_scope.ini" | ||
103 | 4 | @ONLY COPYONLY | ||
104 | 5 | ) | ||
105 | 6 | |||
106 | 7 | configure_file( | ||
107 | 8 | "owm_scope.js" | ||
108 | 9 | "${CMAKE_CURRENT_BINARY_DIR}/owm_scope.js" | ||
109 | 10 | @ONLY COPYONLY | ||
110 | 11 | ) | ||
111 | 0 | 12 | ||
112 | === added file 'tests/owm_scope/scope/owm_scope.ini' | |||
113 | --- tests/owm_scope/scope/owm_scope.ini 1970-01-01 00:00:00 +0000 | |||
114 | +++ tests/owm_scope/scope/owm_scope.ini 2015-11-09 15:16:03 +0000 | |||
115 | @@ -0,0 +1,5 @@ | |||
116 | 1 | [ScopeConfig] | ||
117 | 2 | ScopeRunner=../../node_modules/unity-js-scopes/bin/unity-js-scopes-launcher %S %R | ||
118 | 3 | DisplayName=OpenWeatherMap Test Scope | ||
119 | 4 | Description=This is an OpenWeatherMap test scope | ||
120 | 5 | Author=WebApps <webapps@lists.launchpad.net> | ||
121 | 0 | 6 | ||
122 | === added file 'tests/owm_scope/scope/owm_scope.js' | |||
123 | --- tests/owm_scope/scope/owm_scope.js 1970-01-01 00:00:00 +0000 | |||
124 | +++ tests/owm_scope/scope/owm_scope.js 2015-11-09 15:16:03 +0000 | |||
125 | @@ -0,0 +1,197 @@ | |||
126 | 1 | /* | ||
127 | 2 | * Copyright 2015 Canonical Ltd. | ||
128 | 3 | * | ||
129 | 4 | * This file is part of unity-js-scopes. | ||
130 | 5 | * | ||
131 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
132 | 7 | * it under the terms of the GNU General Public License as published by | ||
133 | 8 | * the Free Software Foundation; version 3. | ||
134 | 9 | * | ||
135 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
136 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
137 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
138 | 13 | * GNU General Public License for more details. | ||
139 | 14 | * | ||
140 | 15 | * You should have received a copy of the GNU General Public License | ||
141 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
142 | 17 | */ | ||
143 | 18 | |||
144 | 19 | var scopes = require('unity-js-scopes') | ||
145 | 20 | var http = require('http'); | ||
146 | 21 | |||
147 | 22 | var query_host = process.env.NETWORK_SCOPE_APIROOT ? process.env.NETWORK_SCOPE_APIROOT : "api.openweathermap.org"; | ||
148 | 23 | var query_host_port = process.env.NETWORK_SCOPE_APIPORT ? process.env.NETWORK_SCOPE_APIPORT : 80; | ||
149 | 24 | var current_weather_path = "/data/2.5/weather?units=metric&APPID=2b12bf09b4e0ab0c1aa5e32a9a3f0cdc&q=" | ||
150 | 25 | var forecast_weather_path = "/data/2.5/forecast/daily?units=metric&cnt=7&APPID=2b12bf09b4e0ab0c1aa5e32a9a3f0cdc&q=" | ||
151 | 26 | |||
152 | 27 | var CURRENT_TEMPLATE = { | ||
153 | 28 | "schema-version": 1, | ||
154 | 29 | "template": { | ||
155 | 30 | "category-layout": "grid", | ||
156 | 31 | "card-size": "medium" | ||
157 | 32 | }, | ||
158 | 33 | "components": { | ||
159 | 34 | "title": "title", | ||
160 | 35 | "art": { | ||
161 | 36 | "field": "art" | ||
162 | 37 | }, | ||
163 | 38 | "subtitle": "subtitle" | ||
164 | 39 | } | ||
165 | 40 | } | ||
166 | 41 | |||
167 | 42 | var FORECAST_TEMPLATE = { | ||
168 | 43 | "schema-version": 1, | ||
169 | 44 | "template": { | ||
170 | 45 | "category-layout": "grid", | ||
171 | 46 | "card-layout": "horizontal", | ||
172 | 47 | "card-size": "small" | ||
173 | 48 | }, | ||
174 | 49 | "components": { | ||
175 | 50 | "title": "title", | ||
176 | 51 | "art" : { | ||
177 | 52 | "field": "art" | ||
178 | 53 | }, | ||
179 | 54 | "subtitle": "subtitle" | ||
180 | 55 | } | ||
181 | 56 | } | ||
182 | 57 | |||
183 | 58 | scopes.self.initialize( | ||
184 | 59 | {} | ||
185 | 60 | , | ||
186 | 61 | { | ||
187 | 62 | run: function() { | ||
188 | 63 | console.log('Running...') | ||
189 | 64 | }, | ||
190 | 65 | start: function(scope_id) { | ||
191 | 66 | console.log('Starting scope id: ' | ||
192 | 67 | + scope_id | ||
193 | 68 | + ', ' | ||
194 | 69 | + scopes.self.scope_directory) | ||
195 | 70 | }, | ||
196 | 71 | search: function(canned_query, metadata) { | ||
197 | 72 | return new scopes.lib.SearchQuery( | ||
198 | 73 | canned_query, | ||
199 | 74 | metadata, | ||
200 | 75 | // run | ||
201 | 76 | function(search_reply) { | ||
202 | 77 | var qs = canned_query.query_string(); | ||
203 | 78 | if (!qs) { | ||
204 | 79 | qs = "London,uk" | ||
205 | 80 | } | ||
206 | 81 | |||
207 | 82 | var current_weather_cb = function(response) { | ||
208 | 83 | var res = ''; | ||
209 | 84 | |||
210 | 85 | // Another chunk of data has been recieved, so append it to res | ||
211 | 86 | response.on('data', function(chunk) { | ||
212 | 87 | res += chunk; | ||
213 | 88 | }); | ||
214 | 89 | |||
215 | 90 | // The whole response has been recieved | ||
216 | 91 | response.on('end', function() { | ||
217 | 92 | r = JSON.parse(res); | ||
218 | 93 | |||
219 | 94 | var category_renderer = new scopes.lib.CategoryRenderer(JSON.stringify(CURRENT_TEMPLATE)); | ||
220 | 95 | var category = search_reply.register_category("current", r.name + ", " + r.sys.country, "", category_renderer); | ||
221 | 96 | |||
222 | 97 | var categorised_result = new scopes.lib.CategorisedResult(category); | ||
223 | 98 | categorised_result.set_uri(r.id.toString()); | ||
224 | 99 | categorised_result.set_title(r.main.temp.toString() + "°C"); | ||
225 | 100 | categorised_result.set_art("http://openweathermap.org/img/w/" + r.weather[0].icon + ".png"); | ||
226 | 101 | categorised_result.set("subtitle", r.weather[0].description); | ||
227 | 102 | categorised_result.set("description", "A description of the result"); | ||
228 | 103 | |||
229 | 104 | search_reply.push(categorised_result); | ||
230 | 105 | |||
231 | 106 | // Now call back into the API for a 7 day forecast | ||
232 | 107 | http.request({host: query_host, port: query_host_port, path: forecast_weather_path + qs}, forecase_weather_cb).end(); | ||
233 | 108 | }); | ||
234 | 109 | } | ||
235 | 110 | |||
236 | 111 | var forecase_weather_cb = function(response) { | ||
237 | 112 | var res = ''; | ||
238 | 113 | |||
239 | 114 | // Another chunk of data has been recieved, so append it to res | ||
240 | 115 | response.on('data', function(chunk) { | ||
241 | 116 | res += chunk; | ||
242 | 117 | }); | ||
243 | 118 | |||
244 | 119 | // The whole response has been recieved | ||
245 | 120 | response.on('end', function() { | ||
246 | 121 | try { | ||
247 | 122 | r = JSON.parse(res); | ||
248 | 123 | |||
249 | 124 | var category_renderer = new scopes.lib.CategoryRenderer(JSON.stringify(FORECAST_TEMPLATE)); | ||
250 | 125 | var category = search_reply.register_category("forecast", "7 day forecast", "", category_renderer); | ||
251 | 126 | |||
252 | 127 | for (i = 0; i < r.list.length; i++) { | ||
253 | 128 | var categorised_result = new scopes.lib.CategorisedResult(category); | ||
254 | 129 | categorised_result.set_uri(r.list[i].weather[0].id.toString()); | ||
255 | 130 | categorised_result.set_title(r.list[i].temp.min.toString() + "°C to " | ||
256 | 131 | + r.list[i].temp.max.toString() + "°C"); | ||
257 | 132 | categorised_result.set_art("http://openweathermap.org/img/w/" + r.list[i].weather[0].icon + ".png"); | ||
258 | 133 | categorised_result.set("subtitle", r.list[i].weather[0].description); | ||
259 | 134 | categorised_result.set("description", "A description of the result"); | ||
260 | 135 | |||
261 | 136 | search_reply.push(categorised_result); | ||
262 | 137 | } | ||
263 | 138 | |||
264 | 139 | // We are done, call finished() on our search_reply | ||
265 | 140 | search_reply.finished(); | ||
266 | 141 | } | ||
267 | 142 | catch(e) { | ||
268 | 143 | // Forecast not available | ||
269 | 144 | console.log("Forecast for '" + qs + "' is unavailable: " + e) | ||
270 | 145 | |||
271 | 146 | // We are done, call finished() on our search_reply | ||
272 | 147 | search_reply.finished(); | ||
273 | 148 | } | ||
274 | 149 | }); | ||
275 | 150 | } | ||
276 | 151 | |||
277 | 152 | http.request({host: query_host, port: query_host_port, path: current_weather_path + qs}, current_weather_cb).end(); | ||
278 | 153 | }, | ||
279 | 154 | // cancelled | ||
280 | 155 | function() { | ||
281 | 156 | }); | ||
282 | 157 | }, | ||
283 | 158 | preview: function(result, action_metadata) { | ||
284 | 159 | return new scopes.lib.PreviewQuery( | ||
285 | 160 | result, | ||
286 | 161 | action_metadata, | ||
287 | 162 | // run | ||
288 | 163 | function(preview_reply) { | ||
289 | 164 | var layout1col = new scopes.lib.ColumnLayout(1); | ||
290 | 165 | var layout2col = new scopes.lib.ColumnLayout(2); | ||
291 | 166 | var layout3col = new scopes.lib.ColumnLayout(3); | ||
292 | 167 | layout1col.add_column(["image", "header", "summary"]); | ||
293 | 168 | |||
294 | 169 | layout2col.add_column(["image"]); | ||
295 | 170 | layout2col.add_column(["header", "summary"]); | ||
296 | 171 | |||
297 | 172 | layout3col.add_column(["image"]); | ||
298 | 173 | layout3col.add_column(["header", "summary"]); | ||
299 | 174 | layout3col.add_column([]); | ||
300 | 175 | |||
301 | 176 | preview_reply.register_layout([layout1col, layout2col, layout3col]); | ||
302 | 177 | |||
303 | 178 | var header = new scopes.lib.PreviewWidget("header", "header"); | ||
304 | 179 | header.add_attribute_mapping("title", "title"); | ||
305 | 180 | header.add_attribute_mapping("subtitle", "subtitle"); | ||
306 | 181 | |||
307 | 182 | var image = new scopes.lib.PreviewWidget("image", "image"); | ||
308 | 183 | image.add_attribute_mapping("source", "art"); | ||
309 | 184 | |||
310 | 185 | var description = new scopes.lib.PreviewWidget("summary", "text"); | ||
311 | 186 | description.add_attribute_mapping("text", "description"); | ||
312 | 187 | |||
313 | 188 | preview_reply.push([image, header, description ]); | ||
314 | 189 | preview_reply.finished(); | ||
315 | 190 | }, | ||
316 | 191 | // cancelled | ||
317 | 192 | function() { | ||
318 | 193 | }); | ||
319 | 194 | } | ||
320 | 195 | } | ||
321 | 196 | ); | ||
322 | 197 | |||
323 | 0 | 198 | ||
324 | === added directory 'tests/owm_scope/tests' | |||
325 | === added file 'tests/owm_scope/tests/CMakeLists.txt' | |||
326 | --- tests/owm_scope/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
327 | +++ tests/owm_scope/tests/CMakeLists.txt 2015-11-09 15:16:03 +0000 | |||
328 | @@ -0,0 +1,22 @@ | |||
329 | 1 | file(GLOB_RECURSE | ||
330 | 2 | TEST_FIXTURES | ||
331 | 3 | "server/*.json" | ||
332 | 4 | "*.py" | ||
333 | 5 | ) | ||
334 | 6 | |||
335 | 7 | # Make these files show up in QtCreator | ||
336 | 8 | add_custom_target(hidden_test_fixtures ALL | ||
337 | 9 | SOURCES ${TEST_FIXTURES} | ||
338 | 10 | ) | ||
339 | 11 | |||
340 | 12 | # Where to find the scope ini file | ||
341 | 13 | set(TEST_SCOPE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../scope") | ||
342 | 14 | |||
343 | 15 | # Where to find the test server binary | ||
344 | 16 | set(FAKE_SERVER "${CMAKE_CURRENT_SOURCE_DIR}/server/server.py") | ||
345 | 17 | |||
346 | 18 | # Register the test with CTest | ||
347 | 19 | add_test( | ||
348 | 20 | owm_scope-tests | ||
349 | 21 | "${CMAKE_CURRENT_SOURCE_DIR}/test-scope.py" "owm_scope" "${TEST_SCOPE_DIRECTORY}/owm_scope.ini" "${FAKE_SERVER}" | ||
350 | 22 | ) | ||
351 | 0 | 23 | ||
352 | === added directory 'tests/owm_scope/tests/server' | |||
353 | === added directory 'tests/owm_scope/tests/server/forecast' | |||
354 | === added file 'tests/owm_scope/tests/server/forecast/London,uk.json' | |||
355 | --- tests/owm_scope/tests/server/forecast/London,uk.json 1970-01-01 00:00:00 +0000 | |||
356 | +++ tests/owm_scope/tests/server/forecast/London,uk.json 2015-11-09 15:16:03 +0000 | |||
357 | @@ -0,0 +1,1 @@ | |||
358 | 1 | {"cod":"200","message":0.1117,"city":{"id":2643743,"name":"London","coord":{"lon":-0.12574,"lat":51.50853},"country":"GB","population":0,"sys":{"population":0}},"cnt":7,"list":[{"dt":1407412800,"temp":{"day":23.33,"min":18.84,"max":25.09,"night":18.84,"eve":24.17,"morn":20.76},"pressure":1018.23,"humidity":83,"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"speed":1.87,"deg":295,"clouds":12,"rain":0.5},{"dt":1407499200,"temp":{"day":19.44,"min":15.54,"max":20.86,"night":15.54,"eve":18.28,"morn":16.21},"pressure":1010.57,"humidity":97,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"speed":4.01,"deg":143,"clouds":92,"rain":8},{"dt":1407585600,"temp":{"day":18.78,"min":13.19,"max":19.58,"night":13.19,"eve":18.95,"morn":14.03},"pressure":1010.78,"humidity":83,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"speed":5.46,"deg":281,"clouds":32},{"dt":1407672000,"temp":{"day":18.09,"min":13.46,"max":18.09,"night":13.46,"eve":16.58,"morn":13.91},"pressure":1002.33,"humidity":67,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"speed":10.68,"deg":162,"clouds":92,"rain":4},{"dt":1407758400,"temp":{"day":17.38,"min":15.39,"max":17.38,"night":16.3,"eve":17.03,"morn":15.39},"pressure":1008.2,"humidity":0,"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}],"speed":13.52,"deg":245,"clouds":74,"rain":12.63},{"dt":1407844800,"temp":{"day":18.44,"min":16.17,"max":18.44,"night":16.83,"eve":18.02,"morn":16.17},"pressure":1009.94,"humidity":0,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"speed":10.93,"deg":251,"clouds":60,"rain":5.25},{"dt":1407931200,"temp":{"day":18.8,"min":16.67,"max":19.02,"night":16.77,"eve":19.02,"morn":16.67},"pressure":1013.17,"humidity":0,"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"speed":9.88,"deg":275,"clouds":85,"rain":1.35}]} | ||
359 | 0 | 2 | ||
360 | === added file 'tests/owm_scope/tests/server/forecast/Manchester,uk.json' | |||
361 | --- tests/owm_scope/tests/server/forecast/Manchester,uk.json 1970-01-01 00:00:00 +0000 | |||
362 | +++ tests/owm_scope/tests/server/forecast/Manchester,uk.json 2015-11-09 15:16:03 +0000 | |||
363 | @@ -0,0 +1,1 @@ | |||
364 | 1 | {"cod":"200","message":0.0056,"city":{"id":2643123,"name":"Manchester","coord":{"lon":-2.23743,"lat":53.480949},"country":"GB","population":0,"sys":{"population":0}},"cnt":7,"list":[{"dt":1407412800,"temp":{"day":17.91,"min":11.96,"max":18.83,"night":11.96,"eve":18.01,"morn":16.13},"pressure":1014.82,"humidity":77,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":3.32,"deg":303,"clouds":0},{"dt":1407499200,"temp":{"day":18.59,"min":12.33,"max":18.59,"night":12.33,"eve":14.55,"morn":14.69},"pressure":1008.22,"humidity":79,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"speed":3.46,"deg":163,"clouds":92,"rain":11},{"dt":1407585600,"temp":{"day":15.8,"min":10.79,"max":17.11,"night":10.79,"eve":16.89,"morn":13.19},"pressure":1005.76,"humidity":92,"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],"speed":5.61,"deg":279,"clouds":56},{"dt":1407672000,"temp":{"day":15.29,"min":12.21,"max":15.98,"night":12.41,"eve":15.98,"morn":12.21},"pressure":995.36,"humidity":95,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"speed":10.75,"deg":137,"clouds":92,"rain":5},{"dt":1407758400,"temp":{"day":15.73,"min":12.99,"max":15.73,"night":13.8,"eve":15.23,"morn":12.99},"pressure":990.16,"humidity":0,"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"speed":9.02,"deg":239,"clouds":99,"rain":1.15},{"dt":1407844800,"temp":{"day":17.64,"min":14.08,"max":17.64,"night":14.08,"eve":14.92,"morn":14.12},"pressure":992.52,"humidity":0,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"speed":10.36,"deg":240,"clouds":45,"rain":4.84},{"dt":1407931200,"temp":{"day":14.35,"min":13.37,"max":15.52,"night":13.77,"eve":15.52,"morn":13.37},"pressure":999.39,"humidity":0,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"speed":7.79,"deg":285,"clouds":92,"rain":5.98}]} | ||
365 | 0 | 2 | ||
366 | === added file 'tests/owm_scope/tests/server/server.py' | |||
367 | --- tests/owm_scope/tests/server/server.py 1970-01-01 00:00:00 +0000 | |||
368 | +++ tests/owm_scope/tests/server/server.py 2015-11-09 15:16:03 +0000 | |||
369 | @@ -0,0 +1,78 @@ | |||
370 | 1 | #!/usr/bin/env python3 | ||
371 | 2 | |||
372 | 3 | # Copyright (C) 2015 Canonical Ltd. | ||
373 | 4 | |||
374 | 5 | # This library is free software; you can redistribute it and/or | ||
375 | 6 | # modify it under the terms of the GNU Lesser General Public | ||
376 | 7 | # License as published by the Free Software Foundation; either | ||
377 | 8 | # version 2.1 of the License, or (at your option) any later version. | ||
378 | 9 | |||
379 | 10 | # This library is distributed in the hope that it will be useful, | ||
380 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
381 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
382 | 13 | # Lesser General Public License for more details. | ||
383 | 14 | |||
384 | 15 | # You should have received a copy of the GNU Lesser General Public | ||
385 | 16 | # License along with this library; if not, write to the Free Software | ||
386 | 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
387 | 18 | # MA 02110-1301 USA | ||
388 | 19 | |||
389 | 20 | import http.server | ||
390 | 21 | import os | ||
391 | 22 | import socketserver | ||
392 | 23 | import sys | ||
393 | 24 | from urllib.parse import urlparse,parse_qs | ||
394 | 25 | |||
395 | 26 | def read_file(path): | ||
396 | 27 | file = os.path.join(os.path.dirname(__file__), path) | ||
397 | 28 | if os.path.isfile(file): | ||
398 | 29 | with open(file, 'r') as fp: | ||
399 | 30 | content = fp.read() | ||
400 | 31 | else: | ||
401 | 32 | content = '' | ||
402 | 33 | |||
403 | 34 | return content | ||
404 | 35 | |||
405 | 36 | class MyRequestHandler(http.server.BaseHTTPRequestHandler): | ||
406 | 37 | def do_GET(self): | ||
407 | 38 | sys.stderr.write("GET: %s\n" % self.path) | ||
408 | 39 | sys.stderr.flush() | ||
409 | 40 | |||
410 | 41 | parse = urlparse(self.path) | ||
411 | 42 | path = parse.path | ||
412 | 43 | query = parse_qs(parse.query) | ||
413 | 44 | |||
414 | 45 | if path == '/data/2.5/weather': | ||
415 | 46 | self.send_response(200) | ||
416 | 47 | self.send_header("Content-type", "text/html") | ||
417 | 48 | self.end_headers() | ||
418 | 49 | |||
419 | 50 | mode = 'json' | ||
420 | 51 | if 'mode' in query: | ||
421 | 52 | mode = query['mode'][0] | ||
422 | 53 | |||
423 | 54 | self.wfile.write(bytes(read_file('weather/%s.%s' % (query['q'][0], mode)), 'UTF-8')) | ||
424 | 55 | elif path == '/data/2.5/forecast/daily': | ||
425 | 56 | self.send_response(200) | ||
426 | 57 | self.send_header("Content-type", "text/html") | ||
427 | 58 | self.end_headers() | ||
428 | 59 | |||
429 | 60 | mode = 'json' | ||
430 | 61 | if 'mode' in query: | ||
431 | 62 | mode = query['mode'][0] | ||
432 | 63 | |||
433 | 64 | self.wfile.write(bytes(read_file('forecast/%s.%s' % (query['q'][0], mode)), 'UTF-8')) | ||
434 | 65 | else: | ||
435 | 66 | self.send_response(404) | ||
436 | 67 | self.send_header("Content-type", "text/html") | ||
437 | 68 | self.end_headers() | ||
438 | 69 | self.wfile.write(bytes('ERROR', 'UTF-8')) | ||
439 | 70 | |||
440 | 71 | if __name__ == "__main__": | ||
441 | 72 | Handler = MyRequestHandler | ||
442 | 73 | httpd = socketserver.TCPServer(("127.0.0.1", 0), Handler) | ||
443 | 74 | |||
444 | 75 | sys.stdout.write('%d\n' % httpd.server_address[1]) | ||
445 | 76 | sys.stdout.flush() | ||
446 | 77 | |||
447 | 78 | httpd.serve_forever() | ||
448 | 0 | 79 | ||
449 | === added directory 'tests/owm_scope/tests/server/weather' | |||
450 | === added file 'tests/owm_scope/tests/server/weather/London,uk.json' | |||
451 | --- tests/owm_scope/tests/server/weather/London,uk.json 1970-01-01 00:00:00 +0000 | |||
452 | +++ tests/owm_scope/tests/server/weather/London,uk.json 2015-11-09 15:16:03 +0000 | |||
453 | @@ -0,0 +1,1 @@ | |||
454 | 1 | {"coord":{"lon":-0.13,"lat":51.51},"sys":{"type":1,"id":5091,"message":0.29,"country":"GB","sunrise":1407386057,"sunset":1407440289},"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}],"base":"cmc stations","main":{"temp":21.83,"pressure":1014,"humidity":53,"temp_min":20,"temp_max":24},"wind":{"speed":1.5,"deg":0},"clouds":{"all":20},"dt":1407408276,"id":2643743,"name":"London","cod":200} | ||
455 | 0 | 2 | ||
456 | === added file 'tests/owm_scope/tests/server/weather/Manchester,uk.json' | |||
457 | --- tests/owm_scope/tests/server/weather/Manchester,uk.json 1970-01-01 00:00:00 +0000 | |||
458 | +++ tests/owm_scope/tests/server/weather/Manchester,uk.json 2015-11-09 15:16:03 +0000 | |||
459 | @@ -0,0 +1,1 @@ | |||
460 | 1 | {"coord":{"lon":-2.24,"lat":53.48},"sys":{"type":1,"id":5060,"message":0.2423,"country":"GB","sunrise":1407386141,"sunset":1407441219},"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"base":"cmc stations","main":{"temp":17.35,"pressure":1016,"humidity":77,"temp_min":17,"temp_max":18},"wind":{"speed":2.6,"deg":20,"var_beg":330,"var_end":80},"clouds":{"all":40},"dt":1407408600,"id":2643123,"name":"Manchester","cod":200} | ||
461 | 0 | 2 | ||
462 | === added file 'tests/owm_scope/tests/test-scope.py' | |||
463 | --- tests/owm_scope/tests/test-scope.py 1970-01-01 00:00:00 +0000 | |||
464 | +++ tests/owm_scope/tests/test-scope.py 2015-11-09 15:16:03 +0000 | |||
465 | @@ -0,0 +1,150 @@ | |||
466 | 1 | #!/usr/bin/env python3 | ||
467 | 2 | |||
468 | 3 | # Copyright (C) 2015 Canonical Ltd. | ||
469 | 4 | |||
470 | 5 | # This library is free software; you can redistribute it and/or | ||
471 | 6 | # modify it under the terms of the GNU Lesser General Public | ||
472 | 7 | # License as published by the Free Software Foundation; either | ||
473 | 8 | # version 2.1 of the License, or (at your option) any later version. | ||
474 | 9 | |||
475 | 10 | # This library is distributed in the hope that it will be useful, | ||
476 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
477 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
478 | 13 | # Lesser General Public License for more details. | ||
479 | 14 | |||
480 | 15 | # You should have received a copy of the GNU Lesser General Public | ||
481 | 16 | # License along with this library; if not, write to the Free Software | ||
482 | 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
483 | 18 | # MA 02110-1301 USA | ||
484 | 19 | |||
485 | 20 | from scope_harness import ( | ||
486 | 21 | CategoryListMatcher, CategoryListMatcherMode, CategoryMatcher, | ||
487 | 22 | Parameters, ResultMatcher, ScopeHarness | ||
488 | 23 | ) | ||
489 | 24 | from scope_harness.testing import * | ||
490 | 25 | import unittest, sys, os | ||
491 | 26 | from subprocess import Popen, PIPE | ||
492 | 27 | |||
493 | 28 | class AppsTest (ScopeHarnessTestCase): | ||
494 | 29 | @classmethod | ||
495 | 30 | def setUpClass(cls): | ||
496 | 31 | cls.process = Popen(["/usr/bin/python3", FAKE_SERVER], stdout=PIPE) | ||
497 | 32 | port = cls.process.stdout.readline().decode("utf-8").rstrip('\n') | ||
498 | 33 | os.environ["NETWORK_SCOPE_APIROOT"] = "localhost" | ||
499 | 34 | os.environ["NETWORK_SCOPE_APIPORT"] = port | ||
500 | 35 | |||
501 | 36 | @classmethod | ||
502 | 37 | def tearDownClass(cls): | ||
503 | 38 | cls.process.terminate() | ||
504 | 39 | |||
505 | 40 | |||
506 | 41 | def start_harness(self): | ||
507 | 42 | self.harness = ScopeHarness.new_from_scope_list(Parameters([SCOPE_INI])) | ||
508 | 43 | self.view = self.harness.results_view | ||
509 | 44 | self.view.active_scope = SCOPE_NAME | ||
510 | 45 | |||
511 | 46 | |||
512 | 47 | def test_surfacing_results(self): | ||
513 | 48 | self.start_harness() | ||
514 | 49 | self.view.search_query = '' | ||
515 | 50 | |||
516 | 51 | match = CategoryListMatcher() \ | ||
517 | 52 | .has_exactly(2) \ | ||
518 | 53 | .mode(CategoryListMatcherMode.BY_ID) \ | ||
519 | 54 | .category(CategoryMatcher("current") \ | ||
520 | 55 | .title("London, GB") \ | ||
521 | 56 | .has_at_least(1) \ | ||
522 | 57 | .result(ResultMatcher("2643743") \ | ||
523 | 58 | .title("21.83°C") \ | ||
524 | 59 | .art("http://openweathermap.org/img/w/02d.png") \ | ||
525 | 60 | .subtitle("few clouds") ) ) \ | ||
526 | 61 | .category(CategoryMatcher("forecast") \ | ||
527 | 62 | .title("7 day forecast") \ | ||
528 | 63 | .has_at_least(7) \ | ||
529 | 64 | .result(ResultMatcher("500") \ | ||
530 | 65 | .title("18.84°C to 25.09°C") \ | ||
531 | 66 | .art("http://openweathermap.org/img/w/10d.png") \ | ||
532 | 67 | .subtitle("light rain") ) \ | ||
533 | 68 | .result(ResultMatcher("501") \ | ||
534 | 69 | .title("15.54°C to 20.86°C") \ | ||
535 | 70 | .art("http://openweathermap.org/img/w/10d.png") \ | ||
536 | 71 | .subtitle("moderate rain") ) \ | ||
537 | 72 | .result(ResultMatcher("802") \ | ||
538 | 73 | .title("13.19°C to 19.58°C") \ | ||
539 | 74 | .art("http://openweathermap.org/img/w/03d.png") \ | ||
540 | 75 | .subtitle("scattered clouds") ) \ | ||
541 | 76 | .result(ResultMatcher("501") \ | ||
542 | 77 | .title("13.46°C to 18.09°C") \ | ||
543 | 78 | .art("http://openweathermap.org/img/w/10d.png") \ | ||
544 | 79 | .subtitle("moderate rain") ) \ | ||
545 | 80 | .result(ResultMatcher("502") \ | ||
546 | 81 | .title("15.39°C to 17.38°C") \ | ||
547 | 82 | .art("http://openweathermap.org/img/w/10d.png") \ | ||
548 | 83 | .subtitle("heavy intensity rain") ) \ | ||
549 | 84 | .result(ResultMatcher("501") \ | ||
550 | 85 | .title("16.17°C to 18.44°C") \ | ||
551 | 86 | .art("http://openweathermap.org/img/w/10d.png") \ | ||
552 | 87 | .subtitle("moderate rain") ) \ | ||
553 | 88 | .result(ResultMatcher("500") \ | ||
554 | 89 | .title("16.67°C to 19.02°C") \ | ||
555 | 90 | .art("http://openweathermap.org/img/w/10d.png") \ | ||
556 | 91 | .subtitle("light rain") ) ) \ | ||
557 | 92 | .match(self.view.categories) | ||
558 | 93 | self.assertMatchResult(match) | ||
559 | 94 | |||
560 | 95 | |||
561 | 96 | def test_search_results(self): | ||
562 | 97 | self.start_harness() | ||
563 | 98 | self.view.search_query = 'Manchester,uk' | ||
564 | 99 | |||
565 | 100 | match = CategoryListMatcher() \ | ||
566 | 101 | .has_exactly(2) \ | ||
567 | 102 | .mode(CategoryListMatcherMode.BY_ID) \ | ||
568 | 103 | .category(CategoryMatcher("current") \ | ||
569 | 104 | .title("Manchester, GB") \ | ||
570 | 105 | .has_at_least(1) \ | ||
571 | 106 | .result(ResultMatcher("2643123") \ | ||
572 | 107 | .title("17.35°C") \ | ||
573 | 108 | .art("http://openweathermap.org/img/w/03d.png") \ | ||
574 | 109 | .subtitle("scattered clouds") ) ) \ | ||
575 | 110 | .category(CategoryMatcher("forecast") \ | ||
576 | 111 | .title("7 day forecast") \ | ||
577 | 112 | .has_at_least(7) \ | ||
578 | 113 | .result(ResultMatcher("800") \ | ||
579 | 114 | .title("11.96°C to 18.83°C") \ | ||
580 | 115 | .art("http://openweathermap.org/img/w/01d.png") \ | ||
581 | 116 | .subtitle("sky is clear") ) \ | ||
582 | 117 | .result(ResultMatcher("501") \ | ||
583 | 118 | .title("12.33°C to 18.59°C") \ | ||
584 | 119 | .art("http://openweathermap.org/img/w/10d.png") \ | ||
585 | 120 | .subtitle("moderate rain") ) \ | ||
586 | 121 | .result(ResultMatcher("803") \ | ||
587 | 122 | .title("10.79°C to 17.11°C") \ | ||
588 | 123 | .art("http://openweathermap.org/img/w/04d.png") \ | ||
589 | 124 | .subtitle("broken clouds") ) \ | ||
590 | 125 | .result(ResultMatcher("501") \ | ||
591 | 126 | .title("12.21°C to 15.98°C") \ | ||
592 | 127 | .art("http://openweathermap.org/img/w/10d.png") \ | ||
593 | 128 | .subtitle("moderate rain") ) \ | ||
594 | 129 | .result(ResultMatcher("500") \ | ||
595 | 130 | .title("12.99°C to 15.73°C") \ | ||
596 | 131 | .art("http://openweathermap.org/img/w/10d.png") \ | ||
597 | 132 | .subtitle("light rain") ) \ | ||
598 | 133 | .result(ResultMatcher("501") \ | ||
599 | 134 | .title("14.08°C to 17.64°C") \ | ||
600 | 135 | .art("http://openweathermap.org/img/w/10d.png") \ | ||
601 | 136 | .subtitle("moderate rain") ) \ | ||
602 | 137 | .result(ResultMatcher("501") \ | ||
603 | 138 | .title("13.37°C to 15.52°C") \ | ||
604 | 139 | .art("http://openweathermap.org/img/w/10d.png") \ | ||
605 | 140 | .subtitle("moderate rain") ) ) \ | ||
606 | 141 | .match(self.view.categories) | ||
607 | 142 | self.assertMatchResult(match) | ||
608 | 143 | |||
609 | 144 | |||
610 | 145 | if __name__ == '__main__': | ||
611 | 146 | SCOPE_NAME = sys.argv[1] | ||
612 | 147 | SCOPE_INI = sys.argv[2] | ||
613 | 148 | FAKE_SERVER = sys.argv[3] | ||
614 | 149 | |||
615 | 150 | unittest.main(argv = sys.argv[:1]) |
FAILED: Continuous integration, rev:107 jenkins. qa.ubuntu. com/job/ unity-js- scopes- ci/51/ jenkins. qa.ubuntu. com/job/ unity-js- scopes- wily-amd64- ci/52/console jenkins. qa.ubuntu. com/job/ unity-js- scopes- wily-armhf- ci/52/console jenkins. qa.ubuntu. com/job/ unity-js- scopes- wily-i386- ci/51/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- js-scopes- ci/51/rebuild
http://