sklik-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,40 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ def register_uri(name, uri_full)
4
+ uri = URI.parse(uri_full)
5
+ unless File.exists?("./test/fixtures/uri_#{name}.fake")
6
+ pp "downloading new fixture from #{uri_full}"
7
+ system "curl -s -i -G -d \"#{uri.query}\" #{uri.host}:#{uri.port}#{uri.path} > ./test/fixtures/uri_#{name}.fake"
8
+ end
9
+ FakeWeb.register_uri(:get, "#{uri_full}", :response => "./test/fixtures/uri_#{name}.fake")
10
+ #p "added #{@count_uries} url to fake web"
11
+ end
12
+
13
+ def register_uri_post(name, uri_full)
14
+ uri = URI.parse(uri_full)
15
+ if File.exists?("./test/fixtures_post_body/#{name}.txt")
16
+ unless File.exists?("./test/fixtures/#{name}.fake")
17
+ pp "downloading new fixture from POST #{uri_full}"
18
+ system "curl -s -d \"@test/fixtures_post_body/post_body_#{name}.txt\" #{uri.host}:#{uri.port}#{uri.path} > ./test/fixtures/uri_#{name}.fake"
19
+ end
20
+ body = ""
21
+ File.open("./test/fixtures/uri_#{name}.fake", "r:UTF-8") do |fo|
22
+ while( line = fo.gets) do
23
+ body += line
24
+ end
25
+ end
26
+ FakeWeb.register_uri(:post, "#{uri_full}", :body => body)
27
+ else
28
+ puts "YOU NEED TO CREATE FILE: test/fixtures_post_body/post_body_#{name}.txt which will contain POST body"
29
+ end
30
+ #p "added #{@count_uries} url to fake web"
31
+ end
32
+
33
+
34
+ #reports
35
+ #register_uri("foreman_report", "http://127.0.0.1:8877/report/foreman_report/adwords/ataxo/6170748009/1072676132/ALL_TIME")
36
+
37
+ #register_uri_post("refinery_relations_ataxo", "http://refinery.stage.internal.ataxo.com/relations/ataxo")
38
+
39
+ FakeWeb.allow_net_connect = true
40
+ p "FakeWeb registered and set to allow net connection: #{FakeWeb.allow_net_connect?}"
@@ -0,0 +1,22 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'fakeweb'
4
+
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'test/unit'
13
+ require 'turn'
14
+ require 'shoulda-context'
15
+
16
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
17
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
18
+ require 'sklik-api'
19
+ require './test/fake_web'
20
+
21
+ class Test::Unit::TestCase
22
+ end
@@ -0,0 +1,103 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'helper'
3
+ class CampaignTest < Test::Unit::TestCase
4
+ context "Campaign" do
5
+
6
+ setup do
7
+ @test_campaign_hash = {
8
+ :name => "hustokrutě megapřísně - #{Time.now.strftime("%Y.%m.%d %H:%M:%S")}",
9
+ :status => :running,
10
+ :cpc => 3.5,
11
+ :budget => 15.0,
12
+ :customer_id => 192495,
13
+
14
+ :network_setting => {
15
+ :content => true,
16
+ :search => true
17
+ },
18
+
19
+ :ad_groups => [
20
+ {
21
+ :name => "my adgroup name",
22
+ :ads => [
23
+ {
24
+ :headline => "Super headline",
25
+ :description1 => "Trying to do ",
26
+ :description2 => "best description ever",
27
+ :display_url => "bartas.cz",
28
+ :url => "http://www.bartas.cz"
29
+ }
30
+ ],
31
+ :keywords => [
32
+ "\"some funny keyword\"",
33
+ "[myphrase keyword]",
34
+ "mybroad keyword for me",
35
+ "test of diarcritics âô"
36
+ ]
37
+ },
38
+ {
39
+ :name => "hustokrutě mazácká adgroupa",
40
+ :ads => [
41
+ {
42
+ :headline => "Super bombasitcký",
43
+ :description1 => "Trying to do ",
44
+ :description2 => "best description ever",
45
+ :display_url => "bartas.cz",
46
+ :url => "http://www.bartas.cz?utm_adgroup=4"
47
+ }
48
+ ],
49
+ :keywords => [
50
+ "\"some funny keyword\"",
51
+ "[myphrase keyword]",
52
+ "mybroad keyword for me",
53
+ "test of diarcritics âô",
54
+ "dokonalý kw"
55
+ ]
56
+ }
57
+ ]
58
+ }
59
+ @campaign = SklikApi::Campaign.new(@test_campaign_hash)
60
+ end
61
+
62
+ should "be initialized" do
63
+ assert_nothing_raised do
64
+ SklikApi::Campaign.new(@test_campaign_hash)
65
+ end
66
+ end
67
+
68
+ should "be found" do
69
+ assert_equal SklikApi::Campaign.find(:campaign_id => 390265).size, 1
70
+ assert SklikApi::Campaign.find(:customer_id => 192495).size > 0
71
+ end
72
+
73
+ should "have hash stored inside" do
74
+ assert_equal @campaign.args, @test_campaign_hash
75
+ end
76
+
77
+ should "return empty array when asking for not known campaign" do
78
+ assert_equal SklikApi::Campaign.find(:campaign_id => 123456789).size , 0
79
+ end
80
+
81
+ context "create" do
82
+ setup do
83
+ @campaign = SklikApi::Campaign.new(@test_campaign_hash)
84
+ @campaign.save
85
+ end
86
+
87
+ should "get current status" do
88
+ assert_equal @campaign.args[:status], :running
89
+ end
90
+
91
+ should "be created with right parameters" do
92
+ campaigns = SklikApi::Campaign.find(:customer_id => @campaign.args[:customer_id], :campaign_id => @campaign.args[:campaign_id])
93
+ campaign_hash = campaigns.first.to_hash
94
+ assert_equal campaign_hash[:campaign_id], @campaign.args[:campaign_id], "campaign id should be same"
95
+ assert_equal campaign_hash[:status], :running , "campaign should be running"
96
+ assert_equal campaign_hash[:budget].to_f, @test_campaign_hash[:budget].to_f, "budgets should be same"
97
+ assert_equal campaign_hash[:name], @test_campaign_hash[:name], "campaign name should be same"
98
+ assert_equal campaign_hash[:ad_groups].size, @test_campaign_hash[:ad_groups].size, "campaign ad_groups should have same count"
99
+ end
100
+ end
101
+
102
+ end
103
+ end
metadata ADDED
@@ -0,0 +1,236 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sklik-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ondrej Bartas
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: &70117586460560 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70117586460560
25
+ - !ruby/object:Gem::Dependency
26
+ name: unicode
27
+ requirement: &70117586459920 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.4.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70117586459920
36
+ - !ruby/object:Gem::Dependency
37
+ name: text
38
+ requirement: &70117586459340 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.2.0
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70117586459340
47
+ - !ruby/object:Gem::Dependency
48
+ name: i18n
49
+ requirement: &70117586458800 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.6.0
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70117586458800
58
+ - !ruby/object:Gem::Dependency
59
+ name: activesupport
60
+ requirement: &70117586458220 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 3.1.0
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *70117586458220
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: &70117586457640 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70117586457640
80
+ - !ruby/object:Gem::Dependency
81
+ name: shoulda-context
82
+ requirement: &70117586457040 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70117586457040
91
+ - !ruby/object:Gem::Dependency
92
+ name: turn
93
+ requirement: &70117586456380 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 0.8.2
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70117586456380
102
+ - !ruby/object:Gem::Dependency
103
+ name: minitest
104
+ requirement: &70117586455640 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70117586455640
113
+ - !ruby/object:Gem::Dependency
114
+ name: ansi
115
+ requirement: &70117586489340 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ~>
119
+ - !ruby/object:Gem::Version
120
+ version: 1.2.5
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *70117586489340
124
+ - !ruby/object:Gem::Dependency
125
+ name: jeweler
126
+ requirement: &70117586488740 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 1.8.3
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: *70117586488740
135
+ - !ruby/object:Gem::Dependency
136
+ name: fakeweb
137
+ requirement: &70117586487980 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: *70117586487980
146
+ - !ruby/object:Gem::Dependency
147
+ name: thin
148
+ requirement: &70117586487380 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: *70117586487380
157
+ - !ruby/object:Gem::Dependency
158
+ name: shotgun
159
+ requirement: &70117586486800 !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ type: :development
166
+ prerelease: false
167
+ version_requirements: *70117586486800
168
+ - !ruby/object:Gem::Dependency
169
+ name: rcov
170
+ requirement: &70117586486220 !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - =
174
+ - !ruby/object:Gem::Version
175
+ version: 0.9.10
176
+ type: :development
177
+ prerelease: false
178
+ version_requirements: *70117586486220
179
+ description: Sklik advertising PPC api for creating campaigns and updating them when
180
+ they runs
181
+ email: ondrej@bartas.cz
182
+ executables: []
183
+ extensions: []
184
+ extra_rdoc_files:
185
+ - LICENSE.txt
186
+ - README.markdown
187
+ files:
188
+ - .document
189
+ - Gemfile
190
+ - LICENSE.txt
191
+ - README.markdown
192
+ - Rakefile
193
+ - VERSION
194
+ - config/access.rb.example
195
+ - lib/sklik-api.rb
196
+ - lib/sklik-api/access.rb
197
+ - lib/sklik-api/campaign.rb
198
+ - lib/sklik-api/campaign_parts/adgroup.rb
199
+ - lib/sklik-api/campaign_parts/adtext.rb
200
+ - lib/sklik-api/campaign_parts/keyword.rb
201
+ - lib/sklik-api/connection.rb
202
+ - lib/sklik-api/sklik_object.rb
203
+ - lib/sklik-api/xmlrpc_setup.rb
204
+ - sklik-api.gemspec
205
+ - test/fake_web.rb
206
+ - test/helper.rb
207
+ - test/unit/campaign.rb
208
+ homepage: http://github.com/ondrejbartas/sklik-api
209
+ licenses:
210
+ - MIT
211
+ post_install_message:
212
+ rdoc_options: []
213
+ require_paths:
214
+ - lib
215
+ required_ruby_version: !ruby/object:Gem::Requirement
216
+ none: false
217
+ requirements:
218
+ - - ! '>='
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ segments:
222
+ - 0
223
+ hash: -2654800062329418774
224
+ required_rubygems_version: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ! '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ requirements: []
231
+ rubyforge_project:
232
+ rubygems_version: 1.8.10
233
+ signing_key:
234
+ specification_version: 3
235
+ summary: Sklik advertising PPC api for creating campaigns
236
+ test_files: []