Last modified: 2014-02-14 16:28:32 UTC
Using a browser to create a new page in a test wiki and to populate that page with test data is prohibitively expensive and takes a long time. Using the API to create pages at runtime containing particular text and/or data should be significantly faster and more reliable.
Building off the work that Aaron Arcos did for Bug 58555, we can use this Python library for Mediawiki interaction: https://github.com/mwclient/mwclient …and then create a script as simple as this to create a new wiki article: import mwclient site = mwclient.Site('en.wikipedia.beta.wmflabs.org') site.login('<username>', '<password>') page = site.Pages['Dune Messiah'] text = page.edit() page.save(text + u'\nDune Messiah is a book by Frank Herbert.', summary = 'Page created via API call') While we could also do this via Ruby, it seems that we might want to use Python instead for consistency with the API test(s) that Aaron has already developed. Added bonus is that the "mwclient" library for Python seems to be actively maintained, while most of the Ruby libraries listed here do not appear to be actively maintained: http://www.mediawiki.org/wiki/API:Client_code
Change 103764 had a related patch set uploaded by Jhall: WIP Script to create new article with random page title https://gerrit.wikimedia.org/r/103764
Changing bug status since task in still WIP.
I modified a single page file in this WIP Gerrit commit: https://gerrit.wikimedia.org/r/#/c/103764/ With this modification, when either the "aftv5.feature" or "page_edit.feature" tests are run, the "aftv5_page.rb" script calls a Python script (which in turn calls the Mediawiki API) and creates a new, randomly-named page via that API call. Each test step from the feature file is then run against that newly-created page. Note: The Python script does assume that the environment variable API_URL has been defined, so it knows what environment to run against. A few items we'll want to consider: 1) Python was chosen for the API client calls due to previous API test work done by Aaron Aarcos in Python, but we could almost certainly do the same thing from Ruby (or another language) if there are objections to Python. 2) Per a conversation with Chris, if this initial approach seems fine, then we should also write a script to create a new user login via the API, and modify tests so that they use both the newly-ceated user account and the newly-created wiki article when they run.
Change 103764 abandoned by Jhall: WIP Script to create new article with random page title Reason: Abandoning this commit so that I can start fresh on the all-Ruby solution (bye-bye Python). https://gerrit.wikimedia.org/r/103764
Resolved via this Gerrit patch set: https://gerrit.wikimedia.org/r/#/c/106548/
Patch hasn't been merged yet.
Jeff, is this resolved?
Yep, this one is resolved, and documentation on the new test setup methods has been added to mediawiki.org: https://www.mediawiki.org/wiki/Quality_Assurance/Browser_testing/Writing_tests#API-based_test_setup_methods