Page MenuHomePhabricator

Skip search tests when the search API is disabled.
Closed, ResolvedPublic


Search on the Wikia website appears to work fine

But errors result from calling the api, search on text or title

But a near match search does appear to be working.

but not returning results which do appear on the search page.

This is causing a test error in site_tests.SiteUserTestCase.testSearch

Traceback (most recent call last):
  File "./tests/", line 887, in testSearch
    se = list("wiki", total=100))
  File "./pywikibot/data/", line 1452, in __iter__ = self.request.submit()
  File "./pywikibot/data/", line 1071, in submit
    raise APIError(code, info, **result["error"]) gsrsearch-text-disabled: text search is disabled

The simplest fix for the test suite is to catch and detect 'gsrsearch-text-disabled' - when the API returns that error, use unittest.SkipTest to skip the test without causing a test failure.

A slightly better approach is to detect that search is disabled, like we detect whether upload is enabled in APISite.is_uploaddisabled.

Long term, if we encounter may sites which disable search, we might want to build a webpage scrapper to do the search using

Event Timeline

jayvdb assigned this task to Omegat.
jayvdb raised the priority of this task from to Needs Triage.
jayvdb updated the task description. (Show Details)
jayvdb changed Security from none to None.
jayvdb added subscribers: Unknown Object (MLST), jayvdb, XZise, Grunny.
jayvdb renamed this task from Skip to Skip search tests when the search API is disabled..Dec 9 2014, 9:04 AM
jayvdb updated the task description. (Show Details)

As noted on the code review, we need to first analyse this 'what' parameter, in the MediaWiki php code, and understand how what = text or title are disabled.

We done a bit of analysis and cant find the appropriate way to use feature detection. We could do dummy requests and check the response, which is what the previous changeset attempted to do, but ... a simpler approach is for the test method to use has_extension to detect extension 'WikiaSearch' and skip the test if the extension is found. We dont know for sure if that extension ( ?) is causing the problem, but it is a decent way to detect 'wikia' without depending on the name of the family file.

To get the exact name of the extension according to the API, use the API query called 'siteinfo', and prop called 'extensions'

Change 182359 had a related patch set uploaded (by Maverick):
Skip search test for wikia


Change 182359 merged by jenkins-bot:
Skip search test for sites using Wikia Search

Change 180409 abandoned by Multichill:
Bug:T77968 Skip search tests if search is disabled

No response. This can always be re-opened if you plan to work on it again.