sem4r 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/Gemfile.lock +36 -0
- data/README.rdoc +30 -0
- data/Rakefile +15 -12
- data/VERSION.yml +1 -1
- data/examples_blog/2009-11-29-hello-world.rb +0 -1
- data/examples_sem4r/01_get_account.rb +1 -1
- data/examples_sem4r/02_get_info.rb +6 -2
- data/examples_sem4r/03_list_ad.rb +1 -1
- data/examples_sem4r/04_list_keywords.rb +1 -1
- data/examples_sem4r/05_request_report.rb +1 -2
- data/examples_sem4r/05_request_report_2010.rb +19 -4
- data/examples_sem4r/06_create_campaigns.rb +1 -1
- data/examples_sem4r/07_create_campaigns_block.rb +1 -1
- data/examples_sem4r/07_create_campaigns_simple.rb +1 -1
- data/examples_sem4r/08_ad_params.rb +1 -1
- data/examples_sem4r/09_targeting_idea.rb +1 -1
- data/examples_sem4r/10_get_location.rb +1 -1
- data/examples_sem4r/11_submit_bulk_job.rb +1 -1
- data/examples_sem4r/12_list_bulk_job.rb +1 -1
- data/examples_sem4r/30_prune_empty_adgroup.rb +1 -1
- data/examples_sem4r/31_empty_accounts.rb +1 -1
- data/examples_sem4r/example_helper.rb +5 -10
- data/lib/sem4r/account.rb +3 -306
- data/lib/sem4r/ad_group/ad_group.rb +16 -14
- data/lib/sem4r/ad_group/ad_group_bids.rb +11 -10
- data/lib/sem4r/ad_group/ad_group_service.rb +5 -5
- data/lib/sem4r/ad_group_ad/ad_group_ad.rb +1 -1
- data/lib/sem4r/ad_group_ad/ad_group_ad_service.rb +5 -5
- data/lib/sem4r/ad_group_ad/ad_group_mobile_ad.rb +9 -9
- data/lib/sem4r/ad_group_ad/ad_group_text_ad.rb +9 -9
- data/lib/sem4r/ad_group_criterion/ad_group_criterion.rb +6 -6
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_bids.rb +5 -6
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_operations.rb +0 -1
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_service.rb +4 -4
- data/lib/sem4r/ad_group_criterion/criterion.rb +3 -3
- data/lib/sem4r/ad_group_criterion/criterion_keyword.rb +3 -3
- data/lib/sem4r/ad_group_criterion/criterion_placement.rb +2 -2
- data/lib/sem4r/ad_param/ad_param.rb +3 -3
- data/lib/sem4r/ad_param/ad_param_service.rb +5 -5
- data/lib/sem4r/adwords.rb +1 -0
- data/lib/sem4r/api_counters.rb +1 -0
- data/lib/sem4r/base.rb +1 -0
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job.rb +2 -2
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_account_extension.rb +59 -0
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_service.rb +5 -5
- data/lib/sem4r/campaign/campaign.rb +10 -10
- data/lib/sem4r/campaign/campaign_account_extension.rb +87 -0
- data/lib/sem4r/campaign/campaign_service.rb +6 -6
- data/lib/sem4r/campaign_target/campaign_target_service.rb +22 -22
- data/lib/sem4r/cli/cli_command.rb +1 -0
- data/lib/sem4r/cli/cli_common_args.rb +10 -3
- data/lib/sem4r/cli/cli_helpers.rb +1 -0
- data/lib/sem4r/cli/cli_sem.rb +1 -0
- data/lib/sem4r/cli/{cli_download_report.rb → commands/cli_download_report.rb} +2 -1
- data/lib/sem4r/cli/{cli_ideas.rb → commands/cli_ideas.rb} +1 -0
- data/lib/sem4r/cli/{cli_commands.rb → commands/cli_info.rb} +3 -23
- data/lib/sem4r/cli/{cli_list_ads.rb → commands/cli_list_ads.rb} +1 -0
- data/lib/sem4r/cli/commands/cli_list_campaign.rb +35 -0
- data/lib/sem4r/cli/commands/cli_list_client.rb +36 -0
- data/lib/sem4r/cli/{cli_list_keywords.rb → commands/cli_list_keywords.rb} +1 -0
- data/lib/sem4r/cli/commands/cli_list_report.rb +34 -0
- data/lib/sem4r/cli/commands/cli_repdef.rb +109 -0
- data/lib/sem4r/cli/commands/cli_report.rb +78 -0
- data/lib/sem4r/cli/{cli_request_report.rb → commands/cli_request_report.rb} +1 -0
- data/lib/sem4r/credentials.rb +1 -0
- data/lib/sem4r/extensions.rb +22 -1
- data/lib/sem4r/geo_location/geo_location_account_extension.rb +43 -0
- data/lib/sem4r/geo_location/geo_location_service.rb +4 -4
- data/lib/sem4r/info/info_account_extension.rb +48 -0
- data/lib/sem4r/info/info_selector.rb +108 -0
- data/lib/sem4r/info/info_service.rb +11 -66
- data/lib/sem4r/{common/operation.rb → operation.rb} +3 -1
- data/lib/sem4r/report_definition/report_definition.rb +75 -15
- data/lib/sem4r/report_definition/report_definition_account_extension.rb +79 -0
- data/lib/sem4r/report_definition/report_definition_operation.rb +3 -1
- data/lib/sem4r/report_definition/report_definition_service.rb +7 -7
- data/lib/sem4r/report_definition/report_field.rb +57 -0
- data/lib/sem4r/sem4r_error.rb +1 -0
- data/lib/sem4r/services/http_connector.rb +93 -0
- data/lib/sem4r/services/service.rb +1 -1
- data/lib/sem4r/services/soap_call.rb +27 -5
- data/lib/sem4r/services/soap_connector.rb +2 -147
- data/lib/sem4r/services/soap_dumper.rb +105 -0
- data/lib/sem4r/services/soap_message_v13.rb +15 -9
- data/lib/sem4r/services/{soap_message_v2009.rb → soap_message_v2010.rb} +26 -12
- data/lib/sem4r/targeting_idea/targeting_idea.rb +16 -11
- data/lib/sem4r/targeting_idea/targeting_idea_account_extension.rb +52 -0
- data/lib/sem4r/targeting_idea/targeting_idea_selector.rb +36 -10
- data/lib/sem4r/targeting_idea/targeting_idea_service.rb +5 -5
- data/lib/sem4r/v13_account/account_account_extension.rb +103 -0
- data/lib/sem4r/v13_account/billing_address.rb +10 -21
- data/lib/sem4r/v13_report/report.rb +8 -8
- data/lib/sem4r/v13_report/report_account_extension.rb +63 -0
- data/lib/sem4r/v13_report/report_job.rb +1 -1
- data/lib/sem4r.rb +27 -6
- data/lib/sem4r_cli.rb +4 -6
- data/lib/{sem4r → soap_helpers}/soap_attributes.rb +105 -13
- data/sem4r.gemspec +229 -190
- data/spec/{aggregates_spec_helper.rb → aggregates_rspec_helper.rb} +0 -0
- data/spec/build_fixtures.rb +84 -0
- data/spec/rspec_hash.rb +66 -0
- data/spec/{spec_helper.rb → rspec_helper.rb} +4 -2
- data/spec/rspec_matchers.rb +102 -0
- data/spec/rspec_sem4r_helper.rb +88 -0
- data/spec/sem4r/account_spec.rb +3 -4
- data/spec/sem4r/ad_group/ad_group_bids_spec.rb +4 -3
- data/spec/sem4r/ad_group/ad_group_service_spec.rb +8 -7
- data/spec/sem4r/ad_group/ad_group_spec.rb +5 -4
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-first-req.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-first-res.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-manual-cpm-bids-req.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-manual-cpm-bids-res.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/mutate_add-req.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/mutate_add-res.xml +0 -0
- data/spec/sem4r/ad_group_ad/ad_group_ad_operation_spec.rb +3 -3
- data/spec/sem4r/ad_group_ad/ad_group_ad_service_spec.rb +6 -5
- data/spec/sem4r/ad_group_ad/ad_group_ad_spec.rb +6 -5
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_mobile_ad-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_mobile_ad-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_text_ad-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_text_ad-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_mobile_ad-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_mobile_ad-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_text_ad-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_text_ad-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_two_criterions-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_two_criterions-res.xml +0 -0
- data/spec/sem4r/ad_group_criterion/ad_group_criterion_bids_spec.rb +5 -4
- data/spec/sem4r/ad_group_criterion/ad_group_criterion_service_spec.rb +6 -5
- data/spec/sem4r/ad_group_criterion/ad_group_criterion_spec.rb +6 -5
- data/spec/sem4r/ad_group_criterion/criterion_spec.rb +5 -4
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/get-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/get-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_keyword-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_keyword-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_placement-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_placement-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_negative_keyword-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_negative_keyword-res.xml +0 -0
- data/spec/sem4r/ad_param/ad_param_service_spec.rb +6 -5
- data/spec/sem4r/ad_param/ad_param_spec.rb +3 -2
- data/spec/{fixtures/services/ad_param → sem4r/ad_param/fixtures}/mutate_set-req.xml +0 -0
- data/spec/{fixtures/services/ad_param → sem4r/ad_param/fixtures}/mutate_set-res.xml +0 -0
- data/spec/sem4r/adwords_spec.rb +1 -1
- data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_service_spec.rb +6 -5
- data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_spec.rb +4 -3
- data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/get-req.xml +0 -0
- data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/get-res.xml +0 -0
- data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/mutate-req.xml +0 -0
- data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/mutate-res.xml +0 -0
- data/spec/sem4r/bulk_mutate_job/job_operation_spec.rb +3 -2
- data/spec/sem4r/campaign/campaign_service_spec.rb +8 -7
- data/spec/sem4r/campaign/campaign_spec.rb +3 -2
- data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/get-req.xml +0 -0
- data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/get-res.xml +0 -0
- data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/mutate_add-req.xml +0 -0
- data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/mutate_add-res.xml +0 -0
- data/spec/sem4r/cli/cli_spec.rb +2 -3
- data/spec/sem4r/credentials_spec.rb +1 -1
- data/spec/sem4r/info/account_info_extension_spec.rb +51 -0
- data/spec/sem4r/info/fixtures/get_unit_count-req.xml +34 -0
- data/spec/sem4r/info/fixtures/get_unit_count-res.xml +27 -0
- data/spec/sem4r/nokogiri_parsing_spec.rb +105 -0
- data/spec/{fixtures/services/report_definition → sem4r/report_definition/fixtures}/mutate_add-req.xml +0 -0
- data/spec/{fixtures/services/report_definition → sem4r/report_definition/fixtures}/mutate_add-req_orig.xml +0 -0
- data/spec/sem4r/report_definition/report_definition_service_spec.rb +5 -3
- data/spec/sem4r/report_definition/report_definition_spec.rb +6 -3
- data/spec/sem4r/rexml_parsing_spec.rb +22 -22
- data/spec/sem4r/services/service_spec.rb +2 -1
- data/spec/sem4r/services/soap_call_spec.rb +6 -5
- data/spec/sem4r/services/soap_message_v13_spec.rb +5 -11
- data/spec/{fixtures/services/targeting_idea → sem4r/targeting_idea/fixtures}/get-req-all-options.xml +0 -0
- data/spec/{fixtures/services/targeting_idea → sem4r/targeting_idea/fixtures}/get-req.xml +9 -11
- data/spec/sem4r/targeting_idea/fixtures/get-res.xml +2276 -0
- data/spec/sem4r/targeting_idea/targeting_idea_selector_spec.rb +30 -11
- data/spec/sem4r/targeting_idea/targeting_idea_service_spec.rb +4 -3
- data/spec/sem4r/targeting_idea/targeting_idea_spec.rb +5 -4
- data/spec/sem4r/v13_account/account_account_extension_spec.rb +47 -0
- data/spec/sem4r/v13_account/account_service_spec.rb +6 -5
- data/spec/sem4r/v13_account/billing_address_spec.rb +40 -0
- data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_account_info-req.xml +0 -0
- data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_account_info-res.xml +0 -0
- data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_client_accounts-req.xml +0 -0
- data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_client_accounts-res.xml +0 -0
- data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/get_all_jobs-req.xml +0 -0
- data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/get_all_jobs-res.xml +2 -2
- data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/schedule_report_job-req.xml +0 -0
- data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/schedule_report_job-res.xml +0 -0
- data/spec/sem4r/v13_report/report_service_spec.rb +13 -11
- data/spec/sem4r/v13_report/report_spec.rb +4 -3
- data/spec/sem4r_stubs.rb +182 -0
- data/spec/soap_helpers/soap_attributes_spec.rb +129 -0
- metadata +225 -125
- data/spec/fixtures/services/info/get_unit_count-req.xml +0 -30
- data/spec/fixtures/services/info/get_unit_count-res.xml +0 -29
- data/spec/fixtures/services/targeting_idea/get-res.xml +0 -3601
- data/spec/sem4r/soap_attributes_spec.rb +0 -116
- data/spec/sem4r_spec_helper.rb +0 -353
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -22,7 +23,7 @@
|
|
22
23
|
#
|
23
24
|
# -------------------------------------------------------------------------
|
24
25
|
|
25
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe TargetingIdeaSelector do
|
28
29
|
include Sem4rSpecHelper, AggregatesSpecHelper
|
@@ -43,16 +44,22 @@ describe TargetingIdeaSelector do
|
|
43
44
|
end
|
44
45
|
|
45
46
|
related_to_keyword_search_parameter do
|
46
|
-
|
47
|
-
|
47
|
+
['dvd player', 'car stereo'].each do |term|
|
48
|
+
text term
|
49
|
+
match_type 'EXACT'
|
50
|
+
end
|
48
51
|
end
|
49
52
|
|
50
53
|
country_target_search_parameter do
|
51
54
|
country_code 'US'
|
52
55
|
end
|
56
|
+
|
57
|
+
ngram_group_search_parameter do
|
58
|
+
ngram 'dvd player'
|
59
|
+
end
|
53
60
|
end
|
54
61
|
|
55
|
-
xml_expected = read_model("//
|
62
|
+
xml_expected = read_model("//selector", "targeting_idea", "get-req.xml")
|
56
63
|
idea_selector.to_xml.should xml_equivalent(xml_expected)
|
57
64
|
end
|
58
65
|
|
@@ -69,7 +76,7 @@ describe TargetingIdeaSelector do
|
|
69
76
|
match_type 'EXACT'
|
70
77
|
end
|
71
78
|
end
|
72
|
-
read_model("//
|
79
|
+
read_model("//requestedAttributeTypes", "targeting_idea", "get-req-all-options.xml") do |attribute_type|
|
73
80
|
idea_selector.to_xml.should xml_contains(attribute_type)
|
74
81
|
end
|
75
82
|
end
|
@@ -77,10 +84,12 @@ describe TargetingIdeaSelector do
|
|
77
84
|
describe RelatedToKeywordSearchParameter do
|
78
85
|
it "should produce xml (input for google)" do
|
79
86
|
sp = RelatedToKeywordSearchParameter.new do
|
80
|
-
|
81
|
-
|
87
|
+
['dvd player', 'car stereo'].each do |term|
|
88
|
+
text term
|
89
|
+
match_type 'EXACT'
|
90
|
+
end
|
82
91
|
end
|
83
|
-
xml_expected = read_model("//
|
92
|
+
xml_expected = read_model("//searchParameters[@type='RelatedToKeywordSearchParameter']", "targeting_idea", "get-req.xml")
|
84
93
|
sp.to_xml.should xml_equivalent(xml_expected)
|
85
94
|
end
|
86
95
|
end
|
@@ -91,7 +100,7 @@ describe TargetingIdeaSelector do
|
|
91
100
|
text "media player"
|
92
101
|
match_type "EXACT"
|
93
102
|
end
|
94
|
-
xml_expected = read_model("//
|
103
|
+
xml_expected = read_model("//searchParameters[@type='ExcludedKeywordSearchParameter']", "targeting_idea", "get-req.xml")
|
95
104
|
sp.to_xml.should xml_equivalent(xml_expected)
|
96
105
|
end
|
97
106
|
end
|
@@ -102,7 +111,7 @@ describe TargetingIdeaSelector do
|
|
102
111
|
match_type 'BROAD'
|
103
112
|
match_type "EXACT"
|
104
113
|
end
|
105
|
-
xml_expected = read_model("//
|
114
|
+
xml_expected = read_model("//searchParameters[@type='KeywordMatchTypeSearchParameter']", "targeting_idea", "get-req.xml")
|
106
115
|
sp.to_xml.should xml_equivalent(xml_expected)
|
107
116
|
end
|
108
117
|
end
|
@@ -112,7 +121,17 @@ describe TargetingIdeaSelector do
|
|
112
121
|
sp = CountryTargetSearchParameter.new do
|
113
122
|
country_code 'US'
|
114
123
|
end
|
115
|
-
xml_expected = read_model("//
|
124
|
+
xml_expected = read_model("//searchParameters[@type='CountryTargetSearchParameter']", "targeting_idea", "get-req.xml")
|
125
|
+
sp.to_xml.should xml_equivalent(xml_expected)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe NgramGroupsSearchParameter do
|
130
|
+
it "should produce xml (input for google)" do
|
131
|
+
sp = NgramGroupsSearchParameter.new do
|
132
|
+
ngram 'dvd player'
|
133
|
+
end
|
134
|
+
xml_expected = read_model("//searchParameters[@type='NgramGroupsSearchParameter']", "targeting_idea", "get-req.xml")
|
116
135
|
sp.to_xml.should xml_equivalent(xml_expected)
|
117
136
|
end
|
118
137
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -22,7 +23,7 @@
|
|
22
23
|
#
|
23
24
|
# -------------------------------------------------------------------------
|
24
25
|
|
25
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe TargetingIdeaService do
|
28
29
|
include Sem4rSpecHelper
|
@@ -32,12 +33,12 @@ describe TargetingIdeaService do
|
|
32
33
|
end
|
33
34
|
|
34
35
|
it "should define 'get'" do
|
35
|
-
response_xml =
|
36
|
+
response_xml = read_xml("targeting_idea", "get-res.xml")
|
36
37
|
connector = mock("connector")
|
37
38
|
connector.should_receive(:send).and_return(response_xml)
|
38
39
|
service = TargetingIdeaService.new(connector)
|
39
40
|
soap_message = service.get( @credentials, "xml" )
|
40
|
-
els =
|
41
|
+
els = soap_message.response.xpath("//getResponse")
|
41
42
|
els.should_not be_empty
|
42
43
|
end
|
43
44
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -22,20 +23,20 @@
|
|
22
23
|
#
|
23
24
|
# -------------------------------------------------------------------------
|
24
25
|
|
25
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe TargetingIdea do
|
28
29
|
include Sem4rSpecHelper, AggregatesSpecHelper
|
29
30
|
|
30
31
|
it "should parse xml (produced by google)" do
|
31
|
-
el = read_model("//entries", "
|
32
|
+
el = read_model("//entries", "targeting_idea", "get-res.xml")
|
32
33
|
idea = TargetingIdea.from_element(el)
|
33
34
|
idea.should have(2).attributes
|
34
35
|
end
|
35
36
|
|
36
37
|
describe TKeywordAttribute do
|
37
38
|
it "should parse xml (produced by google)" do
|
38
|
-
el = read_model("//value", "
|
39
|
+
el = read_model("//value", "targeting_idea", "get-res.xml")
|
39
40
|
attr = TKeywordAttribute.from_element(el)
|
40
41
|
attr.text.should == "sample keyword"
|
41
42
|
attr.match_type.should == "EXACT"
|
@@ -44,7 +45,7 @@ describe TargetingIdea do
|
|
44
45
|
|
45
46
|
describe TIdeaTypeAttribute do
|
46
47
|
it "should parse xml (produced by google)" do
|
47
|
-
el = read_model("//value[@type='IdeaTypeAttribute']", "
|
48
|
+
el = read_model("//value[@type='IdeaTypeAttribute']", "targeting_idea", "get-res.xml")
|
48
49
|
attr = TIdeaTypeAttribute.from_element(el)
|
49
50
|
attr.value.should == "KEYWORD"
|
50
51
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# -------------------------------------------------------------------------
|
3
|
+
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# -------------------------------------------------------------------------
|
25
|
+
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
27
|
+
|
28
|
+
describe AccountAccountExtension do
|
29
|
+
include Sem4rSpecHelper
|
30
|
+
|
31
|
+
before do
|
32
|
+
services = stub("services")
|
33
|
+
stub_service_account(services)
|
34
|
+
stub_service_info(services)
|
35
|
+
stub_service_campaign(services)
|
36
|
+
stub_service_report(services)
|
37
|
+
@adwords = stub_adwords(services)
|
38
|
+
@credentials = stub_credentials
|
39
|
+
|
40
|
+
@account = Account.new(@adwords, @credentials)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should extracts list of account with 'account.client_accounts'" do
|
44
|
+
@account.client_accounts.should have(5).items
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -22,7 +23,7 @@
|
|
22
23
|
#
|
23
24
|
# -------------------------------------------------------------------------
|
24
25
|
|
25
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe AccountService do
|
28
29
|
include Sem4rSpecHelper
|
@@ -32,7 +33,7 @@ describe AccountService do
|
|
32
33
|
end
|
33
34
|
|
34
35
|
it "should define 'account_info'" do
|
35
|
-
response_xml =
|
36
|
+
response_xml = read_xml("v13_account", "get_account_info-res.xml")
|
36
37
|
|
37
38
|
connector = mock("connector")
|
38
39
|
connector.should_receive(:send).and_return(response_xml)
|
@@ -40,12 +41,12 @@ describe AccountService do
|
|
40
41
|
service = AccountService.new(connector)
|
41
42
|
soap_message = service.account_info( @credentials )
|
42
43
|
|
43
|
-
els =
|
44
|
+
els = soap_message.response.xpath("//getAccountInfoResponse")
|
44
45
|
els.should_not be_empty
|
45
46
|
end
|
46
47
|
|
47
48
|
it "should define 'client_accounts'" do
|
48
|
-
response_xml =
|
49
|
+
response_xml = read_xml("v13_account", "get_client_accounts-res.xml")
|
49
50
|
|
50
51
|
connector = mock("connector")
|
51
52
|
connector.should_receive(:send).and_return(response_xml)
|
@@ -53,7 +54,7 @@ describe AccountService do
|
|
53
54
|
service = AccountService.new(connector)
|
54
55
|
soap_message = service.client_accounts( @credentials )
|
55
56
|
|
56
|
-
els =
|
57
|
+
els = soap_message.response.xpath("//getClientAccountsResponse")
|
57
58
|
els.should_not be_empty
|
58
59
|
end
|
59
60
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# -------------------------------------------------------------------------
|
3
|
+
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# -------------------------------------------------------------------------
|
25
|
+
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
27
|
+
|
28
|
+
describe BillingAddress do
|
29
|
+
include Sem4rSpecHelper
|
30
|
+
|
31
|
+
it "should parse xml (produced by google)" do
|
32
|
+
model = read_model( "//billingAddress", "v13_account", "get_account_info-res.xml")
|
33
|
+
ba = BillingAddress.from_element(model)
|
34
|
+
ba.city.should == "Mountain View"
|
35
|
+
ba.country_code.should == "US"
|
36
|
+
ba.phone.should == "4085551212"
|
37
|
+
ba.email.should == "Some@email"
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_account_info-req.xml
RENAMED
File without changes
|
data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_account_info-res.xml
RENAMED
File without changes
|
data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_client_accounts-req.xml
RENAMED
File without changes
|
data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_client_accounts-res.xml
RENAMED
File without changes
|
File without changes
|
@@ -14,8 +14,8 @@
|
|
14
14
|
</requestId>
|
15
15
|
</soapenv:Header>
|
16
16
|
<soapenv:Body>
|
17
|
-
<getAllJobsResponse
|
18
|
-
|
17
|
+
<getAllJobsResponse>
|
18
|
+
<!-- <getAllJobsResponse xmlns=''> -->
|
19
19
|
<ns1:getAllJobsReturn xsi:type='ns1:DefinedReportJob' xmlns:ns1='https://adwords.google.com/api/adwords/v13'>
|
20
20
|
<ns1:clientEmails xsi:nil='true'/>
|
21
21
|
<ns1:crossClient>false</ns1:crossClient>
|
data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/schedule_report_job-req.xml
RENAMED
File without changes
|
data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/schedule_report_job-res.xml
RENAMED
File without changes
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -22,7 +23,7 @@
|
|
22
23
|
#
|
23
24
|
# -------------------------------------------------------------------------
|
24
25
|
|
25
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe ReportService do
|
28
29
|
include Sem4rSpecHelper
|
@@ -32,7 +33,7 @@ describe ReportService do
|
|
32
33
|
end
|
33
34
|
|
34
35
|
it "should define 'all'" do
|
35
|
-
response_xml =
|
36
|
+
response_xml = read_xml("v13_report", "get_all_jobs-res.xml")
|
36
37
|
|
37
38
|
connector = mock("connector")
|
38
39
|
connector.should_receive(:send).and_return(response_xml)
|
@@ -40,13 +41,13 @@ describe ReportService do
|
|
40
41
|
report_service = ReportService.new(connector)
|
41
42
|
soap_message = report_service.all( @credentials )
|
42
43
|
|
43
|
-
els =
|
44
|
+
els = soap_message.response.xpath("//getAllJobsReturn")
|
44
45
|
els.should_not be_empty
|
45
46
|
els.should have(4).elements
|
46
47
|
end
|
47
48
|
|
48
49
|
it "should define 'validate'" do
|
49
|
-
response_xml =
|
50
|
+
response_xml = read_xml("v13_report", "get_all_jobs-res.xml")
|
50
51
|
|
51
52
|
connector = mock("connector")
|
52
53
|
connector.should_receive(:send).and_return(response_xml)
|
@@ -54,13 +55,13 @@ describe ReportService do
|
|
54
55
|
report_service = ReportService.new(connector)
|
55
56
|
soap_message = report_service.validate( @credentials, "xml" )
|
56
57
|
|
57
|
-
els =
|
58
|
+
els = soap_message.response.xpath("//getAllJobsReturn")
|
58
59
|
els.should_not be_empty
|
59
60
|
els.should have(4).elements
|
60
61
|
end
|
61
62
|
|
62
63
|
it "should define 'schedule'" do
|
63
|
-
response_xml =
|
64
|
+
response_xml = read_xml("v13_report", "get_all_jobs-res.xml")
|
64
65
|
|
65
66
|
connector = mock("connector")
|
66
67
|
connector.should_receive(:send).and_return(response_xml)
|
@@ -68,13 +69,13 @@ describe ReportService do
|
|
68
69
|
report_service = ReportService.new(connector)
|
69
70
|
soap_message = report_service.schedule( @credentials, "xml" )
|
70
71
|
|
71
|
-
els =
|
72
|
+
els = soap_message.response.xpath("//getAllJobsReturn")
|
72
73
|
els.should_not be_empty
|
73
74
|
els.should have(4).elements
|
74
75
|
end
|
75
76
|
|
76
77
|
it "should define 'status'" do
|
77
|
-
response_xml =
|
78
|
+
response_xml = read_xml("v13_report", "get_all_jobs-res.xml")
|
78
79
|
|
79
80
|
connector = mock("connector")
|
80
81
|
connector.should_receive(:send).and_return(response_xml)
|
@@ -82,13 +83,14 @@ describe ReportService do
|
|
82
83
|
report_service = ReportService.new(connector)
|
83
84
|
soap_message = report_service.status( @credentials, "job_id" )
|
84
85
|
|
85
|
-
els = REXML::XPath.match( soap_message.response, "//getAllJobsResponse/getAllJobsReturn")
|
86
|
+
# els = REXML::XPath.match( soap_message.response, "//getAllJobsResponse/getAllJobsReturn")
|
87
|
+
els = soap_message.response.xpath("//getAllJobsReturn")
|
86
88
|
els.should_not be_empty
|
87
89
|
els.should have(4).elements
|
88
90
|
end
|
89
91
|
|
90
92
|
it "should define 'url'" do
|
91
|
-
response_xml =
|
93
|
+
response_xml = read_xml("v13_report", "get_all_jobs-res.xml")
|
92
94
|
|
93
95
|
connector = mock("connector")
|
94
96
|
connector.should_receive(:send).and_return(response_xml)
|
@@ -96,7 +98,7 @@ describe ReportService do
|
|
96
98
|
report_service = ReportService.new(connector)
|
97
99
|
soap_message = report_service.url( @credentials, "job_id" )
|
98
100
|
|
99
|
-
els =
|
101
|
+
els = soap_message.response.xpath("//getAllJobsReturn")
|
100
102
|
els.should_not be_empty
|
101
103
|
els.should have(4).elements
|
102
104
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -22,7 +23,7 @@
|
|
22
23
|
#
|
23
24
|
# -------------------------------------------------------------------------
|
24
25
|
|
25
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe Report do
|
28
29
|
include Sem4rSpecHelper
|
@@ -51,7 +52,7 @@ describe Report do
|
|
51
52
|
end
|
52
53
|
|
53
54
|
it "should parse xml (produced by google)" do
|
54
|
-
el = read_model("//getAllJobsReturn", "
|
55
|
+
el = read_model("//getAllJobsReturn", "v13_report", "get_all_jobs-res.xml")
|
55
56
|
report = Report.from_element(@account, el)
|
56
57
|
report.id.should == 11
|
57
58
|
report.name.should == "report [11]"
|
@@ -72,7 +73,7 @@ describe Report do
|
|
72
73
|
column "KeywordTypeDisplay"
|
73
74
|
end
|
74
75
|
|
75
|
-
expected = read_model("//job", "
|
76
|
+
expected = read_model("//job", "v13_report", "schedule_report_job-req.xml")
|
76
77
|
report.to_xml.should xml_equivalent(expected)
|
77
78
|
end
|
78
79
|
|
data/spec/sem4r_stubs.rb
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
# -------------------------------------------------------------------------
|
2
|
+
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#
|
23
|
+
# -------------------------------------------------------------------------
|
24
|
+
|
25
|
+
|
26
|
+
module Sem4rSpecHelper
|
27
|
+
|
28
|
+
#############################################################################
|
29
|
+
# stub services
|
30
|
+
|
31
|
+
def stub_service_account(service)
|
32
|
+
xml_document = read_xml_document("v13_account", "get_account_info-res.xml")
|
33
|
+
soap_message_account_info = stub("soap_message_account_info", :response => xml_document, :counters => nil)
|
34
|
+
|
35
|
+
xml_document = read_xml_document("v13_account", "get_client_accounts-res.xml")
|
36
|
+
soap_message_client_accounts = stub("soap_message_client_accounts", :response => xml_document, :counters => nil)
|
37
|
+
|
38
|
+
service_account = stub("service_account",
|
39
|
+
:account_info => soap_message_account_info,
|
40
|
+
:client_accounts => soap_message_client_accounts)
|
41
|
+
service.stub(:account).and_return(service_account)
|
42
|
+
end
|
43
|
+
|
44
|
+
def stub_service_info(service)
|
45
|
+
xml_document = read_xml_document("info", "get_unit_count-res.xml")
|
46
|
+
soap_message = stub("soap_message", :response => xml_document, :counters => nil)
|
47
|
+
|
48
|
+
service_info = stub("service_info", :get => soap_message)
|
49
|
+
service.stub(:info).and_return(service_info)
|
50
|
+
end
|
51
|
+
|
52
|
+
def stub_service_campaign(service)
|
53
|
+
xml_document = read_xml_document("campaign", "mutate_add-res.xml")
|
54
|
+
soap_message_create = stub("soap_message_create", :response => xml_document, :counters => nil)
|
55
|
+
|
56
|
+
xml_document = read_xml_document("campaign", "get-res.xml")
|
57
|
+
soap_message_all = stub("soap_message_all", :response => xml_document, :counters => nil)
|
58
|
+
|
59
|
+
service_campaign = stub("service_campaign",
|
60
|
+
:create => soap_message_create,
|
61
|
+
:all => soap_message_all)
|
62
|
+
service.stub(:campaign).and_return(service_campaign)
|
63
|
+
end
|
64
|
+
|
65
|
+
def stub_service_ad_group(service)
|
66
|
+
xml_document = read_xml_document("ad_group", "mutate_add-res.xml")
|
67
|
+
soap_message = stub("soap_message", :response => xml_document, :counters => nil)
|
68
|
+
|
69
|
+
service_ad_group = stub("service_ad_group", :create => soap_message)
|
70
|
+
service.stub(:ad_group).and_return(service_ad_group)
|
71
|
+
end
|
72
|
+
|
73
|
+
def stub_service_ad_group_ad(service)
|
74
|
+
xml_document = read_xml_document("ad_group_ad", "mutate_add_text_ad-res.xml")
|
75
|
+
soap_message = stub("soap_message", :response => xml_document, :counters => nil)
|
76
|
+
|
77
|
+
service_ad_group_ad = stub("service_ad_group_ad", :mutate => soap_message)
|
78
|
+
service.stub(:ad_group_ad).and_return(service_ad_group_ad)
|
79
|
+
end
|
80
|
+
|
81
|
+
def stub_service_ad_group_criterion(service)
|
82
|
+
xml_document = read_xml_document("ad_group_criterion", "mutate_add_criterion_keyword-res.xml")
|
83
|
+
soap_message = stub("soap_message", :response => xml_document, :counters => nil)
|
84
|
+
|
85
|
+
service_ad_group_criterion = stub("service_ad_group_criterion", :mutate => soap_message)
|
86
|
+
service.stub(:ad_group_criterion).and_return(service_ad_group_criterion)
|
87
|
+
end
|
88
|
+
|
89
|
+
def stub_service_ad_param(service)
|
90
|
+
# xml_document = read_xml_document("services", "ad_group_criterion_service", "mutate_add_criterion_keyword-res.xml")
|
91
|
+
soap_message = stub("soap_message", :response => nil, :counters => nil)
|
92
|
+
|
93
|
+
service_ad_param = stub("service_ad_param", :mutate => soap_message)
|
94
|
+
service.stub(:ad_param).and_return(service_ad_param)
|
95
|
+
end
|
96
|
+
|
97
|
+
def stub_service_report(service)
|
98
|
+
all_xml_document = read_xml_document("v13_report", "get_all_jobs-res.xml")
|
99
|
+
all_soap_message = stub("soap_message", :response => all_xml_document, :counters => nil)
|
100
|
+
set_soap_message = stub("soap_message", :response => nil, :counters => nil)
|
101
|
+
|
102
|
+
service_report = stub("service_report",
|
103
|
+
:set => set_soap_message,
|
104
|
+
:all => all_soap_message)
|
105
|
+
|
106
|
+
service.stub(:report).and_return(service_report)
|
107
|
+
end
|
108
|
+
|
109
|
+
def stub_service_report_definition(service)
|
110
|
+
service_report_definition = stub("service_report_definition")
|
111
|
+
service.stub(:report_definition).and_return(service_report_definition)
|
112
|
+
end
|
113
|
+
|
114
|
+
#############################################################################
|
115
|
+
|
116
|
+
def stub_services
|
117
|
+
double("services")
|
118
|
+
end
|
119
|
+
|
120
|
+
def stub_adwords(services = nil)
|
121
|
+
stub("adwords",
|
122
|
+
:service => services ||= stub_services,
|
123
|
+
:add_counters => nil)
|
124
|
+
end
|
125
|
+
|
126
|
+
def stub_credentials
|
127
|
+
stub("credentials",
|
128
|
+
:sandbox? => true,
|
129
|
+
:email => "example@gmail.com",
|
130
|
+
:password => "secret",
|
131
|
+
:client_email => nil,
|
132
|
+
:useragent => "sem4r",
|
133
|
+
:developer_token => "dev_token",
|
134
|
+
:authentication_token => "1234567890",
|
135
|
+
:mutable? => false
|
136
|
+
)
|
137
|
+
end
|
138
|
+
|
139
|
+
def stub_account(services = nil)
|
140
|
+
adwords = stub_adwords(services)
|
141
|
+
credentials = stub_credentials
|
142
|
+
account = stub("account",
|
143
|
+
:adwords => adwords,
|
144
|
+
:credentials => credentials,
|
145
|
+
:id => 1000)
|
146
|
+
account
|
147
|
+
end
|
148
|
+
|
149
|
+
def stub_campaign(services = nil)
|
150
|
+
adwords = stub_adwords(services)
|
151
|
+
credentials = stub_credentials
|
152
|
+
|
153
|
+
campaign = stub("campaign",
|
154
|
+
:adwords => adwords,
|
155
|
+
:credentials => credentials,
|
156
|
+
:inside_initialize? => false,
|
157
|
+
:id => 1000)
|
158
|
+
campaign
|
159
|
+
end
|
160
|
+
|
161
|
+
def stub_adgroup(services = nil, id = 1000)
|
162
|
+
adwords = stub_adwords(services)
|
163
|
+
credentials = stub_credentials
|
164
|
+
stub("adgroup",
|
165
|
+
:adwords => adwords,
|
166
|
+
:credentials => credentials,
|
167
|
+
:inside_initialize? => false,
|
168
|
+
:id => id)
|
169
|
+
end
|
170
|
+
|
171
|
+
def stub_criterion(services = nil)
|
172
|
+
adwords = stub_adwords(services)
|
173
|
+
credentials = stub_credentials
|
174
|
+
|
175
|
+
stub("criterion",
|
176
|
+
:adwords => adwords,
|
177
|
+
:credentials => credentials,
|
178
|
+
:inside_initialize? => false,
|
179
|
+
:id => 1000,
|
180
|
+
:ad_group => stub_adgroup(services))
|
181
|
+
end
|
182
|
+
end
|