|
23 | 23 | test_text = 'Bob broke my heart, and then made up this silly sentence to test the PHP SDK' |
24 | 24 | test_html = '<html><head><title>The best SDK Test | AlchemyAPI</title></head><body><h1>Hello World!</h1><p>My favorite language is PHP</p></body></html>' |
25 | 25 | test_url = 'http://www.nytimes.com/2013/07/13/us/politics/a-day-of-friction-notable-even-for-a-fractious-congress.html?_r=0' |
26 | | - |
| 26 | +test_jpg = 'pigeon.jpg' |
27 | 27 |
|
28 | 28 |
|
29 | 29 | alchemyapi = AlchemyAPI() |
|
228 | 228 | print('') |
229 | 229 | print('') |
230 | 230 |
|
| 231 | +#imagetagging |
| 232 | +print('Checking imagetagging . . . ') |
| 233 | +response = alchemyapi.imageTagging('text', test_text); |
| 234 | +assert(response['status'] == 'ERROR') |
| 235 | +response = alchemyapi.imageTagging('html', test_html); |
| 236 | +assert(response['status'] == 'ERROR') |
| 237 | +response = alchemyapi.imageTagging('url', test_url); |
| 238 | +assert(response['status'] == 'OK') |
| 239 | +response = alchemyapi.imageTagging('image', test_jpg); |
| 240 | +assert(response['status'] == 'OK') |
| 241 | +print('Image tagging tests complete!') |
| 242 | +print('') |
| 243 | +print('') |
| 244 | + |
| 245 | +#combined |
| 246 | +print('Checking combined . . . ') |
| 247 | +response = alchemyapi.combined('text', test_text); |
| 248 | +assert(response['status'] == 'OK') |
| 249 | +response = alchemyapi.combined('html', test_html); |
| 250 | +assert(response['status'] == 'ERROR') |
| 251 | +response = alchemyapi.combined('url', test_url); |
| 252 | +assert(response['status'] == 'OK') |
| 253 | +print('Combined tests complete!') |
| 254 | +print('') |
| 255 | +print('') |
| 256 | + |
| 257 | +#taxonomy |
| 258 | +print('Checking taxonomy . . . ') |
| 259 | +response = alchemyapi.taxonomy('text', test_text); |
| 260 | +assert(response['status'] == 'OK') |
| 261 | +response = alchemyapi.taxonomy('html', test_html, {'url':'test'}); |
| 262 | +assert(response['status'] == 'OK') |
| 263 | +response = alchemyapi.taxonomy('url', test_url); |
| 264 | +assert(response['status'] == 'OK') |
| 265 | +print('Taxonomy tests complete!') |
| 266 | +print('') |
| 267 | +print('') |
| 268 | + |
| 269 | +#image |
| 270 | +print('Checking image extraction . . . ') |
| 271 | +response = alchemyapi.imageExtraction('text', test_text); |
| 272 | +assert(response['status'] == 'ERROR') |
| 273 | +response = alchemyapi.imageExtraction('html', test_html); |
| 274 | +assert(response['status'] == 'ERROR') |
| 275 | +response = alchemyapi.imageExtraction('url', test_url); |
| 276 | +assert(response['status'] == 'OK') |
| 277 | +print('Image Extraction tests complete!') |
| 278 | +print('') |
| 279 | +print('') |
| 280 | + |
231 | 281 |
|
232 | 282 | print('**** All tests complete! ****') |
233 | 283 |
|
|
0 commit comments