Tobias Gritschacher has uploaded a new change for review. https://gerrit.wikimedia.org/r/114492
Change subject: Browsertests: make config variables environment variables ...................................................................... Browsertests: make config variables environment variables Currently some configuration needs to be set in config.yml while other configuration is done by setting environment variables. This change makes it possible to fully specify your configuration by either using environment variables or a config.yml. Note that if an environment variable is set, the configuration is taken from there while when it is not set, it will be taken from config.yml. Change-Id: I05a52308bc3908804eedcc4d4f861613272a6467 --- M tests/browser/config/config.yml.sample M tests/browser/config/config_ci.yml D tests/browser/config/config_wdjenkins.yml M tests/browser/features/step_definitions/non_existing_item_steps.rb M tests/browser/features/support/env.rb M tests/browser/features/support/modules/url_module.rb M tests/browser/features/support/modules/wikibase_api_module.rb M tests/browser/features/support/pages/create_item_page.rb M tests/browser/features/support/pages/non_existing_item_page.rb M tests/browser/features/support/pages/repo_login_page.rb 10 files changed, 50 insertions(+), 46 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/92/114492/1 diff --git a/tests/browser/config/config.yml.sample b/tests/browser/config/config.yml.sample index 738743e..afaff3d 100644 --- a/tests/browser/config/config.yml.sample +++ b/tests/browser/config/config.yml.sample @@ -1,16 +1,36 @@ - #WIKIDATA_REPO_URL: "http://localhost/mediawiki/index.php/" - WIKIDATA_REPO_URL: "http://wikidata.beta.wmflabs.org/wiki/" - #WIKIDATA_REPO_URL: "http://wikidata-test-repo.wikimedia.de/wiki/" +# Copy this file to config.yml on your local system and set the values to your needs. +# You can always set all of the below variables in your local environment by doing +# set <VARIABLE>=<VALUE> (on Windows) or +# export <VARIABLE>=<VALUE> (on Unix) +# The environment variable will then be used instead of the values in here. - #WIKIDATA_REPO_API: "http://localhost/mediawiki/api.php/" - WIKIDATA_REPO_API: "http://wikidata.beta.wmflabs.org/w/api.php" - #WIKIDATA_REPO_URL: "http://wikidata-test-repo.wikimedia.de/w/api.php" +# beta instance configuration +WIKIDATA_REPO_URL: "http://wikidata.beta.wmflabs.org/wiki/" +WIKIDATA_REPO_API: "http://wikidata.beta.wmflabs.org/w/api.php" +WB_REPO_USERNAME: "WikidataUser" +WB_REPO_PASSWORD: "WikidataPassword" - # the namespace of the data items (e.g. "Data:" or "" for main namespace) - ITEM_NAMESPACE: "" - PROPERTY_NAMESPACE: "Property:" - ITEM_ID_PREFIX: "Q" - PROPERTY_ID_PREFIX: "P" - LANGUAGE: "en" - LANGUAGE_CODE: "en" - LANGUAGE_NAME: "English" +# local configuration +#WIKIDATA_REPO_API: "http://localhost/mediawiki/api.php/" +#WIKIDATA_REPO_URL: "http://localhost/mediawiki/index.php/" +#WB_REPO_USERNAME: "LocalUser" +#WB_REPO_PASSWORD: "LocalPassword" + +# the namespace of the data items (e.g. "Data:" or "" for main namespace) +ITEM_NAMESPACE: "" +PROPERTY_NAMESPACE: "Property:" +ITEM_ID_PREFIX: "Q" +PROPERTY_ID_PREFIX: "P" +LANGUAGE: "en" +LANGUAGE_CODE: "en" +LANGUAGE_NAME: "English" + +# local browser configuration +BROWSER: "firefox" + +# sauce browser configuration +#SAUCE_ONDEMAND_USERNAME: "SaucelabsUser" +#SAUCE_ONDEMAND_ACCESS_KEY: "SaucelabsKey" +#BROWSER: "firefox" +#VERSION: "25" +#PLATFORM: "Linux" diff --git a/tests/browser/config/config_ci.yml b/tests/browser/config/config_ci.yml index 42f7722..4829315 100644 --- a/tests/browser/config/config_ci.yml +++ b/tests/browser/config/config_ci.yml @@ -6,4 +6,7 @@ PROPERTY_ID_PREFIX: "P" LANGUAGE: "en" LANGUAGE_CODE: "en" -LANGUAGE_NAME: "English" \ No newline at end of file +LANGUAGE_NAME: "English" +BROWSER: "firefox" +VERSION: "25" +PLATFORM: "Linux" \ No newline at end of file diff --git a/tests/browser/config/config_wdjenkins.yml b/tests/browser/config/config_wdjenkins.yml deleted file mode 100644 index cf73854..0000000 --- a/tests/browser/config/config_wdjenkins.yml +++ /dev/null @@ -1,9 +0,0 @@ -WIKIDATA_REPO_URL: "http://deployment-cache-text1/wiki/" -WIKIDATA_REPO_API: "http://deployment-cache-text1/w/api.php" -ITEM_NAMESPACE: "" -PROPERTY_NAMESPACE: "Property:" -ITEM_ID_PREFIX: "Q" -PROPERTY_ID_PREFIX: "P" -LANGUAGE: "en" -LANGUAGE_CODE: "en" -LANGUAGE_NAME: "English" \ No newline at end of file diff --git a/tests/browser/features/step_definitions/non_existing_item_steps.rb b/tests/browser/features/step_definitions/non_existing_item_steps.rb index ebc8c6e..f5bbdc5 100644 --- a/tests/browser/features/step_definitions/non_existing_item_steps.rb +++ b/tests/browser/features/step_definitions/non_existing_item_steps.rb @@ -12,6 +12,6 @@ Then(/^check if this page behaves correctly$/) do on_page(NonExistingItemPage) do |page| page.first_heading.should be_true - page.first_heading_element.text.should == ITEM_NAMESPACE + ITEM_ID_PREFIX + "xy" + page.first_heading_element.text.should == ENV["ITEM_NAMESPACE"] + ENV["ITEM_ID_PREFIX"] + "xy" end end diff --git a/tests/browser/features/support/env.rb b/tests/browser/features/support/env.rb index 9519320..839e664 100644 --- a/tests/browser/features/support/env.rb +++ b/tests/browser/features/support/env.rb @@ -17,7 +17,9 @@ config = YAML.load_file("config/config.yml") config.each do |k, v| - eval("#{k} = '#{v}'") + if !ENV["#{k}"] + ENV["#{k}"] = "#{v}" + end end require_all "features/support/modules" diff --git a/tests/browser/features/support/modules/url_module.rb b/tests/browser/features/support/modules/url_module.rb index c47a1d2..f491505 100644 --- a/tests/browser/features/support/modules/url_module.rb +++ b/tests/browser/features/support/modules/url_module.rb @@ -10,29 +10,17 @@ module URL def self.client_url(name) - if ENV["WIKIDATA_CLIENT_URL"] - url = ENV["WIKIDATA_CLIENT_URL"] - else - url = WIKIDATA_CLIENT_URL - end + url = ENV["WIKIDATA_CLIENT_URL"] "#{url}#{name}" end def self.repo_url(name) - if ENV["WIKIDATA_REPO_URL"] - url = ENV["WIKIDATA_REPO_URL"] - else - url = WIKIDATA_REPO_URL - end + url = ENV["WIKIDATA_REPO_URL"] "#{url}#{name}" end def self.repo_api() - if ENV["WIKIDATA_REPO_URL"] - url = ENV["WIKIDATA_REPO_API"] - else - url = WIKIDATA_REPO_API - end + url = ENV["WIKIDATA_REPO_API"] "#{url}" end end diff --git a/tests/browser/features/support/modules/wikibase_api_module.rb b/tests/browser/features/support/modules/wikibase_api_module.rb index 25112a0..959c366 100644 --- a/tests/browser/features/support/modules/wikibase_api_module.rb +++ b/tests/browser/features/support/modules/wikibase_api_module.rb @@ -40,7 +40,7 @@ check_wb_api_success(resp) id = resp["entity"]["id"] - url = URL.repo_url(ITEM_NAMESPACE + id + "?setlang=" + LANGUAGE_CODE) + url = URL.repo_url(ENV["ITEM_NAMESPACE"] + id + "?setlang=" + ENV["LANGUAGE_CODE"]) entity_data = ActiveSupport::JSON.decode(data) {"id" => id, "url" => url, "label" => entity_data["labels"]["en"]["value"], diff --git a/tests/browser/features/support/pages/create_item_page.rb b/tests/browser/features/support/pages/create_item_page.rb index 3c5a6f4..b68bd2a 100644 --- a/tests/browser/features/support/pages/create_item_page.rb +++ b/tests/browser/features/support/pages/create_item_page.rb @@ -15,14 +15,14 @@ def create_new_item(label, description, switch_lang = true) if switch_lang - self.uls_switch_language(LANGUAGE_CODE, LANGUAGE_NAME) + self.uls_switch_language(ENV["LANGUAGE_CODE"], ENV["LANGUAGE_NAME"]) end self.create_entity_label_field = label self.create_entity_description_field = description create_entity_submit wait_for_entity_to_load @@item_url = current_url - query_string = "/" + ITEM_NAMESPACE + ITEM_ID_PREFIX + query_string = "/" + ENV["ITEM_NAMESPACE"] + ENV["ITEM_ID_PREFIX"] @@item_id = @@item_url[@@item_url.index(query_string)+query_string.length..-1] return @@item_id end diff --git a/tests/browser/features/support/pages/non_existing_item_page.rb b/tests/browser/features/support/pages/non_existing_item_page.rb index 6caae7a..f0f5871 100644 --- a/tests/browser/features/support/pages/non_existing_item_page.rb +++ b/tests/browser/features/support/pages/non_existing_item_page.rb @@ -8,7 +8,7 @@ class NonExistingItemPage include PageObject - page_url WIKIDATA_REPO_URL + ITEM_NAMESPACE + ITEM_ID_PREFIX + "xy" + page_url ENV["WIKIDATA_REPO_URL"] + ENV["ITEM_NAMESPACE"] + ENV["ITEM_ID_PREFIX"] + "xy" span(:first_heading, :xpath => "//h1[@id='firstHeading']/span") link(:special_log_link, :css => "div#mw-content-text > div > p > span > a:nth-child(1)") diff --git a/tests/browser/features/support/pages/repo_login_page.rb b/tests/browser/features/support/pages/repo_login_page.rb index 478f679..cc300c3 100644 --- a/tests/browser/features/support/pages/repo_login_page.rb +++ b/tests/browser/features/support/pages/repo_login_page.rb @@ -9,6 +9,6 @@ class RepoLoginPage < LoginPage include PageObject - page_url "#{WIKIDATA_REPO_URL}Special:UserLogin" + page_url URL.repo_url("Special:UserLogin") end -- To view, visit https://gerrit.wikimedia.org/r/114492 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I05a52308bc3908804eedcc4d4f861613272a6467 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits