Skip to content

Commit

Permalink
Add Google Ads output to tests (#153)
Browse files Browse the repository at this point in the history
* Add Google Ads binary input
* Add Google Ads to default generator tests
* Add Google Ads ServicePresenter test
* Fix ServicePresenter test names
  • Loading branch information
blowmage committed May 29, 2019
1 parent fb3dfc0 commit 9c83863
Show file tree
Hide file tree
Showing 51 changed files with 4,875 additions and 3 deletions.
1 change: 1 addition & 0 deletions gapic-generator/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace :gen do
generate_default_templates "vision"
generate_default_templates "showcase"
# generate_default_templates "garbage"
generate_default_templates "googleads"
end

desc "Generate the expected output for gem creation tests"
Expand Down
166 changes: 166 additions & 0 deletions gapic-generator/test/google/gapic/presenters/service/googleads_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# frozen_string_literal: true

# Copyright 2019 Google LLC
#
# 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
#
# https://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.

require "test_helper"

class GoogleAdsServiceTest < PresenterTest
def presenter
service_presenter :googleads, "CampaignService"
end

def test_name
assert_equal "CampaignService", presenter.name
end

def test_methods
refute_empty presenter.methods
presenter.methods.each { |ref| assert_kind_of MethodPresenter, ref }
exp_method_names = ["get_campaign", "mutate_campaigns"]
assert_equal exp_method_names, presenter.methods.map(&:name)
end

def test_references
assert_empty presenter.references
end

def test_proto_service_name_full
assert_equal "Google::Ads::GoogleAds::V1::Services::CampaignService", presenter.proto_service_name_full
end

def test_proto_service_file_path
assert_equal "google/ads/googleads/v1/services/campaign_service_pb.rb", presenter.proto_service_file_path
end

def test_proto_service_file_name
assert_equal "campaign_service_pb.rb", presenter.proto_service_file_name
end

def test_proto_service_require
assert_equal "google/ads/googleads/v1/services/campaign_service_pb", presenter.proto_service_require
end

def test_proto_services_file_path
assert_equal "google/ads/googleads/v1/services/campaign_service_services_pb.rb", presenter.proto_services_file_path
end

def test_proto_services_file_name
assert_equal "campaign_service_services_pb.rb", presenter.proto_services_file_name
end

def test_proto_services_require
assert_equal "google/ads/googleads/v1/services/campaign_service_services_pb", presenter.proto_services_require
end

def test_proto_service_stub_name_full
assert_equal "Google::Ads::GoogleAds::V1::Services::CampaignService::Stub", presenter.proto_service_stub_name_full
end

def test_credentials_name
assert_equal "Credentials", presenter.credentials_name
end

def test_credentials_name_full
assert_equal "Google::Ads::GoogleAds::V1::Services::CampaignService::Credentials", presenter.credentials_name_full
end

def test_credentials_file_path
assert_equal "google/ads/google_ads/v1/services/campaign_service/credentials.rb", presenter.credentials_file_path
end

def test_credentials_file_name
assert_equal "credentials.rb", presenter.credentials_file_name
end

def test_credentials_require
assert_equal "google/ads/google_ads/v1/services/campaign_service/credentials", presenter.credentials_require
end

def test_operations_name
assert_equal "Operations", presenter.operations_name
end

def test_operations_name_full
assert_equal "Google::Ads::GoogleAds::V1::Services::CampaignService::Operations", presenter.operations_name_full
end

def test_operations_file_path
assert_equal "google/ads/google_ads/v1/services/campaign_service/operations.rb", presenter.operations_file_path
end

def test_operations_file_name
assert_equal "operations.rb", presenter.operations_file_name
end

def test_operations_require
assert_equal "google/ads/google_ads/v1/services/campaign_service/operations", presenter.operations_require
end

def test_helpers_file_path
assert_equal "google/ads/google_ads/v1/services/campaign_service/helpers.rb", presenter.helpers_file_path
end

def test_helpers_file_name
assert_equal "helpers.rb", presenter.helpers_file_name
end

def test_helpers_require
assert_equal "google/ads/google_ads/v1/services/campaign_service/helpers", presenter.helpers_require
end

def test_test_client_file_path
assert_equal "google/ads/google_ads/v1/services/campaign_service_test.rb", presenter.test_client_file_path
end

def test_stub_name
assert_equal "campaign_service_stub", presenter.stub_name
end

def test_lro?
refute presenter.lro?
end

def test_lro_client_var
assert_equal "operations_client", presenter.lro_client_var
end

def test_lro_client_ivar
assert_equal "@operations_client", presenter.lro_client_ivar
end

def test_paths?
refute presenter.paths?
end

def test_paths_name
assert_equal "Paths", presenter.paths_name
end

def test_paths_name_full
assert_equal "Google::Ads::GoogleAds::V1::Services::CampaignService::Paths", presenter.paths_name_full
end

def test_paths_file_path
assert_equal "google/ads/google_ads/v1/services/campaign_service/paths.rb", presenter.paths_file_path
end

def test_paths_file_name
assert_equal "paths.rb", presenter.paths_file_name
end

def test_paths_require
assert_equal "google/ads/google_ads/v1/services/campaign_service/paths", presenter.paths_require
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

require "test_helper"

class GarbageServiceTest < PresenterTest
class SpeechServiceTest < PresenterTest
def presenter
service_presenter :speech, "Speech"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

require "test_helper"

class GarbageServiceTest < PresenterTest
class VisionImageAnnotatorServiceTest < PresenterTest
def presenter
service_presenter :vision, "ImageAnnotator"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

require "test_helper"

class GarbageServiceTest < PresenterTest
class VisionProductSearchServiceTest < PresenterTest
def presenter
service_presenter :vision, "ProductSearch"
end
Expand Down
9 changes: 9 additions & 0 deletions shared/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ task :gen do
Rake::Task["gen:vision"].invoke
Rake::Task["gen:showcase"].invoke
Rake::Task["gen:garbage"].invoke
Rake::Task["gen:googleads"].invoke
end
namespace :gen do
desc "Generate the binary input files for speech"
Expand Down Expand Up @@ -61,6 +62,14 @@ namespace :gen do
]
generate_input_file "garbage", garbage_protos
end

desc "Generate the binary input files for Google Ads"
task :googleads do
googleads_protos = [
"google/ads/googleads/v1/services/campaign_service.proto"
]
generate_input_file "googleads", googleads_protos
end
end

require "rake/testtask"
Expand Down
7 changes: 7 additions & 0 deletions shared/config/googleads.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:gem:
:name: "google-ads-googleads"
:defaults:
:service:
:default_host: "ads.googleapis.com"
:oauth_scopes:
- https://www.googleapis.com/auth/adwords
Binary file added shared/input/googleads_desc.bin
Binary file not shown.
7 changes: 7 additions & 0 deletions shared/output/gapic/templates/googleads/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
inherit_gem:
google-style: google-style.yml

AllCops:
Exclude:
- "google-ads-googleads.gemspec"
- "test/**/*"
10 changes: 10 additions & 0 deletions shared/output/gapic/templates/googleads/.yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--no-private
--title=Google Ads Googleads
--exclude _pb\.rb$
--markup markdown
--markup-provider redcarpet

./lib/**/*.rb
./proto_docs/**/*.rb
-
README.md
6 changes: 6 additions & 0 deletions shared/output/gapic/templates/googleads/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source "https://rubygems.org"

gemspec

gem "google-gax", github: "googleapis/gax-ruby"
gem "rake", "~> 11.0"
21 changes: 21 additions & 0 deletions shared/output/gapic/templates/googleads/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright <YEAR> <COPYRIGHT HOLDER>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
47 changes: 47 additions & 0 deletions shared/output/gapic/templates/googleads/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# The MIT License (MIT)
#
# Copyright <YEAR> <COPYRIGHT HOLDER>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.


require "bundler/setup"
require "bundler/gem_tasks"

require "rubocop/rake_task"
RuboCop::RakeTask.new

require "rake/testtask"
desc "Run tests."
Rake::TestTask.new do |t|
t.test_files = FileList["test/**/*_test.rb"]
t.warning = false
end

desc "Run smoke tests."
Rake::TestTask.new :smoke_test do |t|
t.test_files = FileList["acceptance/**/*smoke_test.rb"]
t.warning = false
end

require "yard"
require "yard/rake/yardoc_task"
YARD::Rake::YardocTask.new

task default: :test
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- ruby -*-
# encoding: utf-8

require File.expand_path("lib/google/ads/googleads/version", __dir__)

Gem::Specification.new do |gem|
gem.name = "google-ads-googleads"
gem.version = Google::Ads::Googleads::VERSION

gem.authors = ["Google LLC"]
gem.email = "googleapis-packages@google.com"
gem.description = "google-ads-googleads is the official library for Google Ads Googleads API."
gem.summary = "API Client library for Google Ads Googleads API"
gem.homepage = "https://github.com/googleapis/googleapis"
gem.license = "MIT"

gem.platform = Gem::Platform::RUBY

gem.files = `git ls-files -- lib/*`.split("\n") +
`git ls-files -- proto_docs/*`.split("\n") +
["README.md", "LICENSE", ".yardopts"]
gem.require_paths = ["lib"]

gem.required_ruby_version = ">= 2.0.0"

gem.add_dependency "google-gax", "2.0.alpha.0.development"

gem.add_development_dependency "google-style", "~> 0.3"
gem.add_development_dependency "minitest", "~> 5.10"
gem.add_development_dependency "redcarpet", "~> 3.0"
gem.add_development_dependency "simplecov", "~> 0.9"
gem.add_development_dependency "yard", "~> 0.9"
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

# The MIT License (MIT)
#
# Copyright <YEAR> <COPYRIGHT HOLDER>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

require "google/ads/google_ads/v1/services/campaign_service/client"
require "google/ads/google_ads/v1/services/campaign_service/credentials"

0 comments on commit 9c83863

Please sign in to comment.