adzerk 0.1.4 → 0.2
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/lib/adzerk.rb +15 -0
- data/lib/adzerk/advertiser.rb +9 -0
- data/lib/adzerk/api_endpoint.rb +41 -0
- data/lib/adzerk/channel_site_map.rb +53 -0
- data/lib/adzerk/client.rb +80 -0
- data/lib/adzerk/creative.rb +17 -0
- data/lib/adzerk/creative_map.rb +38 -0
- data/lib/adzerk/flight.rb +12 -0
- data/lib/adzerk/invitation.rb +23 -0
- data/lib/adzerk/publisher.rb +17 -0
- data/lib/adzerk/reporting.rb +21 -0
- data/lib/adzerk/util.rb +37 -0
- data/lib/adzerk/version.rb +3 -0
- data/test/advertiser_api_spec.rb +57 -82
- data/test/campaign_api_spec.rb +150 -271
- data/test/channel_api_spec.rb +72 -79
- data/test/channel_site_map_api_spec.rb +43 -94
- data/test/creative_api_spec.rb +82 -251
- data/test/creative_map_api_spec.rb +291 -375
- data/test/flight_api_spec.rb +165 -493
- data/test/invitation_api_spec.rb +18 -41
- data/test/login_api_spec.rb +24 -49
- data/test/priority_api_spec.rb +53 -83
- data/test/publisher_api_spec.rb +71 -142
- data/test/rakefile.rb +7 -7
- data/test/report_api_spec.rb +18 -24
- data/test/security_api_spec.rb +21 -0
- data/test/site_api_spec.rb +37 -51
- data/test/spec_helper.rb +4 -17
- data/test/zone_api_spec.rb +38 -64
- metadata +61 -23
- data/lib/Adzerk.rb +0 -55
- data/lib/adzerk/Advertiser.rb +0 -39
- data/lib/adzerk/Campaign.rb +0 -33
- data/lib/adzerk/Channel.rb +0 -33
- data/lib/adzerk/ChannelSiteMap.rb +0 -44
- data/lib/adzerk/Creative.rb +0 -43
- data/lib/adzerk/CreativeMap.rb +0 -33
- data/lib/adzerk/Flight.rb +0 -44
- data/lib/adzerk/Invitation.rb +0 -17
- data/lib/adzerk/Login.rb +0 -28
- data/lib/adzerk/Priority.rb +0 -34
- data/lib/adzerk/Publisher.rb +0 -47
- data/lib/adzerk/Reporting.rb +0 -16
- data/lib/adzerk/Site.rb +0 -35
- data/lib/adzerk/Zone.rb +0 -35
- data/test/channel_api_security_spec.rb +0 -51
- data/test/csv_export_spec.rb +0 -89
- data/test/delivery-test.rb +0 -132
- data/test/test.rb +0 -43
- data/test/test2.rb +0 -175
data/test/flight_api_spec.rb
CHANGED
@@ -1,55 +1,49 @@
|
|
1
|
-
require '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "Flight API" do
|
4
|
-
|
5
|
-
|
6
|
-
@@flight = $adzerk::Flight.new
|
7
|
-
@@advertiser = $adzerk::Advertiser.new
|
8
|
-
@@channel = $adzerk::Channel.new
|
9
|
-
@@campaign = $adzerk::Campaign.new
|
10
|
-
@@priority = $adzerk::Priority.new
|
11
|
-
|
4
|
+
|
5
|
+
|
12
6
|
before(:all) do
|
13
7
|
new_advertiser = {
|
14
8
|
'Title' => "Test"
|
15
9
|
}
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
10
|
+
client = Adzerk::Client.new(API_KEY)
|
11
|
+
@flights= client.flights
|
12
|
+
@advertisers = client.advertisers
|
13
|
+
@channels = client.channels
|
14
|
+
@campaigns = client.campaigns
|
15
|
+
@priorities = client.priorities
|
16
|
+
|
17
|
+
advertiser = @advertisers.create(:title => "test")
|
18
|
+
$advertiserId = advertiser[:id].to_s
|
19
|
+
|
20
|
+
channel = @channels.create(:title => 'Test Channel ' + rand(1000000).to_s,
|
21
|
+
:commission => '0.0',
|
22
|
+
:engine => 'CPM',
|
23
|
+
:keywords => 'test',
|
24
|
+
'CPM' => '10.00',
|
25
|
+
:ad_types => [1,2,3,4])
|
26
|
+
$channel_id = channel[:id].to_s
|
27
|
+
|
28
|
+
priority = @priorities.create(:name => "High Priority Test",
|
29
|
+
:channel_id => $channel_id,
|
30
|
+
:weight => 1,
|
31
|
+
:is_deleted => false)
|
32
|
+
$priority_id = priority[:id].to_s
|
33
|
+
|
34
|
+
campaign = @campaigns.
|
35
|
+
create(:name => 'Test campaign ' + rand(1000000).to_s,
|
36
|
+
:start_date => "1/1/2011",
|
37
|
+
:end_date => "12/31/2011",
|
38
|
+
:is_active => false,
|
39
|
+
:price => '10.00',
|
40
|
+
:advertiser_id => $advertiserId,
|
41
|
+
:flights => [],
|
42
|
+
:is_deleted => false)
|
43
|
+
$campaign_id = campaign[:id]
|
38
44
|
|
39
|
-
new_campaign = {
|
40
|
-
'Name' => 'Test campaign ' + rand(1000000).to_s,
|
41
|
-
'StartDate' => "1/1/2011",
|
42
|
-
'EndDate' => "12/31/2011",
|
43
|
-
'IsActive' => true,
|
44
|
-
'Price' => '10.00',
|
45
|
-
'AdvertiserId' => $advertiserId,
|
46
|
-
'Flights' => [],
|
47
|
-
'IsDeleted' => false
|
48
|
-
}
|
49
|
-
response = @@campaign.create(new_campaign)
|
50
|
-
$campaignId = JSON.parse(response.body)["Id"]
|
51
45
|
end
|
52
|
-
|
46
|
+
|
53
47
|
it "should create a flight" do
|
54
48
|
$flight_Name = 'Test flight ' + rand(1000000).to_s
|
55
49
|
$flight_StartDate = "1/1/2011"
|
@@ -63,10 +57,91 @@ describe "Flight API" do
|
|
63
57
|
$flight_Keywords = "test, test2"
|
64
58
|
$flight_UserAgentKeywords = nil
|
65
59
|
$flight_WeightOverride = nil
|
66
|
-
$flight_CampaignId = $
|
60
|
+
$flight_CampaignId = $campaign_id
|
67
61
|
$flight_IsActive = true
|
68
62
|
$flight_IsDeleted = false
|
69
|
-
|
63
|
+
|
64
|
+
new_flight = {
|
65
|
+
:no_end_date => false,
|
66
|
+
:priority_id => $priority_id,
|
67
|
+
:name => $flight_Name,
|
68
|
+
:start_date => $flight_StartDate,
|
69
|
+
:end_date => $flight_EndDate,
|
70
|
+
:no_end_date => $flight_NoEndDate,
|
71
|
+
:price => $flight_Price,
|
72
|
+
:option_type => $flight_OptionType,
|
73
|
+
:impressions => $flight_Impressions,
|
74
|
+
:is_unlimited => $flight_IsUnlimited,
|
75
|
+
:is_full_speed => $flight_IsFullSpeed,
|
76
|
+
:keywords => $flight_Keywords,
|
77
|
+
:user_agent_keywords => $flight_UserAgentKeywords,
|
78
|
+
:weight_override => $flight_WeightOverride,
|
79
|
+
:campaign_id => $flight_CampaignId,
|
80
|
+
:is_active => $flight_IsActive,
|
81
|
+
:is_deleted => $flight_IsDeleted
|
82
|
+
}
|
83
|
+
flight = @flights.create(new_flight)
|
84
|
+
$flight_id = flight[:id].to_s
|
85
|
+
flight[:no_end_date].should eq(false)
|
86
|
+
flight[:priority_id].should eq($priority_id.to_i)
|
87
|
+
flight[:name].should eq($flight_Name)
|
88
|
+
# JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
|
89
|
+
# JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
|
90
|
+
flight[:price].should eq(15.0)
|
91
|
+
flight[:option_type].should eq($flight_OptionType)
|
92
|
+
flight[:impressions].should eq($flight_Impressions)
|
93
|
+
flight[:is_unlimited].should eq($flight_IsUnlimited)
|
94
|
+
flight[:is_full_speed].should eq($flight_IsFullSpeed)
|
95
|
+
flight[:keywords].should eq($flight_Keywords)
|
96
|
+
flight[:user_agent_keywords].should eq($flight_UserAgentKeywords)
|
97
|
+
flight[:weight_override].should eq($flight_WeightOverride)
|
98
|
+
flight[:campaign_id].should eq($flight_CampaignId)
|
99
|
+
flight[:is_active].should eq($flight_IsActive)
|
100
|
+
flight[:is_deleted].should eq($flight_IsDeleted)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should list a specific flight" do
|
104
|
+
flight = @flights.get($flight_id)
|
105
|
+
flight[:priority_id].should eq($priority_id.to_i)
|
106
|
+
flight[:name].should eq($flight_Name)
|
107
|
+
flight[:price].should eq(15.0)
|
108
|
+
flight[:option_type].should eq($flight_OptionType)
|
109
|
+
flight[:impressions].should eq($flight_Impressions)
|
110
|
+
flight[:is_unlimited].should eq($flight_IsUnlimited)
|
111
|
+
flight[:is_full_speed].should eq($flight_IsFullSpeed)
|
112
|
+
flight[:keywords].should eq($flight_Keywords)
|
113
|
+
flight[:user_agent_keywords].should eq($flight_UserAgentKeywords)
|
114
|
+
flight[:weight_override].should eq($flight_WeightOverride)
|
115
|
+
flight[:campaign_id].should eq($flight_CampaignId)
|
116
|
+
flight[:is_active].should eq($flight_IsActive)
|
117
|
+
flight[:is_deleted].should eq($flight_IsDeleted)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should update a flight" do
|
121
|
+
flight = @flights.update(:id => $flight_id,
|
122
|
+
:campaign_id => $flight_CampaignId,
|
123
|
+
:name => "New Flight Name",
|
124
|
+
:priority_id => $priority_id)
|
125
|
+
flight[:name].should eq("New Flight Name")
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should list all flights" do
|
129
|
+
flights = @flights.list
|
130
|
+
flights.length.should > 0
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should delete a new flight" do
|
134
|
+
response = @flights.delete($flight_id)
|
135
|
+
response.body.should == '"Successfully deleted"'
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should create a flight with geotargeting" do
|
139
|
+
geo = [{
|
140
|
+
'CountryCode' => 'US',
|
141
|
+
'Region' => 'NC',
|
142
|
+
'MetroCode' => '560'
|
143
|
+
}]
|
144
|
+
|
70
145
|
new_flight = {
|
71
146
|
'NoEndDate' => false,
|
72
147
|
'PriorityId' => $priority_id,
|
@@ -84,456 +159,53 @@ describe "Flight API" do
|
|
84
159
|
'WeightOverride' => $flight_WeightOverride,
|
85
160
|
'CampaignId' => $flight_CampaignId,
|
86
161
|
'IsActive' => $flight_IsActive,
|
87
|
-
'IsDeleted' => $flight_IsDeleted
|
162
|
+
'IsDeleted' => $flight_IsDeleted,
|
163
|
+
'GeoTargeting' => geo
|
88
164
|
}
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
JSON.parse(response.body)["Name"].should == $flight_Name
|
165
|
+
flight = @flights.create(new_flight)
|
166
|
+
$flight_id = flight[:id].to_s
|
167
|
+
flight[:no_end_date].should eq(false)
|
168
|
+
flight[:priority_id].should eq($priority_id.to_i)
|
169
|
+
flight[:name].should eq($flight_Name)
|
95
170
|
# JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
|
96
171
|
# JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
response = @@flight.get($flight_id)
|
113
|
-
response.body.should == '{"Id":' + $flight_id + ',"StartDate":"\\/Date(1293840000000+0000)\\/","EndDate":"\\/Date(1325289600000+0000)\\/","Price":15.00,"OptionType":1,"Impressions":10000,"IsUnlimited":false,"IsNoDuplicates":false,"IsFullSpeed":false,"Keywords":"test, test2","Name":"' + $flight_Name + '","CampaignId":' + $campaignId.to_s + ',"PriorityId":' + $priority_id + ',"IsDeleted":false,"IsActive":true,"GeoTargeting":[],"FreqCap":0,"FreqCapDuration":0,"FreqCapType":0,"CreativeMaps":[]}'
|
114
|
-
end
|
115
|
-
|
116
|
-
#it "should update a flight" do
|
117
|
-
#$u_flight_Name = 'Test Test flight ' + rand(1000000).to_s
|
118
|
-
#$u_flight_StartDate = "1/1/2011"
|
119
|
-
#$u_flight_EndDate = "12/31/2011"
|
120
|
-
#$u_flight_NoEndDate = false
|
121
|
-
#$u_flight_Price = '16.00'
|
122
|
-
#$u_flight_OptionType = 1
|
123
|
-
#$u_flight_Impressions = 12000
|
124
|
-
#$u_flight_IsUnlimited = false
|
125
|
-
#$u_flight_IsFullSpeed = false
|
126
|
-
#$u_flight_Keywords = "test, test2"
|
127
|
-
#$u_flight_UserAgentKeywords = nil
|
128
|
-
#$u_flight_WeightOverride = nil
|
129
|
-
#$u_flight_CampaignId = $campaignId
|
130
|
-
#$u_flight_IsActive = true
|
131
|
-
#$u_flight_IsDeleted = false
|
132
|
-
|
133
|
-
#new_flight = {
|
134
|
-
#'Id' => $flight_id,
|
135
|
-
#'NoEndDate' => false,
|
136
|
-
#'PriorityId' => $priority_id,
|
137
|
-
#'Name' => $u_flight_Name,
|
138
|
-
#'StartDate' => $u_flight_StartDate,
|
139
|
-
#'EndDate' => $u_flight_EndDate,
|
140
|
-
#'NoEndDate' => $u_flight_NoEndDate,
|
141
|
-
#'Price' => $u_flight_Price,
|
142
|
-
#'OptionType' => $u_flight_OptionType,
|
143
|
-
#'Impressions' => $u_flight_Impressions,
|
144
|
-
#'IsUnlimited' => $u_flight_IsUnlimited,
|
145
|
-
#'IsFullSpeed' => $u_flight_IsFullSpeed,
|
146
|
-
#'Keywords' => $u_flight_Keywords,
|
147
|
-
#'UserAgentKeywords' => $u_flight_UserAgentKeywords,
|
148
|
-
#'WeightOverride' => $u_flight_WeightOverride,
|
149
|
-
#'CampaignId' => $u_flight_CampaignId,
|
150
|
-
#'IsActive' => $u_flight_IsActive,
|
151
|
-
#'IsDeleted' => $u_flight_IsDeleted
|
152
|
-
#}
|
153
|
-
#response = @@flight.update(new_flight)
|
154
|
-
#$flight_id = JSON.parse(response.body)["Id"].to_s
|
155
|
-
#JSON.parse(response.body)["NoEndDate"].should == false
|
156
|
-
#JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
|
157
|
-
#JSON.parse(response.body)["Name"].should == $u_flight_Name
|
158
|
-
##JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
|
159
|
-
##JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
|
160
|
-
#JSON.parse(response.body)["NoEndDate"].should == $u_flight_NoEndDate
|
161
|
-
#JSON.parse(response.body)["Price"].should == 16.0
|
162
|
-
#JSON.parse(response.body)["OptionType"].should == $u_flight_OptionType
|
163
|
-
#JSON.parse(response.body)["Impressions"].should == $u_flight_Impressions
|
164
|
-
#JSON.parse(response.body)["IsUnlimited"].should == $u_flight_IsUnlimited
|
165
|
-
#JSON.parse(response.body)["IsFullSpeed"].should == $u_flight_IsFullSpeed
|
166
|
-
#JSON.parse(response.body)["Keywords"].should == $u_flight_Keywords
|
167
|
-
#JSON.parse(response.body)["UserAgentKeywords"].should == $u_flight_UserAgentKeywords
|
168
|
-
#JSON.parse(response.body)["WeightOverride"].should == $u_flight_WeightOverride
|
169
|
-
#JSON.parse(response.body)["CampaignId"].should == $u_flight_CampaignId
|
170
|
-
#JSON.parse(response.body)["IsActive"].should == $u_flight_IsActive
|
171
|
-
#JSON.parse(response.body)["IsDeleted"].should == $u_flight_IsDeleted
|
172
|
-
#end
|
173
|
-
|
174
|
-
it "should list all flights" do
|
175
|
-
result = @@flight.list()
|
176
|
-
result.length.should > 0
|
177
|
-
## Can't test this right now because of paging issues
|
178
|
-
# result["Items"].last["Id"].to_s.should == $flight_id
|
179
|
-
# result["Items"].last["NoEndDate"].should == false
|
180
|
-
# result["Items"].last["PriorityId"].should == $priorityId
|
181
|
-
# result["Items"].last["Name"].should == $flight_Name
|
182
|
-
# result["Items"].last["StartDate"].should == "/Date(1293858000000-0500)/"
|
183
|
-
# result["Items"].last["EndDate"].should == "/Date(1325307600000-0500)/"
|
184
|
-
# result["Items"].last["NoEndDate"].should == $flight_NoEndDate
|
185
|
-
# result["Items"].last["Price"].should == 15.0
|
186
|
-
# result["Items"].last["OptionType"].should == $flight_OptionType
|
187
|
-
# result["Items"].last["Impressions"].should == $flight_Impressions
|
188
|
-
# result["Items"].last["IsUnlimited"].should == $flight_IsUnlimited
|
189
|
-
# result["Items"].last["IsFullSpeed"].should == $flight_IsFullSpeed
|
190
|
-
# result["Items"].last["Keywords"].should == $flight_Keywords
|
191
|
-
# result["Items"].last["UserAgentKeywords"].should == $flight_UserAgentKeywords
|
192
|
-
# result["Items"].last["WeightOverride"].should == $flight_WeightOverride
|
193
|
-
# result["Items"].last["CampaignId"].should == $flight_CampaignId
|
194
|
-
# result["Items"].last["IsActive"].should == $flight_IsActive
|
195
|
-
# result["Items"].last["IsDeleted"].should == $flight_IsDeleted
|
172
|
+
flight[:price].should eq(15.0)
|
173
|
+
flight[:option_type].should eq($flight_OptionType)
|
174
|
+
flight[:impressions].should eq($flight_Impressions)
|
175
|
+
flight[:is_unlimited].should eq($flight_IsUnlimited)
|
176
|
+
flight[:is_full_speed].should eq($flight_IsFullSpeed)
|
177
|
+
flight[:keywords].should eq($flight_Keywords)
|
178
|
+
flight[:user_agent_keywords].should eq($flight_UserAgentKeywords)
|
179
|
+
flight[:weight_override].should eq($flight_WeightOverride)
|
180
|
+
flight[:campaign_id].should eq($flight_CampaignId)
|
181
|
+
flight[:is_active].should eq($flight_IsActive)
|
182
|
+
flight[:is_deleted].should eq($flight_IsDeleted)
|
183
|
+
geotargeting = flight[:geo_targeting].first
|
184
|
+
geotargeting[:country_code].should eq("US")
|
185
|
+
geotargeting[:region].should eq("NC")
|
186
|
+
geotargeting[:metro_code].should eq(560)
|
196
187
|
end
|
197
|
-
|
198
|
-
#it "should not get if campaignId or priorityId is forbidden" do
|
199
|
-
#response = @@flight.get($flight_id)
|
200
|
-
#true.should == !response.body.scan(/Object/).nil?
|
201
|
-
#end
|
202
|
-
|
203
|
-
#it "should delete a new flight" do
|
204
|
-
#response = @@flight.delete($flight_id)
|
205
|
-
#response.body.should == 'OK'
|
206
|
-
#end
|
207
|
-
|
208
|
-
#it "should not get individual deleted flight" do
|
209
|
-
#response = @@flight.get($flight_id)
|
210
|
-
#response.body.should == '{"Id":0,"PriorityId":0,"IsDeleted":false,"IsActive":false}'
|
211
|
-
#end
|
212
|
-
|
213
|
-
#it "should not create/update if campaignId is forbidden" do
|
214
|
-
#new_flight = {
|
215
|
-
#'NoEndDate' => false,
|
216
|
-
#'PriorityId' => $priority_id,
|
217
|
-
#'Name' => $flight_Name,
|
218
|
-
#'StartDate' => $flight_StartDate,
|
219
|
-
#'EndDate' => $flight_EndDate,
|
220
|
-
#'NoEndDate' => $flight_NoEndDate,
|
221
|
-
#'Price' => $flight_Price,
|
222
|
-
#'OptionType' => $flight_OptionType,
|
223
|
-
#'Impressions' => $flight_Impressions,
|
224
|
-
#'IsUnlimited' => $flight_IsUnlimited,
|
225
|
-
#'IsFullSpeed' => $flight_IsFullSpeed,
|
226
|
-
#'Keywords' => $flight_Keywords,
|
227
|
-
#'UserAgentKeywords' => $flight_UserAgentKeywords,
|
228
|
-
#'WeightOverride' => $flight_WeightOverride,
|
229
|
-
#'CampaignId' => '123',
|
230
|
-
#'IsActive' => $flight_IsActive,
|
231
|
-
#'IsDeleted' => $flight_IsDeleted
|
232
|
-
#}
|
233
|
-
#response = @@flight.create(new_flight)
|
234
|
-
#true.should == !response.body.scan(/Object/).nil?
|
235
|
-
|
236
|
-
#new_flight = {
|
237
|
-
#'Id' => $flight_id,
|
238
|
-
#'NoEndDate' => false,
|
239
|
-
#'PriorityId' => $priority_id,
|
240
|
-
#'Name' => $flight_Name,
|
241
|
-
#'StartDate' => $flight_StartDate,
|
242
|
-
#'EndDate' => $flight_EndDate,
|
243
|
-
#'NoEndDate' => $flight_NoEndDate,
|
244
|
-
#'Price' => $flight_Price,
|
245
|
-
#'OptionType' => $flight_OptionType,
|
246
|
-
#'Impressions' => $flight_Impressions,
|
247
|
-
#'IsUnlimited' => $flight_IsUnlimited,
|
248
|
-
#'IsFullSpeed' => $flight_IsFullSpeed,
|
249
|
-
#'Keywords' => $flight_Keywords,
|
250
|
-
#'UserAgentKeywords' => $flight_UserAgentKeywords,
|
251
|
-
#'WeightOverride' => $flight_WeightOverride,
|
252
|
-
#'CampaignId' => '123',
|
253
|
-
#'IsActive' => $flight_IsActive,
|
254
|
-
#'IsDeleted' => $flight_IsDeleted
|
255
|
-
#}
|
256
|
-
#response = @@flight.update(new_flight)
|
257
|
-
#true.should == !response.body.scan(/Object/).nil?
|
258
|
-
#end
|
259
|
-
|
260
|
-
#it "should not create/update if priorityId is forbidden" do
|
261
|
-
#new_flight = {
|
262
|
-
#'NoEndDate' => false,
|
263
|
-
#'PriorityId' => '123',
|
264
|
-
#'Name' => $flight_Name,
|
265
|
-
#'StartDate' => $flight_StartDate,
|
266
|
-
#'EndDate' => $flight_EndDate,
|
267
|
-
#'NoEndDate' => $flight_NoEndDate,
|
268
|
-
#'Price' => $flight_Price,
|
269
|
-
#'OptionType' => $flight_OptionType,
|
270
|
-
#'Impressions' => $flight_Impressions,
|
271
|
-
#'IsUnlimited' => $flight_IsUnlimited,
|
272
|
-
#'IsFullSpeed' => $flight_IsFullSpeed,
|
273
|
-
#'Keywords' => $flight_Keywords,
|
274
|
-
#'UserAgentKeywords' => $flight_UserAgentKeywords,
|
275
|
-
#'WeightOverride' => $flight_WeightOverride,
|
276
|
-
#'CampaignId' => $flight_CampaignId,
|
277
|
-
#'IsActive' => $flight_IsActive,
|
278
|
-
#'IsDeleted' => $flight_IsDeleted
|
279
|
-
#}
|
280
|
-
#response = @@flight.create(new_flight)
|
281
|
-
#true.should == !response.body.scan(/Object/).nil?
|
282
|
-
|
283
|
-
#new_flight = {
|
284
|
-
#'Id' => $flight_id,
|
285
|
-
#'NoEndDate' => false,
|
286
|
-
#'PriorityId' => '123',
|
287
|
-
#'Name' => $flight_Name,
|
288
|
-
#'StartDate' => $flight_StartDate,
|
289
|
-
#'EndDate' => $flight_EndDate,
|
290
|
-
#'NoEndDate' => $flight_NoEndDate,
|
291
|
-
#'Price' => $flight_Price,
|
292
|
-
#'OptionType' => $flight_OptionType,
|
293
|
-
#'Impressions' => $flight_Impressions,
|
294
|
-
#'IsUnlimited' => $flight_IsUnlimited,
|
295
|
-
#'IsFullSpeed' => $flight_IsFullSpeed,
|
296
|
-
#'Keywords' => $flight_Keywords,
|
297
|
-
#'UserAgentKeywords' => $flight_UserAgentKeywords,
|
298
|
-
#'WeightOverride' => $flight_WeightOverride,
|
299
|
-
#'CampaignId' => $flight_CampaignId,
|
300
|
-
#'IsActive' => $flight_IsActive,
|
301
|
-
#'IsDeleted' => $flight_IsDeleted
|
302
|
-
#}
|
303
|
-
#response = @@flight.update(new_flight)
|
304
|
-
#true.should == !response.body.scan(/Object/).nil?
|
305
|
-
#end
|
306
|
-
|
307
|
-
#it "should list the coutries, regions, and metros for geo-targeting" do
|
308
|
-
#response = @@flight.countries()
|
309
|
-
#true.should == !response.body.scan(/Object/).nil?
|
310
|
-
#response = @@flight.regions("NC")
|
311
|
-
#true.should == !response.body.scan(/Object/).nil?
|
312
|
-
#end
|
313
|
-
|
314
|
-
#it "should create a flight with geotargeting" do
|
315
|
-
#$geo = [{
|
316
|
-
##'LocationId' => nil,
|
317
|
-
#'CountryCode' => 'US',
|
318
|
-
#'Region' => 'NC',
|
319
|
-
#'MetroCode' => '560'
|
320
|
-
#}]
|
321
|
-
|
322
|
-
#new_flight = {
|
323
|
-
#'NoEndDate' => false,
|
324
|
-
#'PriorityId' => $priority_id,
|
325
|
-
#'Name' => $flight_Name,
|
326
|
-
#'StartDate' => $flight_StartDate,
|
327
|
-
#'EndDate' => $flight_EndDate,
|
328
|
-
#'NoEndDate' => $flight_NoEndDate,
|
329
|
-
#'Price' => $flight_Price,
|
330
|
-
#'OptionType' => $flight_OptionType,
|
331
|
-
#'Impressions' => $flight_Impressions,
|
332
|
-
#'IsUnlimited' => $flight_IsUnlimited,
|
333
|
-
#'IsFullSpeed' => $flight_IsFullSpeed,
|
334
|
-
#'Keywords' => $flight_Keywords,
|
335
|
-
#'UserAgentKeywords' => $flight_UserAgentKeywords,
|
336
|
-
#'WeightOverride' => $flight_WeightOverride,
|
337
|
-
#'CampaignId' => $flight_CampaignId,
|
338
|
-
#'IsActive' => $flight_IsActive,
|
339
|
-
#'IsDeleted' => $flight_IsDeleted,
|
340
|
-
#'GeoTargeting' => $geo
|
341
|
-
#}
|
342
|
-
#response = @@flight.create(new_flight)
|
343
|
-
#$flight_id = JSON.parse(response.body)["Id"].to_s
|
344
|
-
#JSON.parse(response.body)["NoEndDate"].should == false
|
345
|
-
#JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
|
346
|
-
#JSON.parse(response.body)["Name"].should == $flight_Name
|
347
|
-
##JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
|
348
|
-
##JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
|
349
|
-
#JSON.parse(response.body)["NoEndDate"].should == $flight_NoEndDate
|
350
|
-
#JSON.parse(response.body)["Price"].should == 15.0
|
351
|
-
#JSON.parse(response.body)["OptionType"].should == $flight_OptionType
|
352
|
-
#JSON.parse(response.body)["Impressions"].should == $flight_Impressions
|
353
|
-
#JSON.parse(response.body)["IsUnlimited"].should == $flight_IsUnlimited
|
354
|
-
#JSON.parse(response.body)["IsFullSpeed"].should == $flight_IsFullSpeed
|
355
|
-
#JSON.parse(response.body)["Keywords"].should == $flight_Keywords
|
356
|
-
#JSON.parse(response.body)["UserAgentKeywords"].should == $flight_UserAgentKeywords
|
357
|
-
#JSON.parse(response.body)["WeightOverride"].should == $flight_WeightOverride
|
358
|
-
#JSON.parse(response.body)["CampaignId"].should == $flight_CampaignId
|
359
|
-
#JSON.parse(response.body)["IsActive"].should == $flight_IsActive
|
360
|
-
#JSON.parse(response.body)["IsDeleted"].should == $flight_IsDeleted
|
361
|
-
#JSON.parse(response.body)["GeoTargeting"].first["CountryCode"].should == "US"
|
362
|
-
#JSON.parse(response.body)["GeoTargeting"].first["Region"].should == "NC"
|
363
|
-
#JSON.parse(response.body)["GeoTargeting"].first["MetroCode"].should == 560
|
364
|
-
#$location_id = JSON.parse(response.body)["GeoTargeting"].first["LocationId"].to_s
|
365
|
-
#end
|
366
|
-
|
367
|
-
#it "should get a flight with geotargeting" do
|
368
|
-
#response = @@flight.get($flight_id)
|
369
|
-
##response.body.should == '{"Id":' + $flight_id + ',"StartDate":"\\/Date(1293840000000+0000)\\/","EndDate":"\\/Date(1325289600000+0000)\\/","Price":15.00,"OptionType":1,"Impressions":10000,"IsUnlimited":false,"IsNoDuplicates":false,"IsFullSpeed":false,"Keywords":"test, test2","Name":"' + $flight_Name + '","CampaignId":' + $campaignId.to_s + ',"PriorityId":0,"IsDeleted":false,"IsActive":true,"GeoTargeting":[{"LocationId":' + $location_id + ',"CountryCode":"US","Region":"NC","MetroCode":560}]}'
|
370
|
-
#end
|
371
|
-
|
372
|
-
#it "should create a flight with goal types, rate types, and day parting" do
|
373
|
-
#$flight_IsActive = true
|
374
|
-
#$flight_IsDeleted = false
|
375
|
-
|
376
|
-
#new_flight = {
|
377
|
-
#'NoEndDate' => false,
|
378
|
-
#'PriorityId' => $priority_id,
|
379
|
-
#'Name' => $flight_Name,
|
380
|
-
#'StartDate' => $flight_StartDate,
|
381
|
-
#'EndDate' => $flight_EndDate,
|
382
|
-
#'NoEndDate' => $flight_NoEndDate,
|
383
|
-
#'Price' => $flight_Price,
|
384
|
-
#'OptionType' => $flight_OptionType,
|
385
|
-
#'Impressions' => $flight_Impressions,
|
386
|
-
#'IsUnlimited' => $flight_IsUnlimited,
|
387
|
-
#'IsFullSpeed' => $flight_IsFullSpeed,
|
388
|
-
#'Keywords' => $flight_Keywords,
|
389
|
-
#'UserAgentKeywords' => $flight_UserAgentKeywords,
|
390
|
-
#'WeightOverride' => $flight_WeightOverride,
|
391
|
-
#'CampaignId' => $flight_CampaignId,
|
392
|
-
#'IsActive' => $flight_IsActive,
|
393
|
-
#'IsDeleted' => $flight_IsDeleted,
|
394
|
-
#'GoalType' => 1,
|
395
|
-
#'RateType' => 1,
|
396
|
-
#'IsSunday' => true,
|
397
|
-
#'IsMonday' => true,
|
398
|
-
#'IsWednesday' => true,
|
399
|
-
#'DatePartingStartTime' => '12:00:00',
|
400
|
-
#'DatePartingEndTime' => '12:00:00'
|
401
|
-
#}
|
402
|
-
#response = @@flight.create(new_flight)
|
403
|
-
#$flight_id = JSON.parse(response.body)["Id"].to_s
|
404
|
-
#JSON.parse(response.body)["NoEndDate"].should == false
|
405
|
-
#JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
|
406
|
-
#JSON.parse(response.body)["Name"].should == $flight_Name
|
407
|
-
##JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
|
408
|
-
##JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
|
409
|
-
#JSON.parse(response.body)["NoEndDate"].should == $flight_NoEndDate
|
410
|
-
#JSON.parse(response.body)["Price"].should == 15.0
|
411
|
-
#JSON.parse(response.body)["OptionType"].should == $flight_OptionType
|
412
|
-
#JSON.parse(response.body)["Impressions"].should == $flight_Impressions
|
413
|
-
#JSON.parse(response.body)["IsUnlimited"].should == $flight_IsUnlimited
|
414
|
-
#JSON.parse(response.body)["IsFullSpeed"].should == $flight_IsFullSpeed
|
415
|
-
#JSON.parse(response.body)["Keywords"].should == $flight_Keywords
|
416
|
-
#JSON.parse(response.body)["UserAgentKeywords"].should == $flight_UserAgentKeywords
|
417
|
-
#JSON.parse(response.body)["WeightOverride"].should == $flight_WeightOverride
|
418
|
-
#JSON.parse(response.body)["CampaignId"].should == $flight_CampaignId
|
419
|
-
#JSON.parse(response.body)["IsActive"].should == $flight_IsActive
|
420
|
-
#JSON.parse(response.body)["IsDeleted"].should == $flight_IsDeleted
|
421
|
-
#JSON.parse(response.body)["GoalType"].should == 1
|
422
|
-
#JSON.parse(response.body)["RateType"].should == 1
|
423
|
-
#JSON.parse(response.body)["IsSunday"].should == true
|
424
|
-
#JSON.parse(response.body)["IsMonday"].should == true
|
425
|
-
#JSON.parse(response.body)["IsWednesday"].should == true
|
426
|
-
#JSON.parse(response.body)["DatePartingStartTime"].should == '12:00:00'
|
427
|
-
#JSON.parse(response.body)["DatePartingEndTime"].should == '12:00:00'
|
428
|
-
#end
|
429
|
-
|
430
|
-
#it "should create a flight with frequency capping" do
|
431
|
-
#$flight_IsActive = true
|
432
|
-
#$flight_IsDeleted = false
|
433
|
-
|
434
|
-
#new_flight = {
|
435
|
-
#'NoEndDate' => false,
|
436
|
-
#'PriorityId' => $priority_id,
|
437
|
-
#'Name' => $flight_Name,
|
438
|
-
#'StartDate' => $flight_StartDate,
|
439
|
-
#'EndDate' => $flight_EndDate,
|
440
|
-
#'NoEndDate' => $flight_NoEndDate,
|
441
|
-
#'Price' => $flight_Price,
|
442
|
-
#'OptionType' => $flight_OptionType,
|
443
|
-
#'Impressions' => $flight_Impressions,
|
444
|
-
#'IsUnlimited' => $flight_IsUnlimited,
|
445
|
-
#'IsFullSpeed' => $flight_IsFullSpeed,
|
446
|
-
#'Keywords' => $flight_Keywords,
|
447
|
-
#'UserAgentKeywords' => $flight_UserAgentKeywords,
|
448
|
-
#'WeightOverride' => $flight_WeightOverride,
|
449
|
-
#'CampaignId' => $flight_CampaignId,
|
450
|
-
#'IsActive' => $flight_IsActive,
|
451
|
-
#'IsDeleted' => $flight_IsDeleted,
|
452
|
-
#'IsFreqCap' => true,
|
453
|
-
#'FreqCap' => 5,
|
454
|
-
#'FreqCapDuration' => 6,
|
455
|
-
#'FreqCapType' => 1
|
456
|
-
#}
|
457
|
-
#response = @@flight.create(new_flight)
|
458
|
-
#$flight_id = JSON.parse(response.body)["Id"].to_s
|
459
|
-
#JSON.parse(response.body)["NoEndDate"].should == false
|
460
|
-
#JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
|
461
|
-
#JSON.parse(response.body)["Name"].should == $flight_Name
|
462
|
-
##JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
|
463
|
-
##JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
|
464
|
-
#JSON.parse(response.body)["NoEndDate"].should == $flight_NoEndDate
|
465
|
-
#JSON.parse(response.body)["Price"].should == 15.0
|
466
|
-
#JSON.parse(response.body)["OptionType"].should == $flight_OptionType
|
467
|
-
#JSON.parse(response.body)["Impressions"].should == $flight_Impressions
|
468
|
-
#JSON.parse(response.body)["IsUnlimited"].should == $flight_IsUnlimited
|
469
|
-
#JSON.parse(response.body)["IsFullSpeed"].should == $flight_IsFullSpeed
|
470
|
-
#JSON.parse(response.body)["Keywords"].should == $flight_Keywords
|
471
|
-
#JSON.parse(response.body)["UserAgentKeywords"].should == $flight_UserAgentKeywords
|
472
|
-
#JSON.parse(response.body)["WeightOverride"].should == $flight_WeightOverride
|
473
|
-
#JSON.parse(response.body)["CampaignId"].should == $flight_CampaignId
|
474
|
-
#JSON.parse(response.body)["IsActive"].should == $flight_IsActive
|
475
|
-
#JSON.parse(response.body)["IsDeleted"].should == $flight_IsDeleted
|
476
|
-
#JSON.parse(response.body)["IsFreqCap"].should == true
|
477
|
-
#JSON.parse(response.body)["FreqCap"].should == 5
|
478
|
-
#JSON.parse(response.body)["FreqCapDuration"].should == 6
|
479
|
-
#JSON.parse(response.body)["FreqCapType"].should == 1
|
480
|
-
#end
|
481
|
-
|
482
|
-
#it "should test day parting without days selected" do
|
483
|
-
#new_flight = {
|
484
|
-
#'NoEndDate' => false,
|
485
|
-
#'PriorityId' => $priority_id,
|
486
|
-
#'Name' => $flight_Name,
|
487
|
-
#'StartDate' => $flight_StartDate,
|
488
|
-
#'EndDate' => $flight_EndDate,
|
489
|
-
#'NoEndDate' => $flight_NoEndDate,
|
490
|
-
#'Price' => $flight_Price,
|
491
|
-
#'OptionType' => $flight_OptionType,
|
492
|
-
#'Impressions' => $flight_Impressions,
|
493
|
-
#'IsUnlimited' => $flight_IsUnlimited,
|
494
|
-
#'IsFullSpeed' => $flight_IsFullSpeed,
|
495
|
-
#'Keywords' => $flight_Keywords,
|
496
|
-
#'UserAgentKeywords' => $flight_UserAgentKeywords,
|
497
|
-
#'WeightOverride' => $flight_WeightOverride,
|
498
|
-
#'CampaignId' => $flight_CampaignId,
|
499
|
-
#'IsActive' => $flight_IsActive,
|
500
|
-
#'IsDeleted' => $flight_IsDeleted,
|
501
|
-
#'GoalType' => 1,
|
502
|
-
#'RateType' => 1,
|
503
|
-
#'DatePartingStartTime' => '12:00:00',
|
504
|
-
#'DatePartingEndTime' => '18:32:12'
|
505
|
-
#}
|
506
|
-
#response = @@flight.create(new_flight)
|
507
|
-
#end
|
508
|
-
|
509
|
-
#it "should test day parting without time selected" do
|
510
|
-
#new_flight = {
|
511
|
-
#'NoEndDate' => false,
|
512
|
-
#'PriorityId' => $priority_id,
|
513
|
-
#'Name' => $flight_Name,
|
514
|
-
#'StartDate' => $flight_StartDate,
|
515
|
-
#'EndDate' => $flight_EndDate,
|
516
|
-
#'NoEndDate' => $flight_NoEndDate,
|
517
|
-
#'Price' => $flight_Price,
|
518
|
-
#'OptionType' => $flight_OptionType,
|
519
|
-
#'Impressions' => $flight_Impressions,
|
520
|
-
#'IsUnlimited' => $flight_IsUnlimited,
|
521
|
-
#'IsFullSpeed' => $flight_IsFullSpeed,
|
522
|
-
#'Keywords' => $flight_Keywords,
|
523
|
-
#'UserAgentKeywords' => $flight_UserAgentKeywords,
|
524
|
-
#'WeightOverride' => $flight_WeightOverride,
|
525
|
-
#'CampaignId' => $flight_CampaignId,
|
526
|
-
#'IsActive' => $flight_IsActive,
|
527
|
-
#'IsDeleted' => $flight_IsDeleted,
|
528
|
-
#'GoalType' => 1,
|
529
|
-
#'RateType' => 1,
|
530
|
-
#'IsSunday' => true,
|
531
|
-
#'IsMonday' => true,
|
532
|
-
#'IsWednesday' => true
|
533
|
-
#}
|
534
|
-
#response = @@flight.create(new_flight)
|
535
|
-
#end
|
536
|
-
|
537
|
-
|
538
188
|
|
189
|
+
it "should not create a flight for a campaign in a different network" do
|
190
|
+
flight = @flights.create(
|
191
|
+
:no_end_date => false,
|
192
|
+
:priority_id => $priority_id,
|
193
|
+
:name => $flight_Name,
|
194
|
+
:start_date => $flight_StartDate,
|
195
|
+
:end_date => $flight_EndDate,
|
196
|
+
:no_end_date => $flight_NoEndDate,
|
197
|
+
:price => $flight_Price,
|
198
|
+
:option_type => $flight_OptionType,
|
199
|
+
:impressions => $flight_Impressions,
|
200
|
+
:is_unlimited => $flight_IsUnlimited,
|
201
|
+
:is_full_speed => $flight_IsFullSpeed,
|
202
|
+
:keywords => $flight_Keywords,
|
203
|
+
:user_agent_keywords => $flight_UserAgentKeywords,
|
204
|
+
:weight_override => $flight_WeightOverride,
|
205
|
+
:campaign_id => 123,
|
206
|
+
:is_active => $flight_IsActive,
|
207
|
+
:is_deleted => $flight_IsDeleted
|
208
|
+
)
|
209
|
+
flight[:message].should == "This campaign is not part of your network"
|
210
|
+
end
|
539
211
|
end
|