-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
731 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,10 @@ def initialize api, file | |
@file = file | ||
end | ||
|
||
def name | ||
@file.name | ||
end | ||
|
||
def address | ||
@file.address | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
gapic-generator/test/google/gapic/presenters/file/garbage_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 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 GarbageFilePresenterTest < PresenterTest | ||
def schema | ||
api :garbage | ||
end | ||
|
||
def test_garbage | ||
file = schema.files.find { |f| f.name == "garbage/garbage.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["endless", "trash", "forever"], fp.address | ||
assert_equal "So::Much::Trash", fp.namespace | ||
assert_equal "garbage/garbage.rb", fp.docs_file_path | ||
|
||
assert_equal ["LongRunningGarbageRequest", "LongRunningGarbageResponse", "LongRunningGarbageMetadata", "ListGarbageRequest", "ListGarbageResponse", "GarbageItem", "SimpleGarbage", "SimpleGarbageItem", "TypicalGarbage", "SpecificGarbage", "RepeatedGarbage", "GarbageMap"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal ["GarbageEnum"], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
end |
38 changes: 38 additions & 0 deletions
38
gapic-generator/test/google/gapic/presenters/file/googleads_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 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 GoogleAdsFilePresenterTest < PresenterTest | ||
def schema | ||
api :googleads | ||
end | ||
|
||
def test_campaign_service | ||
file = schema.files.find { |f| f.name == "google/ads/googleads/v1/services/campaign_service.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["google", "ads", "googleads", "v1", "services"], fp.address | ||
assert_equal "Google::Ads::GoogleAds::V1::Services", fp.namespace | ||
assert_equal "google/ads/googleads/v1/services/campaign_service.rb", fp.docs_file_path | ||
|
||
assert_equal ["GetCampaignRequest", "MutateCampaignsRequest", "CampaignOperation", "MutateCampaignsResponse", "MutateCampaignResult"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal [], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
end |
83 changes: 83 additions & 0 deletions
83
gapic-generator/test/google/gapic/presenters/file/showcase_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# 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 ShowcaseFilePresenterTest < PresenterTest | ||
def schema | ||
api :showcase | ||
end | ||
|
||
def test_echo | ||
file = schema.files.find { |f| f.name == "google/showcase/v1alpha3/echo.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["google", "showcase", "v1alpha3"], fp.address | ||
assert_equal "Google::Showcase::V1alpha3", fp.namespace | ||
assert_equal "google/showcase/v1alpha3/echo.rb", fp.docs_file_path | ||
|
||
assert_equal ["EchoRequest", "EchoResponse", "ExpandRequest", "PagedExpandRequest", "PagedExpandResponse", "WaitRequest", "WaitResponse", "WaitMetadata"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal [], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
|
||
def test_identity | ||
file = schema.files.find { |f| f.name == "google/showcase/v1alpha3/identity.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["google", "showcase", "v1alpha3"], fp.address | ||
assert_equal "Google::Showcase::V1alpha3", fp.namespace | ||
assert_equal "google/showcase/v1alpha3/identity.rb", fp.docs_file_path | ||
|
||
assert_equal ["User", "CreateUserRequest", "GetUserRequest", "UpdateUserRequest", "DeleteUserRequest", "ListUsersRequest", "ListUsersResponse"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal [], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
|
||
def test_messaging | ||
file = schema.files.find { |f| f.name == "google/showcase/v1alpha3/messaging.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["google", "showcase", "v1alpha3"], fp.address | ||
assert_equal "Google::Showcase::V1alpha3", fp.namespace | ||
assert_equal "google/showcase/v1alpha3/messaging.rb", fp.docs_file_path | ||
|
||
assert_equal ["Room", "CreateRoomRequest", "GetRoomRequest", "UpdateRoomRequest", "DeleteRoomRequest", "ListRoomsRequest", "ListRoomsResponse", "Blurb", "CreateBlurbRequest", "GetBlurbRequest", "UpdateBlurbRequest", "DeleteBlurbRequest", "ListBlurbsRequest", "ListBlurbsResponse", "SearchBlurbsRequest", "SearchBlurbsMetadata", "SearchBlurbsResponse", "StreamBlurbsRequest", "StreamBlurbsResponse", "SendBlurbsResponse", "ConnectRequest"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal [], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
|
||
def test_testing | ||
file = schema.files.find { |f| f.name == "google/showcase/v1alpha3/testing.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["google", "showcase", "v1alpha3"], fp.address | ||
assert_equal "Google::Showcase::V1alpha3", fp.namespace | ||
assert_equal "google/showcase/v1alpha3/testing.rb", fp.docs_file_path | ||
|
||
assert_equal ["Session", "CreateSessionRequest", "GetSessionRequest", "ListSessionsRequest", "ListSessionsResponse", "DeleteSessionRequest", "ReportSessionRequest", "ReportSessionResponse", "Test", "Issue", "ListTestsRequest", "ListTestsResponse", "TestRun", "DeleteTestRequest", "VerifyTestRequest", "VerifyTestResponse"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal [], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
end |
38 changes: 38 additions & 0 deletions
38
gapic-generator/test/google/gapic/presenters/file/speech_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 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 SpeechFilePresenterTest < PresenterTest | ||
def schema | ||
api :speech | ||
end | ||
|
||
def test_cloud_speech | ||
file = schema.files.find { |f| f.name == "google/cloud/speech/v1/cloud_speech.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["google", "cloud", "speech", "v1"], fp.address | ||
assert_equal "Google::Cloud::Speech::V1", fp.namespace | ||
assert_equal "google/cloud/speech/v1/cloud_speech.rb", fp.docs_file_path | ||
|
||
assert_equal ["RecognizeRequest", "LongRunningRecognizeRequest", "StreamingRecognizeRequest", "StreamingRecognitionConfig", "RecognitionConfig", "SpeechContext", "RecognitionAudio", "RecognizeResponse", "LongRunningRecognizeResponse", "LongRunningRecognizeMetadata", "StreamingRecognizeResponse", "StreamingRecognitionResult", "SpeechRecognitionResult", "SpeechRecognitionAlternative", "WordInfo"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal [], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
end |
113 changes: 113 additions & 0 deletions
113
gapic-generator/test/google/gapic/presenters/file/vision_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# 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 VisionFilePresenterTest < PresenterTest | ||
def schema | ||
api :vision | ||
end | ||
|
||
def test_geometry | ||
file = schema.files.find { |f| f.name == "google/cloud/vision/v1/geometry.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["google", "cloud", "vision", "v1"], fp.address | ||
assert_equal "Google::Cloud::Vision::V1", fp.namespace | ||
assert_equal "google/cloud/vision/v1/geometry.rb", fp.docs_file_path | ||
|
||
assert_equal ["Vertex", "NormalizedVertex", "BoundingPoly", "Position"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal [], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
|
||
def test_product_search_service | ||
file = schema.files.find { |f| f.name == "google/cloud/vision/v1/product_search_service.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["google", "cloud", "vision", "v1"], fp.address | ||
assert_equal "Google::Cloud::Vision::V1", fp.namespace | ||
assert_equal "google/cloud/vision/v1/product_search_service.rb", fp.docs_file_path | ||
|
||
assert_equal ["Product", "ProductSet", "ReferenceImage", "CreateProductRequest", "ListProductsRequest", "ListProductsResponse", "GetProductRequest", "UpdateProductRequest", "DeleteProductRequest", "CreateProductSetRequest", "ListProductSetsRequest", "ListProductSetsResponse", "GetProductSetRequest", "UpdateProductSetRequest", "DeleteProductSetRequest", "CreateReferenceImageRequest", "ListReferenceImagesRequest", "ListReferenceImagesResponse", "GetReferenceImageRequest", "DeleteReferenceImageRequest", "AddProductToProductSetRequest", "RemoveProductFromProductSetRequest", "ListProductsInProductSetRequest", "ListProductsInProductSetResponse", "ImportProductSetsGcsSource", "ImportProductSetsInputConfig", "ImportProductSetsRequest", "ImportProductSetsResponse", "BatchOperationMetadata"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal [], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
|
||
def test_product_search | ||
file = schema.files.find { |f| f.name == "google/cloud/vision/v1/product_search.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["google", "cloud", "vision", "v1"], fp.address | ||
assert_equal "Google::Cloud::Vision::V1", fp.namespace | ||
assert_equal "google/cloud/vision/v1/product_search.rb", fp.docs_file_path | ||
|
||
assert_equal ["ProductSearchParams", "ProductSearchResults"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal [], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
|
||
def test_text_annotation | ||
file = schema.files.find { |f| f.name == "google/cloud/vision/v1/text_annotation.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["google", "cloud", "vision", "v1"], fp.address | ||
assert_equal "Google::Cloud::Vision::V1", fp.namespace | ||
assert_equal "google/cloud/vision/v1/text_annotation.rb", fp.docs_file_path | ||
|
||
assert_equal ["TextAnnotation", "Page", "Block", "Paragraph", "Word", "Symbol"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal [], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
|
||
def test_web_detection | ||
file = schema.files.find { |f| f.name == "google/cloud/vision/v1/web_detection.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["google", "cloud", "vision", "v1"], fp.address | ||
assert_equal "Google::Cloud::Vision::V1", fp.namespace | ||
assert_equal "google/cloud/vision/v1/web_detection.rb", fp.docs_file_path | ||
|
||
assert_equal ["WebDetection"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal [], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
|
||
def test_image_annotator | ||
file = schema.files.find { |f| f.name == "google/cloud/vision/v1/image_annotator.proto" } | ||
fp = FilePresenter.new schema, file | ||
|
||
assert_equal ["google", "cloud", "vision", "v1"], fp.address | ||
assert_equal "Google::Cloud::Vision::V1", fp.namespace | ||
assert_equal "google/cloud/vision/v1/image_annotator.rb", fp.docs_file_path | ||
|
||
assert_equal ["Feature", "ImageSource", "Image", "FaceAnnotation", "LocationInfo", "Property", "EntityAnnotation", "LocalizedObjectAnnotation", "SafeSearchAnnotation", "LatLongRect", "ColorInfo", "DominantColorsAnnotation", "ImageProperties", "CropHint", "CropHintsAnnotation", "CropHintsParams", "WebDetectionParams", "ImageContext", "AnnotateImageRequest", "ImageAnnotationContext", "AnnotateImageResponse", "AnnotateFileResponse", "BatchAnnotateImagesRequest", "BatchAnnotateImagesResponse", "AsyncAnnotateFileRequest", "AsyncAnnotateFileResponse", "AsyncBatchAnnotateFilesRequest", "AsyncBatchAnnotateFilesResponse", "InputConfig", "OutputConfig", "GcsSource", "GcsDestination", "OperationMetadata"], fp.messages.map(&:name) | ||
fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } | ||
|
||
assert_equal ["Likelihood"], fp.enums.map(&:name) | ||
fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } | ||
end | ||
end |
49 changes: 49 additions & 0 deletions
49
gapic-generator/test/google/gapic/presenters/gem/garbage_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# 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 GarbageGemPresenterTest < PresenterTest | ||
def presenter | ||
GemPresenter.new api :garbage | ||
end | ||
|
||
def test_garbage | ||
assert_equal ["Google", "Garbage"], presenter.address | ||
assert_equal "google-garbage", presenter.name | ||
assert_equal "Google::Garbage", presenter.namespace | ||
assert_equal "Google Garbage", presenter.title | ||
assert_equal "0.0.1", presenter.version | ||
assert_equal "google/garbage/version", presenter.version_require | ||
assert_equal "google/garbage/version.rb", presenter.version_file_path | ||
assert_equal "Google::Garbage::VERSION", presenter.version_name_full | ||
assert_equal ["Google LLC"], presenter.authors | ||
assert_equal "[email protected]", presenter.email | ||
assert_equal "google-garbage is the official library for Google Garbage API.", presenter.description | ||
assert_equal "API Client library for Google Garbage API", presenter.summary | ||
assert_equal "https://github.com/googleapis/googleapis", presenter.homepage | ||
assert_equal "GARBAGE", presenter.env_prefix | ||
|
||
assert_equal ["endless.trash.forever"], presenter.packages.map(&:name) | ||
presenter.packages.each { |pp| assert_kind_of PackagePresenter, pp } | ||
|
||
assert_equal ["GarbageService"], presenter.services.map(&:name) | ||
presenter.services.each { |sp| assert_kind_of ServicePresenter, sp } | ||
|
||
assert_equal ["google/api/http.proto", "google/protobuf/descriptor.proto", "google/api/client.proto", "google/api/field_behavior.proto", "google/api/resource.proto", "google/protobuf/any.proto", "google/protobuf/empty.proto", "google/rpc/status.proto", "google/longrunning/operations.proto", "google/protobuf/timestamp.proto", "garbage/garbage.proto"], presenter.proto_files.map(&:name) | ||
presenter.proto_files.each { |fp| assert_kind_of FilePresenter, fp } | ||
end | ||
end |
Oops, something went wrong.