jenkins-bot has submitted this change and it was merged.
Change subject: Don't aggressively cache token requests in tests ......................................................................
Don't aggressively cache token requests in tests
Tests aggressively cache all API responses, with the exception of requests containing 'lgpassword'.
Announced recently, token handling on the server is changing. Brad Jorsch: 'Upcoming changes to token handling' https://lists.wikimedia.org/pipermail/mediawiki-api-announce/2014-August/000...
pywikibot doesnt handle 'badtoken', which should cause the client to get a new token.
As a result, re-running tests now fail with badtoken errors, and can only be corrected by deleting the data in tests/apicache.
This patch tells the test layer to not use the API cache for any request containing 'intoken', so new tokens will be requested each test run.
Change-Id: I9f7d86bd1a13eda3cc0b2170840c9d65e716dd20 --- M tests/__init__.py 1 file changed, 10 insertions(+), 0 deletions(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/__init__.py b/tests/__init__.py index 919064a..4176945 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -62,6 +62,13 @@ if not super(TestRequest, self)._load_cache(): return False
+ # tokens need careful management in the cache + # and cant be aggressively cached. + # FIXME: remove once 'badtoken' is reliably handled in api.py + if 'intoken' in self._uniquedescriptionstr(): + self._data = None + return False + if 'lgpassword' in self._uniquedescriptionstr(): self._data = None return False @@ -70,6 +77,9 @@
def _write_cache(self, data): """Write data except login details.""" + if 'intoken' in self._uniquedescriptionstr(): + return + if 'lgpassword' in self._uniquedescriptionstr(): return
pywikibot-commits@lists.wikimedia.org