From 97b720691988f21411e7da03eccdc17643ef6bbe Mon Sep 17 00:00:00 2001 From: Michael Cloonan Date: Thu, 12 Jun 2014 14:25:46 -0400 Subject: [PATCH] Miscellaneous fixes, including updating tests to work with ruby 2.0 and ruby 2.1. --- ads_common/google-ads-common.gemspec | 2 +- ads_common/test/test_credential_handler.rb | 8 +- .../test/adwords_api/test_adwords_api.rb | 10 +- adwords_api/test/bugs/test_issue_00000063.rb | 141 ------------------ .../basic_operations_get_campaigns.def | 2 +- .../templates/v201309/misc_use_oauth2_jwt.def | 2 +- 6 files changed, 14 insertions(+), 151 deletions(-) delete mode 100755 adwords_api/test/bugs/test_issue_00000063.rb diff --git a/ads_common/google-ads-common.gemspec b/ads_common/google-ads-common.gemspec index 7b34bd19a..5321fb1f9 100644 --- a/ads_common/google-ads-common.gemspec +++ b/ads_common/google-ads-common.gemspec @@ -35,7 +35,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = '>= 1.3.6' s.rubyforge_project = 'google-ads-common' s.require_path = 'lib' - s.files = Dir.glob('{lib,test}/**/*') + %w(COPYING README ChangeLog) + s.files = Dir.glob('{lib,test}/**/*') + %w(COPYING README.md ChangeLog) s.test_files = Dir.glob('test/test_*.rb') s.add_dependency('savon', '~> 1.2.0') s.add_dependency('httpi', '~> 1.1.0') diff --git a/ads_common/test/test_credential_handler.rb b/ads_common/test/test_credential_handler.rb index cffe07108..7fc3b1df2 100755 --- a/ads_common/test/test_credential_handler.rb +++ b/ads_common/test/test_credential_handler.rb @@ -80,22 +80,22 @@ def test_auth_handler_callback_compare() credentials[:foo] = 'bar' credentials[:baz] = 42 mock1 = MiniTest::Mock.new() - mock1.expect(:property_changed, nil, [:foo, 'bar']) - mock1.expect(:property_changed, nil, [:baz, 42]) + mock1.expect(:property_changed, nil, [:baz, 42]) @handler.set_auth_handler(mock1) @handler.credentials = credentials assert(mock1.verify) credentials.delete(:baz) mock2 = MiniTest::Mock.new() - mock2.expect(:property_changed, nil, [:baz, nil]) + mock2.expect(:property_changed, nil, [:baz, nil]) @handler.set_auth_handler(mock2) @handler.credentials = credentials assert(mock2.verify) credentials[:foo] = nil mock3 = MiniTest::Mock.new() - mock3.expect(:property_changed, nil, [:foo, nil]) + mock3.expect(:property_changed, nil, [:foo, nil]) + mock3.expect(:property_changed, nil, [:baz, nil]) @handler.set_auth_handler(mock3) @handler.credentials = credentials assert(mock3.verify) diff --git a/adwords_api/test/adwords_api/test_adwords_api.rb b/adwords_api/test/adwords_api/test_adwords_api.rb index 6f3762f1d..8093e2b4b 100755 --- a/adwords_api/test/adwords_api/test_adwords_api.rb +++ b/adwords_api/test/adwords_api/test_adwords_api.rb @@ -119,8 +119,12 @@ def test_clientlogin_removal() :authentication => {:method => 'ClientLogin'}, :service => {:environment => 'PRODUCTION'} }) - assert_nothing_raised(adwords_api.service(:CampaignService, - LAST_CLIENT_LOGIN_API_VERSION)) - assert_raise(adwords_api.service(:CampaignService, API_VERSION)) + assert_nothing_raised do + service = adwords_api.service(:CampaignService, + LAST_CLIENT_LOGIN_API_VERSION) + end + assert_raise(AdsCommon::Errors::AuthError) do + service = adwords_api.service(:CampaignService, API_VERSION) + end end end diff --git a/adwords_api/test/bugs/test_issue_00000063.rb b/adwords_api/test/bugs/test_issue_00000063.rb deleted file mode 100755 index 3708094b1..000000000 --- a/adwords_api/test/bugs/test_issue_00000063.rb +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env ruby -# Encoding: utf-8 -# -# Author:: api.dklimkin@gmail.com (Danial Klimkin) -# -# Copyright:: Copyright 2012, Google Inc. All Rights Reserved. -# -# License:: Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Tests issue #63. - -require 'nori' -require 'savon' -require 'test/unit' - -require 'ads_common/results_extractor' -require 'adwords_api' -require 'adwords_api/v201309/mutate_job_service_registry' - -class TestIssue63 < Test::Unit::TestCase - def setup() - @registry = - AdwordsApi::V201309::MutateJobService::MutateJobServiceRegistry - end - - def run_test(xml_text) - data = Nori.parse(xml_text)[:envelope][:body] - extractor = AdsCommon::ResultsExtractor.new(@registry) - return extractor.extract_result(data, :get_result) - end - - def test_issue_63_single_mutate_error() - result = run_test(single_error_xml) - errors = result[:simple_mutate_result][:errors] - assert_kind_of(Array, errors) - assert_equal(1, errors.size) - end - - def test_issue_63_multiple_mutate_errors() - result = run_test(multiple_errors_xml) - errors = result[:simple_mutate_result][:errors] - assert_kind_of(Array, errors) - assert_equal(2, errors.size) - end - - def single_error_xml() - return < - - - - 123 - MutateJobService - getResult - 1 - 180 - 1 - - - - - - - - - - - - - - operations[0].operand.adGroupId - AdGroupId: 0 - EntityNotFound.INVALID_ID - EntityNotFound - INVALID_ID - - - - - - -EOT - end - - def multiple_errors_xml - return < - - - - 123 - MutateJobService - getResult - 1 - 180 - 1 - - - - - - - - - - - - - - operations[0].operand.adGroupId - AdGroupId: 0 - EntityNotFound.INVALID_ID - EntityNotFound - INVALID_ID - - - operations[1].operand.adGroupId - AdGroupId: 0 - EntityNotFound.INVALID_ID - EntityNotFound - INVALID_ID - - - - - - -EOT - end -end diff --git a/adwords_api/test/templates/v201309/basic_operations_get_campaigns.def b/adwords_api/test/templates/v201309/basic_operations_get_campaigns.def index 78aa3812f..8196a0879 100644 --- a/adwords_api/test/templates/v201309/basic_operations_get_campaigns.def +++ b/adwords_api/test/templates/v201309/basic_operations_get_campaigns.def @@ -22,7 +22,7 @@ def setup_mocks() {"env:Envelope"=> {"env:Header"=> {"wsdl:RequestHeader"=> - {"userAgent"=>"ruby-tests (AwApi-Ruby/0.11.1, Common-Ruby/0.9.6, Savon/1.2.0, ruby/1.9.3, HTTPI/1.1.1, net_http)", + {"userAgent"=>"ruby-tests (AwApi-Ruby/0.11.2, Common-Ruby/0.9.6, Savon/1.2.0, ruby/1.9.3, HTTPI/1.1.1, net_http)", "developerToken"=>"dev_token123", "clientCustomerId"=>"123-456-7890", "authToken"=>"abcAuthbcd", diff --git a/adwords_api/test/templates/v201309/misc_use_oauth2_jwt.def b/adwords_api/test/templates/v201309/misc_use_oauth2_jwt.def index 7541605b5..333161639 100644 --- a/adwords_api/test/templates/v201309/misc_use_oauth2_jwt.def +++ b/adwords_api/test/templates/v201309/misc_use_oauth2_jwt.def @@ -40,7 +40,7 @@ def setup_mocks() {"env:Envelope"=> {"env:Header"=> {"wsdl:RequestHeader"=> - {"userAgent"=>"ruby-tests (AwApi-Ruby/0.11.1, Common-Ruby/0.9.6, Savon/1.2.0, ruby/1.9.3, HTTPI/1.1.1, net_http)", + {"userAgent"=>"ruby-tests (AwApi-Ruby/0.11.2, Common-Ruby/0.9.6, Savon/1.2.0, ruby/1.9.3, HTTPI/1.1.1, net_http)", "developerToken"=>"dev_token123", "clientCustomerId"=>"123-456-7890", "xmlns"=>"https://adwords.google.com/api/adwords/cm/v201309"}},