sem4r 0.1.1
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.
- data/LICENSE +22 -0
- data/README.rdoc +74 -0
- data/Rakefile +126 -0
- data/VERSION.yml +5 -0
- data/bin/sem +34 -0
- data/config/sem4r.example.yml +51 -0
- data/examples_blog/2009-11-29-hello-world.rb +12 -0
- data/examples_blog/2009-12-12-create-campaign.rb +29 -0
- data/examples_blog/2010-02-06-constants-scope.rb +8 -0
- data/examples_blog/2010-02-07-ad-parameters.rb +47 -0
- data/examples_sem4r/01_get_account.rb +37 -0
- data/examples_sem4r/02_get_info.rb +32 -0
- data/examples_sem4r/03_list_ad.rb +47 -0
- data/examples_sem4r/04_list_keywords.rb +54 -0
- data/examples_sem4r/05_request_report.rb +51 -0
- data/examples_sem4r/05_request_report_2010.rb +40 -0
- data/examples_sem4r/06_create_campaigns.rb +86 -0
- data/examples_sem4r/07_create_campaigns_block.rb +99 -0
- data/examples_sem4r/07_create_campaigns_simple.rb +65 -0
- data/examples_sem4r/08_ad_params.rb +70 -0
- data/examples_sem4r/09_targeting_idea.rb +59 -0
- data/examples_sem4r/10_get_location.rb +28 -0
- data/examples_sem4r/11_submit_bulk_job.rb +82 -0
- data/examples_sem4r/12_list_bulk_job.rb +29 -0
- data/examples_sem4r/30_prune_empty_adgroup.rb +50 -0
- data/examples_sem4r/31_empty_accounts.rb +40 -0
- data/examples_sem4r/example_helper.rb +115 -0
- data/lib/sem4r/account.rb +349 -0
- data/lib/sem4r/ad_extension_override/ad_extension_override_service.rb +30 -0
- data/lib/sem4r/ad_group/ad_group.rb +340 -0
- data/lib/sem4r/ad_group/ad_group_bids.rb +170 -0
- data/lib/sem4r/ad_group/ad_group_service.rb +75 -0
- data/lib/sem4r/ad_group/mobile_ad_image.rb +33 -0
- data/lib/sem4r/ad_group_ad/ad_group_ad.rb +98 -0
- data/lib/sem4r/ad_group_ad/ad_group_ad_operations.rb +38 -0
- data/lib/sem4r/ad_group_ad/ad_group_ad_service.rb +56 -0
- data/lib/sem4r/ad_group_ad/ad_group_mobile_ad.rb +137 -0
- data/lib/sem4r/ad_group_ad/ad_group_text_ad.rb +98 -0
- data/lib/sem4r/ad_group_criterion/ad_group_criterion.rb +144 -0
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_bids.rb +115 -0
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_operations.rb +35 -0
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_service.rb +58 -0
- data/lib/sem4r/ad_group_criterion/criterion.rb +67 -0
- data/lib/sem4r/ad_group_criterion/criterion_keyword.rb +80 -0
- data/lib/sem4r/ad_group_criterion/criterion_placement.rb +66 -0
- data/lib/sem4r/ad_param/ad_param.rb +96 -0
- data/lib/sem4r/ad_param/ad_param_operation.rb +34 -0
- data/lib/sem4r/ad_param/ad_param_service.rb +59 -0
- data/lib/sem4r/adwords.rb +242 -0
- data/lib/sem4r/api_counters.rb +7 -0
- data/lib/sem4r/base.rb +43 -0
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job.rb +108 -0
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_selector.rb +56 -0
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_service.rb +57 -0
- data/lib/sem4r/bulk_mutate_job/job_operations.rb +35 -0
- data/lib/sem4r/campaign/campaign.rb +193 -0
- data/lib/sem4r/campaign/campaign_service.rb +91 -0
- data/lib/sem4r/campaign_criterion/campaign_criterion_service.rb +30 -0
- data/lib/sem4r/campaign_target/campaign_target_service.rb +30 -0
- data/lib/sem4r/cli/cli_command.rb +101 -0
- data/lib/sem4r/cli/cli_commands.rb +60 -0
- data/lib/sem4r/cli/cli_common_args.rb +293 -0
- data/lib/sem4r/cli/cli_download_report.rb +81 -0
- data/lib/sem4r/cli/cli_helpers.rb +57 -0
- data/lib/sem4r/cli/cli_ideas.rb +100 -0
- data/lib/sem4r/cli/cli_list_ads.rb +74 -0
- data/lib/sem4r/cli/cli_list_keywords.rb +76 -0
- data/lib/sem4r/cli/cli_request_report.rb +104 -0
- data/lib/sem4r/cli/cli_sem.rb +64 -0
- data/lib/sem4r/common/operation.rb +78 -0
- data/lib/sem4r/credentials.rb +86 -0
- data/lib/sem4r/extensions.rb +62 -0
- data/lib/sem4r/geo_location/geo_location_service.rb +59 -0
- data/lib/sem4r/info/info_service.rb +115 -0
- data/lib/sem4r/report_definition/report_definition.rb +104 -0
- data/lib/sem4r/report_definition/report_definition_operation.rb +34 -0
- data/lib/sem4r/report_definition/report_definition_selector.rb +31 -0
- data/lib/sem4r/report_definition/report_definition_service.rb +55 -0
- data/lib/sem4r/sem4r_error.rb +28 -0
- data/lib/sem4r/services/service.rb +74 -0
- data/lib/sem4r/services/soap_call.rb +100 -0
- data/lib/sem4r/services/soap_connector.rb +284 -0
- data/lib/sem4r/services/soap_error.rb +38 -0
- data/lib/sem4r/services/soap_message_v13.rb +129 -0
- data/lib/sem4r/services/soap_message_v2009.rb +170 -0
- data/lib/sem4r/soap_attributes.rb +141 -0
- data/lib/sem4r/targeting_idea/targeting_idea.rb +158 -0
- data/lib/sem4r/targeting_idea/targeting_idea_selector.rb +200 -0
- data/lib/sem4r/targeting_idea/targeting_idea_service.rb +51 -0
- data/lib/sem4r/v13_account/account_service.rb +54 -0
- data/lib/sem4r/v13_account/billing_address.rb +67 -0
- data/lib/sem4r/v13_report/report.rb +185 -0
- data/lib/sem4r/v13_report/report_job.rb +51 -0
- data/lib/sem4r/v13_report/report_service.rb +89 -0
- data/lib/sem4r/v13_traffic_estimator/traffic_estimator_service.rb +30 -0
- data/lib/sem4r.rb +142 -0
- data/lib/sem4r_cli.rb +40 -0
- data/sem4r.gemspec +247 -0
- data/spec/aggregates_spec_helper.rb +59 -0
- data/spec/fixtures/sem4r.example.yml +26 -0
- data/spec/fixtures/services/ad_group/get-first-req.xml +28 -0
- data/spec/fixtures/services/ad_group/get-first-res.xml +91 -0
- data/spec/fixtures/services/ad_group/get-manual-cpm-bids-req.xml +106 -0
- data/spec/fixtures/services/ad_group/get-manual-cpm-bids-res.xml +75 -0
- data/spec/fixtures/services/ad_group/mutate_add-req.xml +52 -0
- data/spec/fixtures/services/ad_group/mutate_add-res.xml +33 -0
- data/spec/fixtures/services/ad_group_ad/get_mobile_ad-req.xml +28 -0
- data/spec/fixtures/services/ad_group_ad/get_mobile_ad-res.xml +194 -0
- data/spec/fixtures/services/ad_group_ad/get_text_ad-req.xml +29 -0
- data/spec/fixtures/services/ad_group_ad/get_text_ad-res.xml +55 -0
- data/spec/fixtures/services/ad_group_ad/mutate_add_mobile_ad-req.xml +50 -0
- data/spec/fixtures/services/ad_group_ad/mutate_add_mobile_ad-res.xml +42 -0
- data/spec/fixtures/services/ad_group_ad/mutate_add_text_ad-req.xml +37 -0
- data/spec/fixtures/services/ad_group_ad/mutate_add_text_ad-res.xml +32 -0
- data/spec/fixtures/services/ad_group_ad/mutate_add_two_criterions-req.xml +83 -0
- data/spec/fixtures/services/ad_group_ad/mutate_add_two_criterions-res.xml +95 -0
- data/spec/fixtures/services/ad_group_criterion/get-req.xml +28 -0
- data/spec/fixtures/services/ad_group_criterion/get-res.xml +242 -0
- data/spec/fixtures/services/ad_group_criterion/mutate_add_criterion_keyword-req.xml +48 -0
- data/spec/fixtures/services/ad_group_criterion/mutate_add_criterion_keyword-res.xml +47 -0
- data/spec/fixtures/services/ad_group_criterion/mutate_add_criterion_placement-req.xml +35 -0
- data/spec/fixtures/services/ad_group_criterion/mutate_add_criterion_placement-res.xml +32 -0
- data/spec/fixtures/services/ad_group_criterion/mutate_add_negative_keyword-req.xml +37 -0
- data/spec/fixtures/services/ad_group_criterion/mutate_add_negative_keyword-res.xml +51 -0
- data/spec/fixtures/services/ad_param/mutate_set-req.xml +43 -0
- data/spec/fixtures/services/ad_param/mutate_set-res.xml +29 -0
- data/spec/fixtures/services/bulk_mutate_job/get-req.xml +36 -0
- data/spec/fixtures/services/bulk_mutate_job/get-res.xml +54 -0
- data/spec/fixtures/services/bulk_mutate_job/mutate-req.xml +69 -0
- data/spec/fixtures/services/bulk_mutate_job/mutate-res.xml +48 -0
- data/spec/fixtures/services/campaign/get-req.xml +37 -0
- data/spec/fixtures/services/campaign/get-res.xml +1986 -0
- data/spec/fixtures/services/campaign/mutate_add-req.xml +37 -0
- data/spec/fixtures/services/campaign/mutate_add-res.xml +42 -0
- data/spec/fixtures/services/error.xml +28 -0
- data/spec/fixtures/services/info/get_unit_count-req.xml +30 -0
- data/spec/fixtures/services/info/get_unit_count-res.xml +29 -0
- data/spec/fixtures/services/report_definition/mutate_add-req.xml +24 -0
- data/spec/fixtures/services/report_definition/mutate_add-req_orig.xml +45 -0
- data/spec/fixtures/services/targeting_idea/get-req-all-options.xml +57 -0
- data/spec/fixtures/services/targeting_idea/get-req.xml +60 -0
- data/spec/fixtures/services/targeting_idea/get-res.xml +3601 -0
- data/spec/fixtures/services/v13_account/get_account_info-req.xml +23 -0
- data/spec/fixtures/services/v13_account/get_account_info-res.xml +54 -0
- data/spec/fixtures/services/v13_account/get_client_accounts-req.xml +22 -0
- data/spec/fixtures/services/v13_account/get_client_accounts-res.xml +37 -0
- data/spec/fixtures/services/v13_report/get_all_jobs-req.xml +21 -0
- data/spec/fixtures/services/v13_report/get_all_jobs-res.xml +109 -0
- data/spec/fixtures/services/v13_report/schedule_report_job-req.xml +56 -0
- data/spec/fixtures/services/v13_report/schedule_report_job-res.xml +24 -0
- data/spec/sem4r/account_spec.rb +86 -0
- data/spec/sem4r/ad_group/ad_group_bids_spec.rb +67 -0
- data/spec/sem4r/ad_group/ad_group_service_spec.rb +66 -0
- data/spec/sem4r/ad_group/ad_group_spec.rb +212 -0
- data/spec/sem4r/ad_group_ad/ad_group_ad_operation_spec.rb +88 -0
- data/spec/sem4r/ad_group_ad/ad_group_ad_service_spec.rb +55 -0
- data/spec/sem4r/ad_group_ad/ad_group_ad_spec.rb +173 -0
- data/spec/sem4r/ad_group_criterion/ad_group_criterion_bids_spec.rb +60 -0
- data/spec/sem4r/ad_group_criterion/ad_group_criterion_service_spec.rb +55 -0
- data/spec/sem4r/ad_group_criterion/ad_group_criterion_spec.rb +103 -0
- data/spec/sem4r/ad_group_criterion/criterion_spec.rb +85 -0
- data/spec/sem4r/ad_param/ad_param_service_spec.rb +55 -0
- data/spec/sem4r/ad_param/ad_param_spec.rb +59 -0
- data/spec/sem4r/adwords_spec.rb +110 -0
- data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_service_spec.rb +63 -0
- data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_spec.rb +69 -0
- data/spec/sem4r/bulk_mutate_job/job_operation_spec.rb +48 -0
- data/spec/sem4r/campaign/campaign_service_spec.rb +66 -0
- data/spec/sem4r/campaign/campaign_spec.rb +105 -0
- data/spec/sem4r/cli/cli_spec.rb +71 -0
- data/spec/sem4r/credentials_spec.rb +65 -0
- data/spec/sem4r/report_definition/report_definition_service_spec.rb +44 -0
- data/spec/sem4r/report_definition/report_definition_spec.rb +105 -0
- data/spec/sem4r/rexml_parsing_spec.rb +103 -0
- data/spec/sem4r/services/service_spec.rb +36 -0
- data/spec/sem4r/services/soap_call_spec.rb +115 -0
- data/spec/sem4r/services/soap_message_v13_spec.rb +54 -0
- data/spec/sem4r/soap_attributes_spec.rb +116 -0
- data/spec/sem4r/targeting_idea/targeting_idea_selector_spec.rb +120 -0
- data/spec/sem4r/targeting_idea/targeting_idea_service_spec.rb +44 -0
- data/spec/sem4r/targeting_idea/targeting_idea_spec.rb +53 -0
- data/spec/sem4r/v13_account/account_service_spec.rb +60 -0
- data/spec/sem4r/v13_report/report_service_spec.rb +104 -0
- data/spec/sem4r/v13_report/report_spec.rb +79 -0
- data/spec/sem4r_spec_helper.rb +353 -0
- data/spec/spec_helper.rb +12 -0
- metadata +375 -0
|
@@ -0,0 +1,212 @@
|
|
|
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
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
describe AdGroup do
|
|
29
|
+
|
|
30
|
+
include Sem4rSpecHelper
|
|
31
|
+
|
|
32
|
+
before do
|
|
33
|
+
services = double("services")
|
|
34
|
+
stub_service_ad_group(services)
|
|
35
|
+
stub_service_ad_group_criterion(services)
|
|
36
|
+
stub_service_ad_group_ad(services)
|
|
37
|
+
stub_service_ad_param(services)
|
|
38
|
+
@campaign = stub_campaign(services)
|
|
39
|
+
@criterion = stub_criterion(services)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe "adgroup management" do
|
|
43
|
+
|
|
44
|
+
it "create should accept a block (instance_eval)" do
|
|
45
|
+
adgroup = AdGroup.create(@campaign) do
|
|
46
|
+
name "adgroup"
|
|
47
|
+
end
|
|
48
|
+
adgroup.name.should == "adgroup"
|
|
49
|
+
adgroup.id.should == 10
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "create should accept a block (call)" do
|
|
53
|
+
adgroup = AdGroup.create(@campaign) do |g|
|
|
54
|
+
g.name "adgroup"
|
|
55
|
+
end
|
|
56
|
+
adgroup.name.should == "adgroup"
|
|
57
|
+
adgroup.id.should == 10
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "create should accept a manual cpc bids" do
|
|
61
|
+
adgroup = AdGroup.create(@campaign) do
|
|
62
|
+
name "sem4r library"
|
|
63
|
+
manual_cpc_bids do
|
|
64
|
+
keyword_max_cpc 10000
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
adgroup.bids.should be_instance_of(ManualCPCAdGroupBids)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "create should accept a manual cpm bids" do
|
|
71
|
+
adgroup = AdGroup.create(@campaign) do
|
|
72
|
+
name "sem4r library"
|
|
73
|
+
manual_cpm_bids do
|
|
74
|
+
max_cpm 10000
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
adgroup.bids.should be_instance_of(ManualCPMAdGroupBids)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "should build xml (input for google)" do
|
|
81
|
+
adgroup = AdGroup.create(@campaign) do
|
|
82
|
+
name "sem4r library"
|
|
83
|
+
manual_cpc_bids do
|
|
84
|
+
keyword_max_cpc 20000000
|
|
85
|
+
site_max_cpc 30000000
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
exepected_xml = read_model("//operand", "services", "ad_group", "mutate_add-req.xml")
|
|
89
|
+
adgroup.to_xml("operand").should xml_equivalent(exepected_xml)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should parse xml (produced by google)" do
|
|
93
|
+
el = read_model("//entries", "services", "ad_group", "get-first-res.xml")
|
|
94
|
+
adgroup = AdGroup.from_element(@campaign, el)
|
|
95
|
+
adgroup.id.should == 3060217923
|
|
96
|
+
adgroup.name.should == "test adgroup"
|
|
97
|
+
adgroup.status.should == "ENABLED"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "should parse xml (produced by google) with manual cpm bids" do
|
|
101
|
+
el = read_model("//entries", "services", "ad_group", "get-manual-cpm-bids-res.xml")
|
|
102
|
+
adgroup = AdGroup.from_element(@campaign, el)
|
|
103
|
+
adgroup.bids.should be_instance_of(ManualCPMAdGroupBids)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
describe "ad management" do
|
|
109
|
+
|
|
110
|
+
it "should create a TextAd with a block" do
|
|
111
|
+
adgroup = AdGroup.new(@campaign) do
|
|
112
|
+
name "adgroup"
|
|
113
|
+
text_ad do
|
|
114
|
+
url "http://www.pluto.com"
|
|
115
|
+
display_url "www.Pluto.com"
|
|
116
|
+
headline "Vieni da noi"
|
|
117
|
+
description1 "vieni da noi"
|
|
118
|
+
description2 "arivieni da noi"
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
adgroup.ads.length.should == 1
|
|
123
|
+
adgroup.ads.first.id.should == 10
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
describe "criterion management" do
|
|
129
|
+
|
|
130
|
+
it "should add a CriterionKeyword with method 'keyword' + block" do
|
|
131
|
+
adgroup = AdGroup.new(@campaign) do
|
|
132
|
+
name "adgroup"
|
|
133
|
+
keyword do
|
|
134
|
+
text "pippo"
|
|
135
|
+
match "BROAD"
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
adgroup.should have(1).criterions
|
|
139
|
+
criterion = adgroup.criterions.first.criterion
|
|
140
|
+
criterion.text.should == "pippo"
|
|
141
|
+
criterion.id.should == 10
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it "should add a CriterionKeyword with method 'keyword' + parameters" do
|
|
145
|
+
adgroup = AdGroup.new(@campaign) do
|
|
146
|
+
name "adgroup"
|
|
147
|
+
keyword "pippo", "BROAD"
|
|
148
|
+
end
|
|
149
|
+
adgroup.should have(1).criterions
|
|
150
|
+
criterion = adgroup.criterions.first.criterion
|
|
151
|
+
criterion.id.should == 10
|
|
152
|
+
criterion.text.should == "pippo"
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it "should add a CriterionPlacement with method 'placement' + block" do
|
|
156
|
+
adgroup = AdGroup.new(@campaign) do
|
|
157
|
+
name "adgroup"
|
|
158
|
+
placement do
|
|
159
|
+
url "pippo"
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
adgroup.criterions.length.should == 1
|
|
163
|
+
criterion = adgroup.criterions.first.criterion
|
|
164
|
+
criterion.id.should == 10
|
|
165
|
+
criterion.url.should == "pippo"
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it "should add a CriterionPlacement with method 'placement' + parameters" do
|
|
169
|
+
adgroup = AdGroup.new(@campaign) do
|
|
170
|
+
name "adgroup"
|
|
171
|
+
placement "url"
|
|
172
|
+
end
|
|
173
|
+
adgroup.criterions.length.should == 1
|
|
174
|
+
criterion = adgroup.criterions.first.criterion
|
|
175
|
+
criterion.id.should == 10
|
|
176
|
+
criterion.url.should == "url"
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
describe "ad_param management" do
|
|
181
|
+
|
|
182
|
+
it "should create a AdParam with method 'ad_param' + block" do
|
|
183
|
+
criterion = @criterion # it is necessary to pass to following block
|
|
184
|
+
adgroup = AdGroup.new(@campaign) do
|
|
185
|
+
name "adgroup"
|
|
186
|
+
ad_param(criterion) do
|
|
187
|
+
index 1
|
|
188
|
+
text "$99.99"
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
adgroup.ad_params.length.should == 1
|
|
193
|
+
param = adgroup.ad_params.first
|
|
194
|
+
param.index.should == 1
|
|
195
|
+
param.text.should == "$99.99"
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it "should create a AdParam with method 'ad_param' + param" do
|
|
199
|
+
criterion = @criterion # it is necessary to pass to following block
|
|
200
|
+
adgroup = AdGroup.new(@campaign) do
|
|
201
|
+
name "adgroup"
|
|
202
|
+
ad_param criterion, 1, "$99.99"
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
adgroup.ad_params.length.should == 1
|
|
206
|
+
param = adgroup.ad_params.first
|
|
207
|
+
param.index.should == 1
|
|
208
|
+
param.text.should == "$99.99"
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
describe AdGroupAdOperation do
|
|
29
|
+
include Sem4rSpecHelper
|
|
30
|
+
|
|
31
|
+
before(:each) do
|
|
32
|
+
@adgroup = mock("adgroup").as_null_object
|
|
33
|
+
@ad_operation = AdGroupAdOperation.new
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should raise missing operand" do
|
|
37
|
+
@ad_operation.operator "ADD"
|
|
38
|
+
@ad_operation.operator.should == "ADD"
|
|
39
|
+
lambda {
|
|
40
|
+
@ad_operation.to_xml(nil)
|
|
41
|
+
}.should raise_error(Sem4rError, "Missing Operand")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should produce xml (input for google)" do
|
|
45
|
+
@adgroup.should_receive(:id).and_return(3060284754)
|
|
46
|
+
text_ad = AdGroupTextAd.new(@adgroup)
|
|
47
|
+
text_ad.headline = "Cruise to Mars Sector 1"
|
|
48
|
+
text_ad.description1 = "Visit the Red Planet in style."
|
|
49
|
+
text_ad.description2 = "Low-gravity fun for everyone!"
|
|
50
|
+
text_ad.display_url = "www.example.com"
|
|
51
|
+
text_ad.url = "http://www.example.com"
|
|
52
|
+
@ad_operation.add text_ad
|
|
53
|
+
|
|
54
|
+
expected_xml = read_model("//operations", "services", "bulk_mutate_job", "mutate-req.xml")
|
|
55
|
+
@ad_operation.to_xml('operations').should xml_equivalent(expected_xml)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should produce xml (input for google) with two operation" do
|
|
59
|
+
pending "test"
|
|
60
|
+
@adgroup = stub_adgroup
|
|
61
|
+
|
|
62
|
+
text_ad_1 = AdGroupTextAd.new(@adgroup) do
|
|
63
|
+
headline "sem4r"
|
|
64
|
+
description1 "adwords ruby client library"
|
|
65
|
+
description2 "adwords ruby client library"
|
|
66
|
+
display_url "www.sem4r.com"
|
|
67
|
+
url "http://www.Sem4R.com"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
text_ad_2 = AdGroupTextAd.new(@adgroup) do
|
|
71
|
+
headline "sem4r"
|
|
72
|
+
description1 "adwords ruby client library"
|
|
73
|
+
description2 "adwodrs api made simple!"
|
|
74
|
+
display_url "www.sem4r.com"
|
|
75
|
+
url "http://www.Sem4R.com"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
ad_operation_1 = AdGroupAdOperation.new.add text_ad_1
|
|
79
|
+
ad_operation_2 = AdGroupAdOperation.new.add text_ad_2
|
|
80
|
+
|
|
81
|
+
puts ad_operation_1.to_xml("operations")
|
|
82
|
+
puts ad_operation_2.to_xml("operations")
|
|
83
|
+
|
|
84
|
+
# expected_xml = read_model("//operations", "services", "bulk_mutate_job", "mutate-req.xml")
|
|
85
|
+
# @ad_operation.to_xml('operations').should xml_equivalent(expected_xml)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
26
|
+
|
|
27
|
+
describe AdGroupAdService do
|
|
28
|
+
include Sem4rSpecHelper
|
|
29
|
+
|
|
30
|
+
before do
|
|
31
|
+
@credentials = stub_credentials
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should define 'all'" do
|
|
35
|
+
response_xml = read_xml_file("services", "ad_group_ad", "get_mobile_ad-res.xml")
|
|
36
|
+
connector = mock("connector")
|
|
37
|
+
connector.should_receive(:send).and_return(response_xml)
|
|
38
|
+
service = AdGroupAdService.new(connector)
|
|
39
|
+
soap_message = service.all( @credentials, "ad_group_id" )
|
|
40
|
+
els = REXML::XPath.match( soap_message.response, "//getResponse")
|
|
41
|
+
els.should_not be_empty
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should define 'mutate'" do
|
|
45
|
+
@credentials.should_receive(:mutable?).and_return(true)
|
|
46
|
+
response_xml = read_xml_file("services", "ad_group_ad", "mutate_add_mobile_ad-res.xml")
|
|
47
|
+
connector = mock("connector")
|
|
48
|
+
connector.should_receive(:send).and_return(response_xml)
|
|
49
|
+
service = AdGroupAdService.new(connector)
|
|
50
|
+
soap_message = service.mutate( @credentials, "xml" )
|
|
51
|
+
els = REXML::XPath.match( soap_message.response, "//mutateResponse")
|
|
52
|
+
els.should_not be_empty
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
26
|
+
|
|
27
|
+
describe AdGroupAd do
|
|
28
|
+
|
|
29
|
+
include Sem4rSpecHelper
|
|
30
|
+
|
|
31
|
+
before(:each) do
|
|
32
|
+
services = stub("services")
|
|
33
|
+
stub_service_ad_group_criterion(services)
|
|
34
|
+
stub_service_ad_group_ad(services)
|
|
35
|
+
@adgroup = stub_adgroup(services, 3060217927)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe AdGroupAd do
|
|
39
|
+
|
|
40
|
+
it "should parse xml (output from google)" do
|
|
41
|
+
el = read_model("//ad", "services", "ad_group_ad", "get_text_ad-res.xml")
|
|
42
|
+
ad = AdGroupAd.from_element(@adgroup, el)
|
|
43
|
+
# ad.id.should == 218770
|
|
44
|
+
ad.url.should == "http://www.pluto.com"
|
|
45
|
+
ad.headline.should == "Vieni da noi"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe AdGroupTextAd do
|
|
51
|
+
|
|
52
|
+
it "should accepts accessor" do
|
|
53
|
+
text_ad = AdGroupTextAd.new(@adgroup)
|
|
54
|
+
text_ad.headline = "headline"
|
|
55
|
+
text_ad.description1 = "description1"
|
|
56
|
+
text_ad.description2 = "description2"
|
|
57
|
+
|
|
58
|
+
text_ad.headline.should == "headline"
|
|
59
|
+
text_ad.description1.should == "description1"
|
|
60
|
+
text_ad.description2.should == "description2"
|
|
61
|
+
text_ad.status.should == "ENABLED"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should accepts a block (instance_eval)" do
|
|
65
|
+
text_ad = AdGroupTextAd.new(@adgroup) do
|
|
66
|
+
headline "headline"
|
|
67
|
+
description1 "description1"
|
|
68
|
+
description2 "description2"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
text_ad.id.should == 10
|
|
72
|
+
text_ad.headline.should == "headline"
|
|
73
|
+
text_ad.description1.should == "description1"
|
|
74
|
+
text_ad.description2.should == "description2"
|
|
75
|
+
text_ad.status.should == "ENABLED"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "should accepts a block (call)" do
|
|
79
|
+
text_ad = AdGroupTextAd.new(@adgroup) do |a|
|
|
80
|
+
a.headline "headline"
|
|
81
|
+
a.description1 "description1"
|
|
82
|
+
a.description2 "description2"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
text_ad.id.should == 10
|
|
86
|
+
text_ad.headline.should == "headline"
|
|
87
|
+
text_ad.description1.should == "description1"
|
|
88
|
+
text_ad.description2.should == "description2"
|
|
89
|
+
text_ad.status.should == "ENABLED"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should change status" do
|
|
93
|
+
text_ad = AdGroupTextAd.new(@adgroup) do
|
|
94
|
+
headline "headline"
|
|
95
|
+
description1 "description1"
|
|
96
|
+
description2 "description2"
|
|
97
|
+
end
|
|
98
|
+
text_ad.status.should == "ENABLED"
|
|
99
|
+
text_ad.status "PAUSED"
|
|
100
|
+
text_ad.status.should == "PAUSED"
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "should produce xml (input for google)" do
|
|
104
|
+
text_ad = AdGroupTextAd.new(@adgroup) do
|
|
105
|
+
headline "Vieni da noi"
|
|
106
|
+
description1 "vieni da noi"
|
|
107
|
+
description2 "arivieni da noi"
|
|
108
|
+
url "http://www.pluto.com"
|
|
109
|
+
display_url "www.Pluto.com"
|
|
110
|
+
end
|
|
111
|
+
expected_xml = read_model("//operand", "services", "ad_group_ad", "mutate_add_text_ad-req.xml")
|
|
112
|
+
text_ad.to_xml("operand").should xml_equivalent(expected_xml)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
describe AdGroupMobileAd do
|
|
118
|
+
|
|
119
|
+
it "should accepts a block (instance_eval)" do
|
|
120
|
+
mobile_ad = AdGroupMobileAd.new(@adgroup) do
|
|
121
|
+
markup "HTML"
|
|
122
|
+
carrier 'T-Mobile@US'
|
|
123
|
+
carrier 'Verizon@US'
|
|
124
|
+
image do
|
|
125
|
+
name 'image_192x53.jpg'
|
|
126
|
+
data MOBILE_IMAGE_DATA
|
|
127
|
+
dimension 'SHRUNKEN: 192x53'
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
mobile_ad.status.should == "ENABLED"
|
|
131
|
+
mobile_ad.markups.should include(AdGroupMobileAd::HTML)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "should accepts a block (call)" do
|
|
135
|
+
mobile_ad = AdGroupMobileAd.new(@adgroup) do |a|
|
|
136
|
+
a.markup "HTML"
|
|
137
|
+
a.carrier 'T-Mobile@US'
|
|
138
|
+
a.carrier 'Verizon@US'
|
|
139
|
+
a.image do
|
|
140
|
+
name 'image_192x53.jpg'
|
|
141
|
+
data MOBILE_IMAGE_DATA
|
|
142
|
+
dimension 'SHRUNKEN: 192x53'
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
mobile_ad.status.should == "ENABLED"
|
|
146
|
+
mobile_ad.markups.should include(AdGroupMobileAd::HTML)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it "should produce xml (input for google)" do
|
|
150
|
+
mobile_ad = AdGroupMobileAd.new(@adgroup) do
|
|
151
|
+
headline "sem4r"
|
|
152
|
+
description "simply adwords"
|
|
153
|
+
# markup "XHTML"
|
|
154
|
+
carrier "Vodafone@IT"
|
|
155
|
+
# carrier 'ALLCARRIERS'
|
|
156
|
+
business_name "sem4r"
|
|
157
|
+
country_code "IT"
|
|
158
|
+
phone_number "0612345"
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
expected_xml = read_model("//operand", "services", "ad_group_ad", "mutate_add_mobile_ad-req.xml")
|
|
162
|
+
mobile_ad.to_xml("operand").should xml_equivalent(expected_xml)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
it "should parse xml (output from google)" do
|
|
166
|
+
el = read_model("//ad", "services", "ad_group_ad", "get_mobile_ad-res.xml")
|
|
167
|
+
ad = AdGroupAd.from_element(@adgroup, el)
|
|
168
|
+
ad.headline.should == "sem4r"
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
26
|
+
|
|
27
|
+
describe AdGroupCriterionBids do
|
|
28
|
+
include Sem4rSpecHelper
|
|
29
|
+
|
|
30
|
+
it "should parse xml (produced by google)" do
|
|
31
|
+
el = read_model("//bids", "services", "ad_group_criterion", "get-res.xml")
|
|
32
|
+
bids = AdGroupCriterionBids.from_element(el)
|
|
33
|
+
bids.should be_instance_of ManualCPCAdGroupCriterionBids
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe ManualCPCAdGroupCriterionBids do
|
|
37
|
+
|
|
38
|
+
it "should accept accessor" do
|
|
39
|
+
bids = ManualCPCAdGroupCriterionBids.new
|
|
40
|
+
bids.max_cpc 10000000
|
|
41
|
+
bids.max_cpc.should == 10000000
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should build xml (input for google)" do
|
|
45
|
+
bids = ManualCPCAdGroupCriterionBids.new
|
|
46
|
+
bids.max_cpc 10000000
|
|
47
|
+
expected_xml = read_model("//bids", "services", "ad_group_criterion", "mutate_add_criterion_keyword-req.xml")
|
|
48
|
+
bids.to_xml.should xml_equivalent( expected_xml )
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should parse xml (produced by google)" do
|
|
52
|
+
el = read_model("//bids", "services", "ad_group_criterion", "get-res.xml")
|
|
53
|
+
bids = ManualCPCAdGroupCriterionBids.from_element(el)
|
|
54
|
+
bids.bid_source.should == "ADGROUP"
|
|
55
|
+
bids.max_cpc.should == 10000000
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
26
|
+
|
|
27
|
+
describe AdGroupCriterionService do
|
|
28
|
+
include Sem4rSpecHelper
|
|
29
|
+
|
|
30
|
+
before do
|
|
31
|
+
@credentials = stub_credentials
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should define 'all'" do
|
|
35
|
+
response_xml = read_xml_file("services", "ad_group_criterion", "get-res.xml")
|
|
36
|
+
connector = mock("connector")
|
|
37
|
+
connector.should_receive(:send).and_return(response_xml)
|
|
38
|
+
service = AdGroupCriterionService.new(connector)
|
|
39
|
+
soap_message = service.all( @credentials, "ad_group_id" )
|
|
40
|
+
els = REXML::XPath.match( soap_message.response, "//getResponse")
|
|
41
|
+
els.should_not be_empty
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should define 'mutate'" do
|
|
45
|
+
@credentials.should_receive(:mutable?).and_return(true)
|
|
46
|
+
response_xml = read_xml_file("services", "ad_group_criterion", "mutate_add_criterion_keyword-res.xml")
|
|
47
|
+
connector = mock("connector")
|
|
48
|
+
connector.should_receive(:send).and_return(response_xml)
|
|
49
|
+
service = AdGroupCriterionService.new(connector)
|
|
50
|
+
soap_message = service.mutate( @credentials, "xml" )
|
|
51
|
+
els = REXML::XPath.match( soap_message.response, "//mutateResponse")
|
|
52
|
+
els.should_not be_empty
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|