google-ads-common 0.14.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/COPYING +0 -0
- data/ChangeLog +22 -0
- data/README.md +1 -1
- data/lib/ads_common/api.rb +11 -21
- data/lib/ads_common/api_config.rb +10 -38
- data/lib/ads_common/auth/base_handler.rb +0 -0
- data/lib/ads_common/auth/oauth2_handler.rb +4 -0
- data/lib/ads_common/auth/oauth2_service_account_handler.rb +0 -0
- data/lib/ads_common/build/savon_abstract_generator.rb +0 -0
- data/lib/ads_common/build/savon_generator.rb +0 -0
- data/lib/ads_common/build/savon_registry.rb +19 -0
- data/lib/ads_common/build/savon_registry_generator.rb +0 -0
- data/lib/ads_common/build/savon_service_generator.rb +0 -0
- data/lib/ads_common/config.rb +0 -0
- data/lib/ads_common/credential_handler.rb +0 -0
- data/lib/ads_common/env_check.rb +0 -0
- data/lib/ads_common/errors.rb +0 -0
- data/lib/ads_common/http.rb +4 -0
- data/lib/ads_common/parameters_validator.rb +0 -0
- data/lib/ads_common/results_extractor.rb +0 -0
- data/lib/ads_common/savon_headers/base_header_handler.rb +0 -0
- data/lib/ads_common/savon_headers/oauth_header_handler.rb +0 -0
- data/lib/ads_common/savon_service.rb +12 -11
- data/lib/ads_common/utils.rb +1 -2
- data/lib/ads_common/version.rb +1 -1
- metadata +76 -29
- data/test/coverage.rb +0 -33
- data/test/suite_unittests.rb +0 -28
- data/test/test_config.rb +0 -96
- data/test/test_config.yml +0 -11
- data/test/test_credential_handler.rb +0 -125
- data/test/test_env.rb +0 -43
- data/test/test_oauth2_handler.rb +0 -84
- data/test/test_oauth2_service_account_handler.rb +0 -61
- data/test/test_parameters_validator.rb +0 -153
- data/test/test_results_extractor.rb +0 -250
- data/test/test_savon_service.rb +0 -125
- data/test/test_utils.rb +0 -111
data/test/test_utils.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Copyright:: Copyright 2012, Google Inc. All Rights Reserved.
|
5
|
-
#
|
6
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
15
|
-
# implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
# Tests the utils.
|
20
|
-
|
21
|
-
require 'tempfile'
|
22
|
-
require 'test/unit'
|
23
|
-
require 'yaml'
|
24
|
-
|
25
|
-
require 'ads_common/utils'
|
26
|
-
|
27
|
-
|
28
|
-
class TestUtils < Test::Unit::TestCase
|
29
|
-
|
30
|
-
def test_has_lower_camelcase()
|
31
|
-
assert('str'.respond_to?(:lower_camelcase))
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_lower_camelcase_works()
|
35
|
-
data = [
|
36
|
-
{:input => 'lowerCamelCase', :output => 'lowerCamelCase'},
|
37
|
-
{:input => 'UpperCamelCase', :output => 'upperCamelCase'},
|
38
|
-
{:input => 'snake_case', :output => 'snakeCase'},
|
39
|
-
{:input => 'single1', :output => 'single1'},
|
40
|
-
{:input => 'Single2', :output => 'single2'},
|
41
|
-
{:input => '', :output => ''},
|
42
|
-
{:input => 'strange_MixOf_all', :output => 'strangeMixOfAll'},
|
43
|
-
{:input => 'number_5', :output => 'number5'},
|
44
|
-
]
|
45
|
-
data.each do |arg|
|
46
|
-
result = arg[:input].lower_camelcase()
|
47
|
-
assert_equal(arg[:output], result)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_lower_camelcase_non_destructive()
|
52
|
-
str = 'str_snake'
|
53
|
-
result = str.lower_camelcase()
|
54
|
-
assert_not_same(str, result)
|
55
|
-
assert_equal('str_snake', str)
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_hash_keys_to_str()
|
59
|
-
data = {:a => 'aa', :b5 => 43, 'xyz' => :abc}
|
60
|
-
result = AdsCommon::Utils.hash_keys_to_str(data)
|
61
|
-
assert_equal('aa', result['a'])
|
62
|
-
assert_equal(43, result['b5'])
|
63
|
-
assert_equal(:abc, result['xyz'])
|
64
|
-
assert_equal(3, result.size)
|
65
|
-
assert_not_same(result, data)
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_hash_keys_to_sym()
|
69
|
-
data = {:a => 'aa', :b5 => 43, 'xyz' => :abc, 'f5' => :xyz}
|
70
|
-
result = AdsCommon::Utils.hash_keys_to_sym(data)
|
71
|
-
assert_equal('aa', result[:a])
|
72
|
-
assert_equal(43, result[:b5])
|
73
|
-
assert_equal(:abc, result[:xyz])
|
74
|
-
assert_equal(:xyz, result[:f5])
|
75
|
-
assert_equal(4, result.size)
|
76
|
-
assert_not_same(result, data)
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_save_oauth2_token()
|
80
|
-
config_stub = {:authentication => {:method => 'OAuth2'}}
|
81
|
-
token = {:token_key => 'token_value', :token_number => 42}
|
82
|
-
expected_result = {
|
83
|
-
:authentication => {
|
84
|
-
:method => 'OAuth2',
|
85
|
-
:oauth2_token => token.dup
|
86
|
-
}
|
87
|
-
}
|
88
|
-
tmp_file = Tempfile.new('ruby-tests')
|
89
|
-
tmp_file.write(YAML::dump(config_stub))
|
90
|
-
filename = tmp_file.path()
|
91
|
-
tmp_file.close()
|
92
|
-
AdsCommon::Utils.save_oauth2_token(filename, token)
|
93
|
-
|
94
|
-
assert(File.exist?(filename))
|
95
|
-
result = YAML::load_file(filename)
|
96
|
-
assert_equal(expected_result, result)
|
97
|
-
assert(File.exist?(filename + '.backup'))
|
98
|
-
File.unlink(filename + '.backup')
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_find_new_name()
|
102
|
-
tmp_file = Tempfile.new('ruby-tests')
|
103
|
-
name1 = AdsCommon::Utils.find_new_name(tmp_file.path())
|
104
|
-
assert_equal(tmp_file.path() + '.backup', name1)
|
105
|
-
File.open(name1, 'w') do |file1|
|
106
|
-
name2 = AdsCommon::Utils.find_new_name(tmp_file.path())
|
107
|
-
assert_equal(tmp_file.path() + '.backup1', name2)
|
108
|
-
end
|
109
|
-
File.unlink(name1)
|
110
|
-
end
|
111
|
-
end
|