Dduvall has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/180084

Change subject: API helper method for creating accounts
......................................................................

API helper method for creating accounts

Change-Id: I57e76c2b98622bc951f6bb7a15df70e22853b2cf
---
M lib/mediawiki_selenium/support/modules/api_helper.rb
1 file changed, 14 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/selenium 
refs/changes/84/180084/1

diff --git a/lib/mediawiki_selenium/support/modules/api_helper.rb 
b/lib/mediawiki_selenium/support/modules/api_helper.rb
index 45bb421..b7a650e 100644
--- a/lib/mediawiki_selenium/support/modules/api_helper.rb
+++ b/lib/mediawiki_selenium/support/modules/api_helper.rb
@@ -19,6 +19,20 @@
       end
     end
 
+    # Ensures the given alternative account exists by attempting to create it
+    # via the API.  Any errors related to the account already existing are
+    # swallowed.
+    #
+    # @param id [Symbol] ID of alternative user.
+    #
+    def ensure_account(id)
+      begin
+        api.create_account(user(id), password(id))
+      rescue MediawikiApi::ApiError => e
+        raise e unless e.code == "userexists"
+      end
+    end
+
     # Extends parent implementation to also override the API URL. If no API
     # URL is explicitly defined for the given alternative, one is constructed
     # relative to the wiki URL.

-- 
To view, visit https://gerrit.wikimedia.org/r/180084
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I57e76c2b98622bc951f6bb7a15df70e22853b2cf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/selenium
Gerrit-Branch: env-abstraction-layer
Gerrit-Owner: Dduvall <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to