[483] | 1 | dojo.provide("dojox.rpc.tests.Yahoo"); |
---|
| 2 | dojo.require("dojo.io.script"); |
---|
| 3 | dojo.require("dojox.rpc.Service"); |
---|
| 4 | |
---|
| 5 | dojox.rpc.tests.yahooService = new dojox.rpc.Service(dojo.moduleUrl("dojox.rpc.SMDLibrary", "yahoo.smd")); |
---|
| 6 | |
---|
| 7 | dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT = 8000; |
---|
| 8 | dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT = 30000; |
---|
| 9 | |
---|
| 10 | dojox.rpc.tests.yahooService._testMethod = function(method){ |
---|
| 11 | return function(m){ |
---|
| 12 | var d = new doh.Deferred(); |
---|
| 13 | |
---|
| 14 | if (method.name && method.parameters && method.expectedResult) { |
---|
| 15 | var yd = dojox.rpc.tests.yahooService[method.name](method.parameters); |
---|
| 16 | yd.addCallback(this, function(result){ |
---|
| 17 | if (result[method.expectedResult]){ |
---|
| 18 | d.callback(true); |
---|
| 19 | }else{ |
---|
| 20 | d.errback(new Error("Unexpected Return Value: ", result)); |
---|
| 21 | } |
---|
| 22 | }); |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | return d; |
---|
| 26 | } |
---|
| 27 | }; |
---|
| 28 | |
---|
| 29 | doh.register("dojox.rpc.tests.yahoo", |
---|
| 30 | [ |
---|
| 31 | { |
---|
| 32 | name: "#1, Yahoo Answers::questionSearch", |
---|
| 33 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 34 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 35 | name: "questionSearch", |
---|
| 36 | parameters: {query: "dojo toolkit"}, |
---|
| 37 | expectedResult: "all" |
---|
| 38 | }) |
---|
| 39 | }, |
---|
| 40 | { |
---|
| 41 | name: "#2, Yahoo Answers::getByCategory", |
---|
| 42 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 43 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 44 | name: "getByCategory", |
---|
| 45 | parameters: {category_name: "Computers+%26+Internet%3ESoftware"}, |
---|
| 46 | expectedResult: "all" |
---|
| 47 | }) |
---|
| 48 | }, |
---|
| 49 | { |
---|
| 50 | name: "#3, Yahoo Answers::getQuestion", |
---|
| 51 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 52 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 53 | name: "getQuestion", |
---|
| 54 | parameters: {question_id: "1005120800412"}, |
---|
| 55 | expectedResult: "all" |
---|
| 56 | }) |
---|
| 57 | }, |
---|
| 58 | { |
---|
| 59 | name: "#4, Yahoo Answers::getByUser", |
---|
| 60 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 61 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 62 | name: "getByUser", |
---|
| 63 | parameters: {user_id: "AA10001397"}, |
---|
| 64 | expectedResult: "all" |
---|
| 65 | }) |
---|
| 66 | }, |
---|
| 67 | { |
---|
| 68 | name: "#5, Yahoo Audio::artistSearch", |
---|
| 69 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 70 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 71 | name: "artistSearch", |
---|
| 72 | parameters: {artist: "The Beatles"}, |
---|
| 73 | expectedResult: "ResultSet" |
---|
| 74 | }) |
---|
| 75 | }, |
---|
| 76 | { |
---|
| 77 | name: "#6, Yahoo Audio::albumSearch", |
---|
| 78 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 79 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 80 | name: "albumSearch", |
---|
| 81 | parameters: {artist: "The Beatles", album: "Magical Mystery Tour"}, |
---|
| 82 | expectedResult: "ResultSet" |
---|
| 83 | }) |
---|
| 84 | }, |
---|
| 85 | { |
---|
| 86 | name: "#7, Yahoo Audio::songSearch", |
---|
| 87 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 88 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 89 | name: "songSearch", |
---|
| 90 | parameters: {artist: "The Beatles", album: "Magical Mystery Tour", song: "Penny Lane"}, |
---|
| 91 | expectedResult: "ResultSet" |
---|
| 92 | }) |
---|
| 93 | }, |
---|
| 94 | { |
---|
| 95 | name: "#8, Yahoo Audio::songDownloadLocation", |
---|
| 96 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 97 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 98 | name: "songDownloadLocation", |
---|
| 99 | parameters: {songid: "XXXXXXT000995691"}, |
---|
| 100 | expectedResult: "ResultSet" |
---|
| 101 | }) |
---|
| 102 | }, |
---|
| 103 | { |
---|
| 104 | name: "#9, Yahoo ContentAnalysis::contextSearch", |
---|
| 105 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 106 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 107 | name: "contextSearch", |
---|
| 108 | parameters: { |
---|
| 109 | context: "Welcome to the Book of Dojo. This book covers both versions 0.9 and 1.0, and all 1.0 extensions and changes are clearly marked for your enjoyment. Please use the forums for support questions, but if you see something missing, incomplete, or just plain wrong in this book, please leave a comment.", |
---|
| 110 | query: "dojo" |
---|
| 111 | }, |
---|
| 112 | expectedResult: "ResultSet" |
---|
| 113 | }) |
---|
| 114 | }, |
---|
| 115 | { |
---|
| 116 | name: "#10, Yahoo Image::imageSearch", |
---|
| 117 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 118 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 119 | name: "imageSearch", |
---|
| 120 | parameters: {query: "dojo"}, |
---|
| 121 | expectedResult: "ResultSet" |
---|
| 122 | }) |
---|
| 123 | }, |
---|
| 124 | { |
---|
| 125 | name: "#11, Yahoo Local::localSearch", |
---|
| 126 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 127 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 128 | name: "localSearch", |
---|
| 129 | parameters: {query: "pizza", zip: "98201"}, |
---|
| 130 | expectedResult: "ResultSet" |
---|
| 131 | }) |
---|
| 132 | }, |
---|
| 133 | { |
---|
| 134 | name: "#12, Yahoo Local::collectionSearch", |
---|
| 135 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT, |
---|
| 136 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 137 | name: "collectionSearch", |
---|
| 138 | parameters: {query: "dojo"}, |
---|
| 139 | expectedResult: "ResultSet" |
---|
| 140 | }) |
---|
| 141 | }, |
---|
| 142 | { |
---|
| 143 | name: "#13, Yahoo Local::getCollection", |
---|
| 144 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT, |
---|
| 145 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 146 | expectedResult: "getCollection", |
---|
| 147 | parameters: {collection_id: "1000031487"}, |
---|
| 148 | expectedResult: "Result" |
---|
| 149 | }) |
---|
| 150 | }, |
---|
| 151 | { |
---|
| 152 | name: "#14, Yahoo Local::trafficData", |
---|
| 153 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT, |
---|
| 154 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 155 | name: "trafficData", |
---|
| 156 | parameters: {street: "1600 Pennsylvania Ave", city: "Washington, DC"}, |
---|
| 157 | expectedResult: "ResultSet" |
---|
| 158 | }) |
---|
| 159 | }, |
---|
| 160 | { |
---|
| 161 | name: "#15, Yahoo MyWebs::urlSearch", |
---|
| 162 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT, |
---|
| 163 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 164 | name: "urlSearch", |
---|
| 165 | parameters: {tag: "javascript"}, |
---|
| 166 | expectedResult: "ResultSet" |
---|
| 167 | }) |
---|
| 168 | }, |
---|
| 169 | { |
---|
| 170 | name: "#16, Yahoo MyWebs::tagSearch", |
---|
| 171 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT, |
---|
| 172 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 173 | name: "tagSearch", |
---|
| 174 | parameters: {url: "dojotoolkit.org"}, |
---|
| 175 | expectedResult: "ResultSet" |
---|
| 176 | }) |
---|
| 177 | }, |
---|
| 178 | { |
---|
| 179 | name: "#17, Yahoo MyWebs::relatedTags", |
---|
| 180 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT, |
---|
| 181 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 182 | name: "relatedTags", |
---|
| 183 | parameters: {tag: "javascript"}, |
---|
| 184 | expectedResult: "ResultSet" |
---|
| 185 | }) |
---|
| 186 | }, |
---|
| 187 | { |
---|
| 188 | name: "#18, Yahoo NewsSearch::newsSearch", |
---|
| 189 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 190 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 191 | name: "newsSearch", |
---|
| 192 | parameters: {query: "dojo toolkit"}, |
---|
| 193 | expectedResult: "ResultSet" |
---|
| 194 | }) |
---|
| 195 | }, |
---|
| 196 | { |
---|
| 197 | name: "#19, Yahoo Shopping::catalogListing", |
---|
| 198 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 199 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 200 | name: "catalogListing", |
---|
| 201 | parameters: {idtype: "brand,partnum", idvalue: "canon,1079B001", getspec: 1}, |
---|
| 202 | expectedResult: "Catalog" |
---|
| 203 | }) |
---|
| 204 | }, |
---|
| 205 | { |
---|
| 206 | name: "#20, Yahoo Shopping::merchantSearch", |
---|
| 207 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 208 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 209 | name: "merchantSearch", |
---|
| 210 | parameters: {merchantid: "1021849"}, |
---|
| 211 | expectedResult: "Merchant" |
---|
| 212 | }) |
---|
| 213 | }, |
---|
| 214 | { |
---|
| 215 | name: "#21, Yahoo Shopping::productSearch", |
---|
| 216 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 217 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 218 | name: "productSearch", |
---|
| 219 | parameters: {query: "dojo"}, |
---|
| 220 | expectedResult: "Categories" |
---|
| 221 | }) |
---|
| 222 | }, |
---|
| 223 | { |
---|
| 224 | name: "#22, Yahoo SiteExplorer::inlinkData", |
---|
| 225 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 226 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 227 | name: "inlinkData", |
---|
| 228 | parameters: {query: "dojotoolkit.org"}, |
---|
| 229 | expectedResult: "ResultSet" |
---|
| 230 | }) |
---|
| 231 | }, |
---|
| 232 | { |
---|
| 233 | name: "#23, Yahoo SiteExplorer::pageData", |
---|
| 234 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 235 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 236 | name: "pageData", |
---|
| 237 | parameters: {query: "dojotoolkit.org"}, |
---|
| 238 | expectedResult: "ResultSet" |
---|
| 239 | }) |
---|
| 240 | }, |
---|
| 241 | { |
---|
| 242 | name: "#24, Yahoo SiteExplorer::ping", |
---|
| 243 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 244 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 245 | name: "ping", |
---|
| 246 | parameters: {sitemap: "http://www.yahoo.com"}, |
---|
| 247 | expectedResult: "Success" |
---|
| 248 | }) |
---|
| 249 | }, |
---|
| 250 | { |
---|
| 251 | name: "#25, Yahoo SiteExplorer::updateNotification", |
---|
| 252 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 253 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 254 | name: "updateNotification", |
---|
| 255 | parameters: {url: "http://www.yahoo.com"}, |
---|
| 256 | expectedResult: "Success" |
---|
| 257 | }) |
---|
| 258 | }, |
---|
| 259 | { |
---|
| 260 | name: "#26, Yahoo Trip::tripSearch", |
---|
| 261 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 262 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 263 | name: "tripSearch", |
---|
| 264 | parameters: {query: "eiffel tower"}, |
---|
| 265 | expectedResult: "ResultSet" |
---|
| 266 | }) |
---|
| 267 | }, |
---|
| 268 | { |
---|
| 269 | name: "#27, Yahoo Trip::getTrip", |
---|
| 270 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 271 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 272 | name: "getTrip", |
---|
| 273 | parameters: {id: "546303"}, |
---|
| 274 | expectedResult: "Result" |
---|
| 275 | }) |
---|
| 276 | }, |
---|
| 277 | { |
---|
| 278 | name: "#28, Yahoo Video::videoSearch", |
---|
| 279 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 280 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 281 | name: "videoSearch", |
---|
| 282 | parameters: {query: "star wars kid"}, |
---|
| 283 | expectedResult: "ResultSet" |
---|
| 284 | }) |
---|
| 285 | }, |
---|
| 286 | { |
---|
| 287 | name: "#29, Yahoo Web::webSearch", |
---|
| 288 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 289 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 290 | name: "webSearch", |
---|
| 291 | parameters: {query: "dojo toolkit"}, |
---|
| 292 | expectedResult: "ResultSet" |
---|
| 293 | }) |
---|
| 294 | }, |
---|
| 295 | { |
---|
| 296 | name: "#30, Yahoo Web::spellingSuggestion", |
---|
| 297 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 298 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 299 | name: "spellingSuggestion", |
---|
| 300 | parameters: {query: "beatls"}, |
---|
| 301 | expectedResult: "ResultSet" |
---|
| 302 | }) |
---|
| 303 | }, |
---|
| 304 | { |
---|
| 305 | name: "#31, Yahoo Web::relatedSuggestion", |
---|
| 306 | timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT, |
---|
| 307 | runTest: dojox.rpc.tests.yahooService._testMethod({ |
---|
| 308 | name: "relatedSuggestion", |
---|
| 309 | parameters: {query: "dojo toolkit"}, |
---|
| 310 | expectedResult: "ResultSet" |
---|
| 311 | }) |
---|
| 312 | } |
---|
| 313 | ]); |
---|