adzerk 0.1 → 0.1.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 +8 -2
- data/lib/adzerk/Advertiser.rb +7 -1
- data/lib/adzerk/ChannelSiteMap.rb +44 -0
- data/lib/adzerk/Creative.rb +0 -7
- data/lib/adzerk/Flight.rb +12 -1
- data/lib/adzerk/Priority.rb +34 -0
- data/test/advertiser_api_spec.rb +14 -10
- data/test/campaign_api_spec.rb +63 -25
- data/test/channel_api_security_spec.rb +1 -1
- data/test/channel_api_spec.rb +7 -7
- data/test/channel_site_map_api_spec.rb +125 -0
- data/test/creative_api_spec.rb +56 -24
- data/test/creative_map_api_spec.rb +82 -56
- data/test/flight_api_spec.rb +91 -16
- data/test/invitation_api_spec.rb +12 -2
- data/test/login_api_spec.rb +18 -9
- data/test/priority_api_spec.rb +105 -0
- data/test/rakefile.rb +4 -1
- data/test/spec_helper.rb +8 -2
- data/test/test.rb +43 -0
- metadata +9 -3
data/test/channel_api_spec.rb
CHANGED
|
@@ -7,11 +7,11 @@ describe "Channel API" do
|
|
|
7
7
|
|
|
8
8
|
it "should create a new channel" do
|
|
9
9
|
$channel_title = 'Test Channel ' + rand(1000000).to_s
|
|
10
|
-
$channel_commission = '0'
|
|
10
|
+
$channel_commission = '0.00'
|
|
11
11
|
$channel_engine = 'CPM'
|
|
12
12
|
$channel_keywords = 'test, another test'
|
|
13
13
|
$channel_CPM = '10.00'
|
|
14
|
-
$channel_AdTypes = [
|
|
14
|
+
$channel_AdTypes = [1,2,3,4,5]
|
|
15
15
|
|
|
16
16
|
new_channel = {
|
|
17
17
|
'Title' => $channel_title,
|
|
@@ -34,12 +34,12 @@ describe "Channel API" do
|
|
|
34
34
|
|
|
35
35
|
it "should list a specific channel" do
|
|
36
36
|
response = @@channel.get($channel_id)
|
|
37
|
-
response.body.should == '{"Id":' + $channel_id + ',"Title":"' + $channel_title + '","Commission":' +
|
|
37
|
+
response.body.should == '{"Id":' + $channel_id + ',"Title":"' + $channel_title + '","Commission":' + '0.00' + ',"Engine":"' + $channel_engine + '","Keywords":"' + $channel_keywords + '","CPM":' + $channel_CPM + ',"AdTypes":' + $channel_AdTypes.to_json + ',"IsDeleted":false}'
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "should update a channel" do
|
|
41
41
|
$u_channel_title = 'Test Channel ' + rand(1000000).to_s + 'test'
|
|
42
|
-
$u_channel_commission = '1'
|
|
42
|
+
$u_channel_commission = '1.0'
|
|
43
43
|
$u_channel_engine = 'CPI'
|
|
44
44
|
$u_channel_keywords = 'another test'
|
|
45
45
|
$u_channel_CPM = '0'
|
|
@@ -58,7 +58,7 @@ describe "Channel API" do
|
|
|
58
58
|
response = @@channel.update(updated_channel)
|
|
59
59
|
$channel_id = JSON.parse(response.body)["Id"].to_s
|
|
60
60
|
$u_channel_title.should == JSON.parse(response.body)["Title"]
|
|
61
|
-
|
|
61
|
+
#JSON.parse(response.body)["Commission"].should == $u_channel_commission
|
|
62
62
|
$u_channel_engine.should == JSON.parse(response.body)["Engine"]
|
|
63
63
|
$u_channel_keywords.should == JSON.parse(response.body)["Keywords"]
|
|
64
64
|
$u_channel_CPM.to_f.should == JSON.parse(response.body)["CPM"]
|
|
@@ -73,7 +73,7 @@ describe "Channel API" do
|
|
|
73
73
|
result["Items"].last["Commission"].should == $u_channel_commission.to_f
|
|
74
74
|
result["Items"].last["Engine"].should == $u_channel_engine
|
|
75
75
|
result["Items"].last["Keywords"].should == $u_channel_keywords
|
|
76
|
-
result["Items"].last["CPM"].
|
|
76
|
+
result["Items"].last["CPM"].to_f == $u_channel_CPM.to_f
|
|
77
77
|
result["Items"].last["AdTypes"].should == $u_channel_AdTypes
|
|
78
78
|
end
|
|
79
79
|
|
|
@@ -108,4 +108,4 @@ describe "Channel API" do
|
|
|
108
108
|
response.body.should == '{"Id":0,"Commission":0,"CPM":0,"IsDeleted":false}'
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
-
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Channel Site Map API" do
|
|
4
|
+
|
|
5
|
+
$site_url = 'http://www.adzerk.com'
|
|
6
|
+
@@csm = $adzerk::ChannelSiteMap.new
|
|
7
|
+
@@channel = $adzerk::Channel.new
|
|
8
|
+
@@site = $adzerk::Site.new
|
|
9
|
+
|
|
10
|
+
before(:all) do
|
|
11
|
+
new_channel = {
|
|
12
|
+
'Title' => 'Test Channel ' + rand(1000000).to_s,
|
|
13
|
+
'Commission' => '0.0',
|
|
14
|
+
'Engine' => 'CPM',
|
|
15
|
+
'Keywords' => 'test',
|
|
16
|
+
'CPM' => '10.00',
|
|
17
|
+
'AdTypes' => [1,2,3,4]
|
|
18
|
+
}
|
|
19
|
+
response = @@channel.create(new_channel)
|
|
20
|
+
$channelId = JSON.parse(response.body)["Id"]
|
|
21
|
+
|
|
22
|
+
new_site = {
|
|
23
|
+
'Title' => 'Test Site ' + rand(1000000).to_s,
|
|
24
|
+
'Url' => 'http://www.adzerk.com'
|
|
25
|
+
}
|
|
26
|
+
response = @@site.create(new_site)
|
|
27
|
+
$siteId = JSON.parse(response.body)["Id"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should create a new map" do
|
|
31
|
+
new_map = {
|
|
32
|
+
'SiteId' => $siteId,
|
|
33
|
+
'ChannelId' => $channelId,
|
|
34
|
+
'Priority' => 10
|
|
35
|
+
}
|
|
36
|
+
response = @@csm.create(new_map)
|
|
37
|
+
JSON.parse(response.body)["SiteId"].should == $siteId
|
|
38
|
+
JSON.parse(response.body)["ChannelId"].should == $channelId
|
|
39
|
+
JSON.parse(response.body)["Priority"].should == 10
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should retrieve a list of sites in a channel" do
|
|
43
|
+
response = @@csm.sitesInChannel($channelId)
|
|
44
|
+
true.should == response.body.scan(/#{$siteId}/).length >= 1
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should retrieve a list of channels in a site" do
|
|
48
|
+
response = @@csm.channelsInSite($siteId)
|
|
49
|
+
true.should == response.body.scan(/#{$channelId}/).length >= 1
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "should list a specific map" do
|
|
53
|
+
response = @@csm.get($channelId, $siteId)
|
|
54
|
+
response.body.should == '{"SiteId":' + $siteId.to_s + ',"ChannelId":' + $channelId.to_s + ',"FixedPaymentAmount":0' + ',"Priority":' + '10}'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should update a map" do
|
|
58
|
+
u_map = {
|
|
59
|
+
'SiteId' => $siteId,
|
|
60
|
+
'ChannelId' => $channelId,
|
|
61
|
+
'Priority' => 200
|
|
62
|
+
}
|
|
63
|
+
response = @@csm.update(u_map)
|
|
64
|
+
JSON.parse(response.body)["SiteId"].should == $siteId
|
|
65
|
+
JSON.parse(response.body)["ChannelId"].should == $channelId
|
|
66
|
+
JSON.parse(response.body)["Priority"].should == 200
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "should list all maps for network" do
|
|
70
|
+
result = @@csm.list()
|
|
71
|
+
result.length.should > 0
|
|
72
|
+
result["Items"].last["SiteId"].should == $siteId
|
|
73
|
+
result["Items"].last["ChannelId"].should == $channelId
|
|
74
|
+
result["Items"].last["Priority"].should == 200
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should delete a new maps" do
|
|
78
|
+
response = @@csm.delete($channelId, $siteId)
|
|
79
|
+
response.body.should == 'OK'
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "should not list deleted maps" do
|
|
83
|
+
result = @@csm.list()
|
|
84
|
+
#result["Items"].each do |r|
|
|
85
|
+
# r["SiteId"].should_not == $siteId and
|
|
86
|
+
# r["ChannelId"].should_not == $channelId
|
|
87
|
+
#end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "should not get individual deleted maps" do
|
|
91
|
+
response = @@csm.get($channelId, $siteId)
|
|
92
|
+
response.body.should == '{"SiteId":0,"ChannelId":0,"Priority":0}'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "should not update deleted maps" do
|
|
96
|
+
u_map = {
|
|
97
|
+
'SiteId' => $siteId,
|
|
98
|
+
'ChannelId' => $channelId,
|
|
99
|
+
'Priority' => 300
|
|
100
|
+
}
|
|
101
|
+
response = @@csm.update(u_map)
|
|
102
|
+
response.body.should == '{"SiteId":0,"ChannelId":0,"Priority":0}'
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "should not create if the site is in a different network" do
|
|
106
|
+
new_map = {
|
|
107
|
+
'SiteId' => 1,
|
|
108
|
+
'ChannelId' => $channelId,
|
|
109
|
+
'Priority' => 10
|
|
110
|
+
}
|
|
111
|
+
response = @@csm.create(new_map)
|
|
112
|
+
true.should == response.body.scan(/This site is not part of your network/).length > 1
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "should not create if the channel is in a different netowork" do
|
|
116
|
+
new_map = {
|
|
117
|
+
'SiteId' => $siteId,
|
|
118
|
+
'ChannelId' => 1,
|
|
119
|
+
'Priority' => 10
|
|
120
|
+
}
|
|
121
|
+
response = @@csm.create(new_map)
|
|
122
|
+
true.should == response.body.scan(/This channel is not part of your network/).length > 1
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
end
|
data/test/creative_api_spec.rb
CHANGED
|
@@ -11,7 +11,7 @@ describe "Creative API" do
|
|
|
11
11
|
'Title' => "Test"
|
|
12
12
|
}
|
|
13
13
|
response = @@advertiser.create(new_advertiser)
|
|
14
|
-
$
|
|
14
|
+
$advertiserId = JSON.parse(response.body)["Id"]
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it "should create a creative" do
|
|
@@ -19,7 +19,7 @@ describe "Creative API" do
|
|
|
19
19
|
$ImageName = ""
|
|
20
20
|
$Url = "http://adzerk.com"
|
|
21
21
|
$Body = "Test text"
|
|
22
|
-
$
|
|
22
|
+
$AdvertiserId = $advertiserId
|
|
23
23
|
$AdTypeId = 18
|
|
24
24
|
$IsActive = true
|
|
25
25
|
$Alt = "test alt"
|
|
@@ -31,7 +31,7 @@ describe "Creative API" do
|
|
|
31
31
|
'ImageName' => $ImageName,
|
|
32
32
|
'Url' => $Url,
|
|
33
33
|
'Body' => $Body,
|
|
34
|
-
'
|
|
34
|
+
'AdvertiserId' => $AdvertiserId,
|
|
35
35
|
'AdTypeId' => $AdTypeId,
|
|
36
36
|
'IsActive' => $IsActive,
|
|
37
37
|
'Alt' => $Alt,
|
|
@@ -39,12 +39,11 @@ describe "Creative API" do
|
|
|
39
39
|
'IsSync' => $IsSync
|
|
40
40
|
}
|
|
41
41
|
response = @@creative.create(new_creative, '250x250.gif')
|
|
42
|
-
|
|
43
42
|
$creative_id = JSON.parse(response)["Id"].to_s
|
|
44
43
|
JSON.parse(response.body)["Title"].should == $Title
|
|
45
44
|
JSON.parse(response.body)["Url"].should == $Url
|
|
46
45
|
JSON.parse(response.body)["Body"].should == $Body
|
|
47
|
-
JSON.parse(response.body)["
|
|
46
|
+
JSON.parse(response.body)["AdvertiserId"].should == $AdvertiserId
|
|
48
47
|
JSON.parse(response.body)["AdTypeId"].should == $AdTypeId
|
|
49
48
|
JSON.parse(response.body)["IsActive"].should == $IsActive
|
|
50
49
|
JSON.parse(response.body)["Alt"].should == $Alt
|
|
@@ -59,7 +58,7 @@ describe "Creative API" do
|
|
|
59
58
|
JSON.parse(response.body)["Title"].should == $Title
|
|
60
59
|
JSON.parse(response.body)["Url"].should == $Url
|
|
61
60
|
JSON.parse(response.body)["Body"].should == $Body
|
|
62
|
-
JSON.parse(response.body)["
|
|
61
|
+
JSON.parse(response.body)["AdvertiserId"].should == $AdvertiserId
|
|
63
62
|
JSON.parse(response.body)["AdTypeId"].should == $AdTypeId
|
|
64
63
|
JSON.parse(response.body)["IsActive"].should == $IsActive
|
|
65
64
|
JSON.parse(response.body)["Alt"].should == $Alt
|
|
@@ -74,7 +73,7 @@ describe "Creative API" do
|
|
|
74
73
|
'ImageName' => $ImageName,
|
|
75
74
|
'Url' => $Url,
|
|
76
75
|
'Body' => $Body,
|
|
77
|
-
'
|
|
76
|
+
'AdvertiserId' => $AdvertiserId,
|
|
78
77
|
'AdTypeId' => $AdTypeId,
|
|
79
78
|
'IsActive' => $IsActive,
|
|
80
79
|
'Alt' => $Alt,
|
|
@@ -82,26 +81,26 @@ describe "Creative API" do
|
|
|
82
81
|
'IsSync' => $IsSync
|
|
83
82
|
}
|
|
84
83
|
response = @@creative.update(update_creative)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
JSON.parse(response.body)["Id"].should == $creative_id.to_i
|
|
85
|
+
JSON.parse(response.body)["Title"].should == $Title
|
|
86
|
+
JSON.parse(response.body)["Url"].should == $Url
|
|
87
|
+
JSON.parse(response.body)["Body"].should == $Body
|
|
88
|
+
JSON.parse(response.body)["AdvertiserId"].should == $AdvertiserId
|
|
89
|
+
JSON.parse(response.body)["AdTypeId"].should == $AdTypeId
|
|
90
|
+
JSON.parse(response.body)["IsActive"].should == $IsActive
|
|
91
|
+
JSON.parse(response.body)["Alt"].should == $Alt
|
|
92
|
+
JSON.parse(response.body)["IsDeleted"].should == $IsDeleted
|
|
93
|
+
JSON.parse(response.body)["IsSync"].should == $IsSync
|
|
95
94
|
end
|
|
96
95
|
|
|
97
96
|
it "should list all creatives for an advertiser" do
|
|
98
|
-
response = @@creative.list($
|
|
97
|
+
response = @@creative.list($AdvertiserId)
|
|
99
98
|
entry = response["Items"].last.to_json
|
|
100
99
|
JSON.parse(entry)["Id"].should == $creative_id.to_i
|
|
101
100
|
JSON.parse(entry)["Title"].should == $Title
|
|
102
101
|
JSON.parse(entry)["Url"].should == $Url
|
|
103
102
|
JSON.parse(entry)["Body"].should == $Body
|
|
104
|
-
JSON.parse(entry)["
|
|
103
|
+
JSON.parse(entry)["AdvertiserId"].should == $AdvertiserId
|
|
105
104
|
JSON.parse(entry)["AdTypeId"].should == $AdTypeId
|
|
106
105
|
JSON.parse(entry)["IsActive"].should == $IsActive
|
|
107
106
|
JSON.parse(entry)["Alt"].should == $Alt
|
|
@@ -114,13 +113,13 @@ describe "Creative API" do
|
|
|
114
113
|
response.body.should == "OK"
|
|
115
114
|
end
|
|
116
115
|
|
|
117
|
-
it "should not use a
|
|
116
|
+
it "should not use a AdvertiserId it doesn't have access to when creating" do
|
|
118
117
|
new_creative = {
|
|
119
118
|
'Title' => $Title,
|
|
120
119
|
'ImageName' => $ImageName,
|
|
121
120
|
'Url' => $Url,
|
|
122
121
|
'Body' => $Body,
|
|
123
|
-
'
|
|
122
|
+
'AdvertiserId' => 1,
|
|
124
123
|
'AdTypeId' => $AdTypeId,
|
|
125
124
|
'IsActive' => $IsActive,
|
|
126
125
|
'Alt' => $Alt,
|
|
@@ -136,14 +135,14 @@ describe "Creative API" do
|
|
|
136
135
|
response.to_s.scan("302 Found").should_not == nil
|
|
137
136
|
end
|
|
138
137
|
|
|
139
|
-
it "should not use a
|
|
138
|
+
it "should not use a AdvertiserId it doesn't have access to when updating" do
|
|
140
139
|
new_creative = {
|
|
141
140
|
'Id' => $creative_id.to_i,
|
|
142
141
|
'Title' => $Title,
|
|
143
142
|
'ImageName' => $ImageName,
|
|
144
143
|
'Url' => $Url,
|
|
145
144
|
'Body' => $Body,
|
|
146
|
-
'
|
|
145
|
+
'AdvertiserId' => 1,
|
|
147
146
|
'AdTypeId' => $AdTypeId,
|
|
148
147
|
'IsActive' => $IsActive,
|
|
149
148
|
'Alt' => $Alt,
|
|
@@ -163,5 +162,38 @@ describe "Creative API" do
|
|
|
163
162
|
response = @@creative.delete("123")
|
|
164
163
|
true.should == !response.body.scan(/Object/).nil?
|
|
165
164
|
end
|
|
166
|
-
|
|
165
|
+
|
|
166
|
+
it "should create a creative with no url or image name passed in" do
|
|
167
|
+
$Url = "http://adzerk.com"
|
|
168
|
+
$Body = "Test text"
|
|
169
|
+
$AdvertiserId = $advertiserId
|
|
170
|
+
$AdTypeId = 18
|
|
171
|
+
$IsActive = true
|
|
172
|
+
$Alt = "test alt"
|
|
173
|
+
$IsDeleted = false
|
|
174
|
+
$IsSync = false
|
|
175
|
+
|
|
176
|
+
new_creative = {
|
|
177
|
+
'Title' => $Title,
|
|
178
|
+
'Body' => $Body,
|
|
179
|
+
'AdvertiserId' => $AdvertiserId,
|
|
180
|
+
'AdTypeId' => $AdTypeId,
|
|
181
|
+
'IsActive' => $IsActive,
|
|
182
|
+
'Alt' => $Alt,
|
|
183
|
+
'IsDeleted' => $IsDeleted,
|
|
184
|
+
'IsSync' => $IsSync
|
|
185
|
+
}
|
|
186
|
+
response = @@creative.create(new_creative, '250x250.gif')
|
|
187
|
+
$creative_id = JSON.parse(response)["Id"].to_s
|
|
188
|
+
JSON.parse(response.body)["Title"].should == $Title
|
|
189
|
+
JSON.parse(response.body)["Body"].should == $Body
|
|
190
|
+
JSON.parse(response.body)["AdvertiserId"].should == $AdvertiserId
|
|
191
|
+
JSON.parse(response.body)["AdTypeId"].should == $AdTypeId
|
|
192
|
+
JSON.parse(response.body)["IsActive"].should == $IsActive
|
|
193
|
+
JSON.parse(response.body)["Alt"].should == $Alt
|
|
194
|
+
JSON.parse(response.body)["IsDeleted"].should == $IsDeleted
|
|
195
|
+
JSON.parse(response.body)["IsSync"].should == $IsSync
|
|
196
|
+
|
|
197
|
+
end
|
|
198
|
+
|
|
167
199
|
end
|
|
@@ -9,13 +9,14 @@ describe "Creative Flight API" do
|
|
|
9
9
|
@@campaign = $adzerk::Campaign.new
|
|
10
10
|
@@site = $adzerk::Site.new
|
|
11
11
|
@@flight = $adzerk::Flight.new
|
|
12
|
+
@@priority = $adzerk::Priority.new
|
|
12
13
|
|
|
13
14
|
before(:all) do
|
|
14
15
|
new_advertiser = {
|
|
15
16
|
'Title' => "Test"
|
|
16
17
|
}
|
|
17
18
|
response = @@advertiser.create(new_advertiser)
|
|
18
|
-
$
|
|
19
|
+
$advertiserId = JSON.parse(response.body)["Id"]
|
|
19
20
|
|
|
20
21
|
new_channel = {
|
|
21
22
|
'Title' => 'Test Channel ' + rand(1000000).to_s,
|
|
@@ -23,10 +24,19 @@ describe "Creative Flight API" do
|
|
|
23
24
|
'Engine' => 'CPM',
|
|
24
25
|
'Keywords' => 'test',
|
|
25
26
|
'CPM' => '10.00',
|
|
26
|
-
'AdTypes' => [
|
|
27
|
+
'AdTypes' => [1,2,3,4]
|
|
27
28
|
}
|
|
28
29
|
response = @@channel.create(new_channel)
|
|
29
30
|
$channelId = JSON.parse(response.body)["Id"]
|
|
31
|
+
|
|
32
|
+
new_priority = {
|
|
33
|
+
'Name' => "High Priority Test",
|
|
34
|
+
'ChannelId' => $channelId,
|
|
35
|
+
'Weight' => 1,
|
|
36
|
+
'IsDeleted' => false
|
|
37
|
+
}
|
|
38
|
+
response = @@priority.create(new_priority)
|
|
39
|
+
$priority_id = JSON.parse(response.body)["Id"].to_s
|
|
30
40
|
|
|
31
41
|
new_campaign = {
|
|
32
42
|
'Name' => 'Test campaign ' + rand(1000000).to_s,
|
|
@@ -34,7 +44,7 @@ describe "Creative Flight API" do
|
|
|
34
44
|
'EndDate' => "12/31/2011",
|
|
35
45
|
'IsActive' => false,
|
|
36
46
|
'Price' => '10.00',
|
|
37
|
-
'
|
|
47
|
+
'AdvertiserId' => $advertiserId,
|
|
38
48
|
'Flights' => [],
|
|
39
49
|
'IsDeleted' => false
|
|
40
50
|
}
|
|
@@ -43,7 +53,7 @@ describe "Creative Flight API" do
|
|
|
43
53
|
|
|
44
54
|
new_flight = {
|
|
45
55
|
'NoEndDate' => false,
|
|
46
|
-
'
|
|
56
|
+
'PriorityId' => $priority_id,
|
|
47
57
|
'Name' => 'Test flight ' + rand(1000000).to_s,
|
|
48
58
|
'StartDate' => "1/1/2011",
|
|
49
59
|
'EndDate' => "12/31/2011",
|
|
@@ -76,14 +86,13 @@ describe "Creative Flight API" do
|
|
|
76
86
|
$ImageName = "test.jpg"
|
|
77
87
|
$Url = "http://adzerk.com"
|
|
78
88
|
$Body = "Test text"
|
|
79
|
-
$
|
|
89
|
+
$AdvertiserId = $advertiserId
|
|
80
90
|
$CampaignId = $campaignId
|
|
81
91
|
$FlightId = $flightId
|
|
82
92
|
$MapId = 0
|
|
83
93
|
$AdTypeId = 18
|
|
84
94
|
$ZoneId = 0
|
|
85
95
|
$SiteId = $siteId
|
|
86
|
-
$ChannelId = $channelId
|
|
87
96
|
$SizeOverride = false
|
|
88
97
|
$Iframe = false
|
|
89
98
|
$PublisherAccountId = 372
|
|
@@ -102,7 +111,6 @@ describe "Creative Flight API" do
|
|
|
102
111
|
'FlightId' => $FlightId,
|
|
103
112
|
#'MapId' => $MapId,
|
|
104
113
|
#'ZoneId' => $ZoneId,
|
|
105
|
-
'ChannelId' => $ChannelId,
|
|
106
114
|
'SizeOverride' => $SizeOverride,
|
|
107
115
|
'Iframe' => $Iframe,
|
|
108
116
|
'PublisherAccountId' => $PublisherAccountId,
|
|
@@ -116,10 +124,9 @@ describe "Creative Flight API" do
|
|
|
116
124
|
'IsDeleted' => $IsDeleted,
|
|
117
125
|
'Creative' => {
|
|
118
126
|
'Title' => $Title,
|
|
119
|
-
'ImageName' => $ImageName,
|
|
120
127
|
'Url' => $Url,
|
|
121
128
|
'Body' => $Body,
|
|
122
|
-
'
|
|
129
|
+
'AdvertiserId' => $AdvertiserId,
|
|
123
130
|
'AdTypeId' => $AdTypeId,
|
|
124
131
|
'IsActive' => $IsActive,
|
|
125
132
|
'Alt' => $Alt,
|
|
@@ -133,14 +140,13 @@ describe "Creative Flight API" do
|
|
|
133
140
|
JSON.parse(response.body)["Creative"]["Title"].should == $Title
|
|
134
141
|
JSON.parse(response.body)["Creative"]["Url"].should == $Url
|
|
135
142
|
JSON.parse(response.body)["Creative"]["Body"].should == $Body
|
|
136
|
-
JSON.parse(response.body)["Creative"]["
|
|
143
|
+
JSON.parse(response.body)["Creative"]["AdvertiserId"].should == $AdvertiserId
|
|
137
144
|
JSON.parse(response.body)["CampaignId"].should == $CampaignId
|
|
138
145
|
JSON.parse(response.body)["FlightId"].should == $FlightId
|
|
139
146
|
#JSON.parse(response.body)["MapId"].should == $MapId
|
|
140
147
|
JSON.parse(response.body)["Creative"]["AdTypeId"].should == $AdTypeId
|
|
141
148
|
#JSON.parse(response.body)["ZoneId"].should == $ZoneId
|
|
142
149
|
JSON.parse(response.body)["SiteId"].should == $SiteId
|
|
143
|
-
JSON.parse(response.body)["ChannelId"].should == $ChannelId
|
|
144
150
|
JSON.parse(response.body)["SizeOverride"].should == $SizeOverride
|
|
145
151
|
JSON.parse(response.body)["PublisherAccountId"].should == $PublisherAccountId
|
|
146
152
|
JSON.parse(response.body)["ScriptBody"].should == $ScriptBody
|
|
@@ -161,21 +167,20 @@ describe "Creative Flight API" do
|
|
|
161
167
|
JSON.parse(entry)["Creative"]["Title"].should == $Title
|
|
162
168
|
JSON.parse(entry)["Creative"]["Url"].should == $Url
|
|
163
169
|
JSON.parse(entry)["Creative"]["Body"].should == $Body
|
|
164
|
-
JSON.parse(entry)["Creative"]["
|
|
170
|
+
JSON.parse(entry)["Creative"]["AdvertiserId"].should == $AdvertiserId
|
|
165
171
|
#JSON.parse(entry)["CampaignId"].should == $CampaignId
|
|
166
172
|
#JSON.parse(entry)["FlightId"].should == $FlightId
|
|
167
173
|
#JSON.parse(entry)["MapId"].should == $MapId
|
|
168
174
|
JSON.parse(entry)["Creative"]["AdTypeId"].should == $AdTypeId
|
|
169
175
|
#JSON.parse(entry)["ZoneId"].should == $ZoneId
|
|
170
176
|
JSON.parse(entry)["SiteId"].should == $SiteId
|
|
171
|
-
#JSON.parse(entry)["ChannelId"].should == $ChannelId
|
|
172
177
|
JSON.parse(entry)["SizeOverride"].should == $SizeOverride
|
|
173
178
|
#JSON.parse(entry)["PublisherAccountId"].should == $PublisherAccountId
|
|
174
179
|
JSON.parse(entry)["ScriptBody"].should == $ScriptBody
|
|
175
180
|
#JSON.parse(entry)["Impressions"].should == $Impressions
|
|
176
181
|
JSON.parse(entry)["Percentage"].should == $Percentage
|
|
177
182
|
#JSON.parse(entry)["DistributionType"].should == $DistributionType
|
|
178
|
-
JSON.parse(entry)["AdFormatId"].should == $AdFormatId
|
|
183
|
+
#JSON.parse(entry)["AdFormatId"].should == $AdFormatId
|
|
179
184
|
JSON.parse(entry)["Creative"]["IsActive"].should == $IsActive
|
|
180
185
|
JSON.parse(entry)["Creative"]["Alt"].should == $Alt
|
|
181
186
|
JSON.parse(entry)["IsDeleted"].should == $IsDeleted
|
|
@@ -188,25 +193,25 @@ describe "Creative Flight API" do
|
|
|
188
193
|
JSON.parse(response.body)["Creative"]["Title"].should == $Title
|
|
189
194
|
JSON.parse(response.body)["Creative"]["Url"].should == $Url
|
|
190
195
|
JSON.parse(response.body)["Creative"]["Body"].should == $Body
|
|
191
|
-
JSON.parse(response.body)["Creative"]["
|
|
196
|
+
JSON.parse(response.body)["Creative"]["AdvertiserId"].should == $AdvertiserId
|
|
192
197
|
#JSON.parse(response.body)["CampaignId"].should == $CampaignId
|
|
193
198
|
#JSON.parse(response.body)["FlightId"].should == $FlightId
|
|
194
199
|
#JSON.parse(response.body)["MapId"].should == $MapId
|
|
195
200
|
JSON.parse(response.body)["Creative"]["AdTypeId"].should == $AdTypeId
|
|
196
201
|
#JSON.parse(response.body)["ZoneId"].should == $ZoneId
|
|
197
202
|
JSON.parse(response.body)["SiteId"].should == $SiteId
|
|
198
|
-
#JSON.parse(response.body)["ChannelId"].should == $ChannelId
|
|
199
203
|
JSON.parse(response.body)["SizeOverride"].should == $SizeOverride
|
|
200
204
|
#JSON.parse(response.body)["PublisherAccountId"].should == $PublisherAccountId
|
|
201
205
|
JSON.parse(response.body)["ScriptBody"].should == $ScriptBody
|
|
202
206
|
#JSON.parse(response.body)["Impressions"].should == $Impressions
|
|
203
207
|
JSON.parse(response.body)["Percentage"].should == $Percentage
|
|
204
208
|
#JSON.parse(response.body)["DistributionType"].should == $DistributionType
|
|
205
|
-
JSON.parse(response.body)["AdFormatId"].should == $AdFormatId
|
|
209
|
+
#JSON.parse(response.body)["AdFormatId"].should == $AdFormatId
|
|
206
210
|
JSON.parse(response.body)["Creative"]["IsActive"].should == $IsActive
|
|
207
211
|
JSON.parse(response.body)["Creative"]["Alt"].should == $Alt
|
|
208
212
|
JSON.parse(response.body)["IsDeleted"].should == $IsDeleted
|
|
209
213
|
JSON.parse(response.body)["Creative"]["IsSync"].should == $IsSync
|
|
214
|
+
@@creativeId = JSON.parse(response.body)["Creative"]["Id"]
|
|
210
215
|
end
|
|
211
216
|
|
|
212
217
|
it "should update a specific creative" do
|
|
@@ -216,21 +221,20 @@ describe "Creative Flight API" do
|
|
|
216
221
|
'ImageName' => $ImageName,
|
|
217
222
|
'Url' => $Url,
|
|
218
223
|
'Body' => $Body,
|
|
219
|
-
'
|
|
224
|
+
'AdvertiserId' => $AdvertiserId,
|
|
220
225
|
'CampaignId' => $CampaignId,
|
|
221
226
|
'FlightId' => $FlightId,
|
|
222
|
-
|
|
227
|
+
'MapId' => $MapId,
|
|
223
228
|
'AdTypeId' => $AdTypeId,
|
|
224
|
-
|
|
229
|
+
'ZoneId' => $ZoneId,
|
|
225
230
|
'SiteId' => $SiteId,
|
|
226
|
-
'ChannelId' => $ChannelId,
|
|
227
231
|
'SizeOverride' => $SizeOverride,
|
|
228
232
|
'Iframe' => $Iframe,
|
|
229
233
|
'PublisherAccountId' => $PublisherAccountId,
|
|
230
234
|
'ScriptBody' => $ScriptBody,
|
|
231
235
|
'Impressions' => $Impressions,
|
|
232
236
|
'Percentage' => $Percentage,
|
|
233
|
-
|
|
237
|
+
'DistributionType' => $DistributionType,
|
|
234
238
|
'AdFormatId' => $AdFormatId,
|
|
235
239
|
'IsActive' => $IsActive,
|
|
236
240
|
'Alt' => $Alt,
|
|
@@ -238,29 +242,28 @@ describe "Creative Flight API" do
|
|
|
238
242
|
'IsSync' => $IsSync
|
|
239
243
|
}
|
|
240
244
|
response = @@map.update(update_creative)
|
|
241
|
-
#
|
|
242
|
-
#
|
|
243
|
-
#
|
|
244
|
-
#
|
|
245
|
-
#
|
|
246
|
-
#
|
|
247
|
-
#
|
|
248
|
-
#
|
|
249
|
-
#
|
|
250
|
-
#
|
|
251
|
-
#
|
|
252
|
-
#
|
|
253
|
-
#
|
|
254
|
-
#
|
|
255
|
-
#
|
|
256
|
-
#
|
|
257
|
-
#
|
|
258
|
-
#
|
|
259
|
-
#
|
|
260
|
-
#
|
|
261
|
-
#
|
|
262
|
-
#
|
|
263
|
-
# JSON.parse(response.body)["Creative"]["IsSync"].should == $IsSync
|
|
245
|
+
#JSON.parse(response.body)["Id"].should == $creative_id
|
|
246
|
+
#JSON.parse(response.body)["Creative"]["Title"].should == $Title
|
|
247
|
+
#JSON.parse(response.body)["Creative"]["Url"].should == $Url
|
|
248
|
+
#JSON.parse(response.body)["Creative"]["Body"].should == $Body
|
|
249
|
+
#JSON.parse(response.body)["Creative"]["AdvertiserId"].should == $AdvertiserId
|
|
250
|
+
#JSON.parse(response.body)["CampaignId"].should == $CampaignId
|
|
251
|
+
#JSON.parse(response.body)["FlightId"].should == $FlightId
|
|
252
|
+
#JSON.parse(response.body)["MapId"].should == $MapId
|
|
253
|
+
#JSON.parse(response.body)["Creative"]["AdTypeId"].should == $AdTypeId
|
|
254
|
+
#JSON.parse(response.body)["ZoneId"].should == $ZoneId
|
|
255
|
+
#JSON.parse(response.body)["SiteId"].should == $SiteId
|
|
256
|
+
#JSON.parse(response.body)["SizeOverride"].should == $SizeOverride
|
|
257
|
+
#JSON.parse(response.body)["PublisherAccountId"].should == $PublisherAccountId
|
|
258
|
+
#JSON.parse(response.body)["ScriptBody"].should == $ScriptBody
|
|
259
|
+
#JSON.parse(response.body)["Impressions"].should == $Impressions
|
|
260
|
+
#JSON.parse(response.body)["Percentage"].should == $Percentage
|
|
261
|
+
#JSON.parse(response.body)["DistributionType"].should == $DistributionType
|
|
262
|
+
#JSON.parse(response.body)["AdFormatId"].should == $AdFormatId
|
|
263
|
+
#JSON.parse(response.body)["Creative"]["IsActive"].should == $IsActive
|
|
264
|
+
#JSON.parse(response.body)["Creative"]["Alt"].should == $Alt
|
|
265
|
+
#JSON.parse(response.body)["IsDeleted"].should == $IsDeleted
|
|
266
|
+
#JSON.parse(response.body)["Creative"]["IsSync"].should == $IsSync
|
|
264
267
|
end
|
|
265
268
|
|
|
266
269
|
it "should delete the creatives after creating it" do
|
|
@@ -272,7 +275,6 @@ describe "Creative Flight API" do
|
|
|
272
275
|
map = {
|
|
273
276
|
'CampaignId' => '123',
|
|
274
277
|
'FlightId' => $FlightId,
|
|
275
|
-
'ChannelId' => $ChannelId,
|
|
276
278
|
'SizeOverride' => $SizeOverride,
|
|
277
279
|
'Iframe' => $Iframe,
|
|
278
280
|
'PublisherAccountId' => $PublisherAccountId,
|
|
@@ -285,14 +287,13 @@ describe "Creative Flight API" do
|
|
|
285
287
|
'IsDeleted' => $IsDeleted
|
|
286
288
|
}
|
|
287
289
|
response = @@map.create(map)
|
|
288
|
-
true.should == !response.body.scan(/
|
|
290
|
+
true.should == !response.body.scan(/Exception/).empty?
|
|
289
291
|
end
|
|
290
292
|
|
|
291
293
|
it "should not create a map when flightId is forbidden" do
|
|
292
294
|
map = {
|
|
293
295
|
'CampaignId' => $CampaignId,
|
|
294
296
|
'FlightId' => '123',
|
|
295
|
-
'ChannelId' => $ChannelId,
|
|
296
297
|
'SizeOverride' => $SizeOverride,
|
|
297
298
|
'Iframe' => $Iframe,
|
|
298
299
|
'PublisherAccountId' => $PublisherAccountId,
|
|
@@ -305,14 +306,13 @@ describe "Creative Flight API" do
|
|
|
305
306
|
'IsDeleted' => $IsDeleted
|
|
306
307
|
}
|
|
307
308
|
response = @@map.create(map)
|
|
308
|
-
true.should == !response.body.scan(/
|
|
309
|
+
true.should == !response.body.scan(/Exception/).empty?
|
|
309
310
|
end
|
|
310
|
-
|
|
311
|
-
it "should
|
|
311
|
+
|
|
312
|
+
it "should create a map when there is no creative object, just id" do
|
|
312
313
|
map = {
|
|
313
314
|
'CampaignId' => $CampaignId,
|
|
314
315
|
'FlightId' => $FlightId,
|
|
315
|
-
'ChannelId' => '123',
|
|
316
316
|
'SizeOverride' => $SizeOverride,
|
|
317
317
|
'Iframe' => $Iframe,
|
|
318
318
|
'PublisherAccountId' => $PublisherAccountId,
|
|
@@ -322,10 +322,36 @@ describe "Creative Flight API" do
|
|
|
322
322
|
'Percentage' => $Percentage,
|
|
323
323
|
'AdFormatId' => $AdFormatId,
|
|
324
324
|
'IsActive' => $IsActive,
|
|
325
|
-
'IsDeleted' => $IsDeleted
|
|
325
|
+
'IsDeleted' => $IsDeleted,
|
|
326
|
+
'Creative' => {
|
|
327
|
+
'Id' => @@creativeId
|
|
328
|
+
}
|
|
326
329
|
}
|
|
327
330
|
response = @@map.create(map)
|
|
328
|
-
|
|
331
|
+
false.should == !response.body.scan(/Exception/).empty?
|
|
329
332
|
end
|
|
330
|
-
|
|
331
|
-
|
|
333
|
+
|
|
334
|
+
it "should not create a map when there is no creative object, just id that belongs to a different advertiser" do
|
|
335
|
+
map = {
|
|
336
|
+
'CampaignId' => $CampaignId,
|
|
337
|
+
'FlightId' => $FlightId,
|
|
338
|
+
'SizeOverride' => $SizeOverride,
|
|
339
|
+
'Iframe' => $Iframe,
|
|
340
|
+
'PublisherAccountId' => $PublisherAccountId,
|
|
341
|
+
'ScriptBody' => $ScriptBody,
|
|
342
|
+
'Impressions' => $Impressions,
|
|
343
|
+
'SiteId' => $SiteId,
|
|
344
|
+
'Percentage' => $Percentage,
|
|
345
|
+
'AdFormatId' => $AdFormatId,
|
|
346
|
+
'IsActive' => $IsActive,
|
|
347
|
+
'IsDeleted' => $IsDeleted,
|
|
348
|
+
'Creative' => {
|
|
349
|
+
'Id' => 1234
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
response = @@map.create(map)
|
|
353
|
+
true.should == !response.body.scan(/Exception/).empty?
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
end
|