thrillcall-api 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +10 -0
- data/.gitignore +10 -0
- data/.rspec +4 -0
- data/.rvmrc +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +58 -0
- data/README.md +1141 -0
- data/Rakefile +2 -0
- data/autotest/discover.rb +1 -0
- data/docs/API.html +1262 -0
- data/docs/API.md +1024 -0
- data/docs/README.html +1382 -0
- data/docs/WRAPPER.html +182 -0
- data/docs/WRAPPER.md +115 -0
- data/lib/thrillcall-api.rb +76 -0
- data/lib/thrillcall-api/exceptions.rb +7 -0
- data/lib/thrillcall-api/result.rb +142 -0
- data/lib/thrillcall-api/version.rb +3 -0
- data/script/convert_readme.rb +119 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/thrillcall-api/thrillcall-api_spec.rb +477 -0
- data/thrillcall-api.gemspec +34 -0
- metadata +201 -0
@@ -0,0 +1,119 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# USAGE:
|
4
|
+
# INSTALL FIRST! : You must have the Python Pygments lib installed
|
5
|
+
# before this will run. See : http://pygments.org/docs/installation/
|
6
|
+
#
|
7
|
+
# Install with:
|
8
|
+
#
|
9
|
+
# sudo easy_install Pygments
|
10
|
+
#
|
11
|
+
# Run me with : 'bundle install' and 'cd script' and 'bundle exec ruby convert_readme.rb'
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler'
|
15
|
+
Bundler.setup
|
16
|
+
Bundler.require(:development)
|
17
|
+
|
18
|
+
css = "
|
19
|
+
<style type='text/css'>
|
20
|
+
.highlight .hll { background-color: #ffffcc }
|
21
|
+
.highlight { background: #dddddd; }
|
22
|
+
.highlight .c { color: #408080; font-style: italic } /* Comment */
|
23
|
+
.highlight .err { border: 1px solid #FF0000 } /* Error */
|
24
|
+
.highlight .k { color: #008000; font-weight: bold } /* Keyword */
|
25
|
+
.highlight .o { color: #666666 } /* Operator */
|
26
|
+
.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
27
|
+
.highlight .cp { color: #BC7A00 } /* Comment.Preproc */
|
28
|
+
.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
|
29
|
+
.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
|
30
|
+
.highlight .gd { color: #A00000 } /* Generic.Deleted */
|
31
|
+
.highlight .ge { font-style: italic } /* Generic.Emph */
|
32
|
+
.highlight .gr { color: #FF0000 } /* Generic.Error */
|
33
|
+
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
34
|
+
.highlight .gi { color: #00A000 } /* Generic.Inserted */
|
35
|
+
.highlight .go { color: #808080 } /* Generic.Output */
|
36
|
+
.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
37
|
+
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
38
|
+
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
39
|
+
.highlight .gt { color: #0040D0 } /* Generic.Traceback */
|
40
|
+
.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
|
41
|
+
.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
|
42
|
+
.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
|
43
|
+
.highlight .kp { color: #008000 } /* Keyword.Pseudo */
|
44
|
+
.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
|
45
|
+
.highlight .kt { color: #B00040 } /* Keyword.Type */
|
46
|
+
.highlight .m { color: #666666 } /* Literal.Number */
|
47
|
+
.highlight .s { color: #BA2121 } /* Literal.String */
|
48
|
+
.highlight .na { color: #7D9029 } /* Name.Attribute */
|
49
|
+
.highlight .nb { color: #008000 } /* Name.Builtin */
|
50
|
+
.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
51
|
+
.highlight .no { color: #880000 } /* Name.Constant */
|
52
|
+
.highlight .nd { color: #AA22FF } /* Name.Decorator */
|
53
|
+
.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
|
54
|
+
.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
55
|
+
.highlight .nf { color: #0000FF } /* Name.Function */
|
56
|
+
.highlight .nl { color: #A0A000 } /* Name.Label */
|
57
|
+
.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
58
|
+
.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
|
59
|
+
.highlight .nv { color: #19177C } /* Name.Variable */
|
60
|
+
.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
61
|
+
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
|
62
|
+
.highlight .mf { color: #666666 } /* Literal.Number.Float */
|
63
|
+
.highlight .mh { color: #666666 } /* Literal.Number.Hex */
|
64
|
+
.highlight .mi { color: #666666 } /* Literal.Number.Integer */
|
65
|
+
.highlight .mo { color: #666666 } /* Literal.Number.Oct */
|
66
|
+
.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
|
67
|
+
.highlight .sc { color: #BA2121 } /* Literal.String.Char */
|
68
|
+
.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
|
69
|
+
.highlight .s2 { color: #BA2121 } /* Literal.String.Double */
|
70
|
+
.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
71
|
+
.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
|
72
|
+
.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
73
|
+
.highlight .sx { color: #008000 } /* Literal.String.Other */
|
74
|
+
.highlight .sr { color: #BB6688 } /* Literal.String.Regex */
|
75
|
+
.highlight .s1 { color: #BA2121 } /* Literal.String.Single */
|
76
|
+
.highlight .ss { color: #19177C } /* Literal.String.Symbol */
|
77
|
+
.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
|
78
|
+
.highlight .vc { color: #19177C } /* Name.Variable.Class */
|
79
|
+
.highlight .vg { color: #19177C } /* Name.Variable.Global */
|
80
|
+
.highlight .vi { color: #19177C } /* Name.Variable.Instance */
|
81
|
+
.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
|
82
|
+
</style>
|
83
|
+
"
|
84
|
+
|
85
|
+
puts "Combining API.md and WRAPPER.md"
|
86
|
+
|
87
|
+
api = File.open(File.expand_path("../../docs/API.md", __FILE__)).read
|
88
|
+
wrapper = File.open(File.expand_path("../../docs/WRAPPER.md", __FILE__)).read
|
89
|
+
combined = wrapper + "\n\n" + api
|
90
|
+
|
91
|
+
File.open(File.expand_path("../../README.md", __FILE__),"w+") { |f|
|
92
|
+
f.write(combined)
|
93
|
+
}
|
94
|
+
|
95
|
+
convert = {
|
96
|
+
"API" => api,
|
97
|
+
"WRAPPER" => wrapper,
|
98
|
+
"README" => combined
|
99
|
+
}
|
100
|
+
|
101
|
+
convert.each do |name, doc|
|
102
|
+
rc = Redcarpet.new(doc, :fenced_code, :space_header, :gh_blockcode)
|
103
|
+
|
104
|
+
rc = css + rc.to_html
|
105
|
+
|
106
|
+
doc = Nokogiri::HTML.fragment(rc)
|
107
|
+
|
108
|
+
doc.search('pre').each do |node|
|
109
|
+
next unless lang = node['lang']
|
110
|
+
html = Albino.colorize(node.inner_text, lang)
|
111
|
+
node.replace(html)
|
112
|
+
end
|
113
|
+
|
114
|
+
File.open(File.expand_path("../../docs/#{name}.html", __FILE__),"w+") { |f|
|
115
|
+
f.write(doc.to_s)
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
puts "Done"
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
5
|
+
# in spec/support/ and its subdirectories.
|
6
|
+
#Dir["spec/support/**/*.rb"].each {|f| require f}
|
7
|
+
|
8
|
+
RSpec.configure do |c|
|
9
|
+
c.fail_fast = true
|
10
|
+
# ....
|
11
|
+
end
|
@@ -0,0 +1,477 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'thrillcall-api'
|
3
|
+
require 'ap'
|
4
|
+
require 'faker'
|
5
|
+
|
6
|
+
# Set to one of :development, :staging, :production
|
7
|
+
TEST_ENV = :development
|
8
|
+
|
9
|
+
# For the environment specified in TEST_ENV, you must have set a few system environment variables.
|
10
|
+
# For example, if your TEST_ENV is :development, you need:
|
11
|
+
# TC_DEVELOPMENT_API_KEY : your API key
|
12
|
+
# TC_DEVELOPMENT_LOGIN : the login (email address) for the test account if testing the Person endpoint
|
13
|
+
# TC_DEVELOPMENT_PASSWORD : the password for the test account if testing the Person endpoint
|
14
|
+
|
15
|
+
# Place something like this in your bash_login script:
|
16
|
+
# export TC_DEVELOPMENT_API_KEY="1234567890abcdef"
|
17
|
+
# export TC_DEVELOPMENT_LOGIN="some_account@thrillcall.com"
|
18
|
+
# export TC_DEVELOPMENT_PASSWORD="some_password"
|
19
|
+
|
20
|
+
# You should not have to edit anything below this line.
|
21
|
+
#####################################################################
|
22
|
+
|
23
|
+
env_prefix = TEST_ENV.to_s.upcase
|
24
|
+
|
25
|
+
TEST_KEY = ENV["TC_#{env_prefix}_API_KEY"]
|
26
|
+
PERSON_LOGIN = ENV["TC_#{env_prefix}_LOGIN"]
|
27
|
+
PERSON_PASSWORD = ENV["TC_#{env_prefix}_PASSWORD"]
|
28
|
+
|
29
|
+
HOST = "http://localhost:3000/api/" if TEST_ENV == :development
|
30
|
+
HOST = "https://secure-zion.thrillcall.com:443/api/" if TEST_ENV == :staging # SSL!
|
31
|
+
HOST = "https://api.thrillcall.com:443/api/" if TEST_ENV == :production # SSL!
|
32
|
+
|
33
|
+
LIMIT = 14
|
34
|
+
TINY_LIMIT = 3
|
35
|
+
|
36
|
+
POSTAL_CODE = "94108"
|
37
|
+
|
38
|
+
PERSON_CREATE_FIRSTNAME = Faker::Name.first_name
|
39
|
+
PERSON_CREATE_EMAIL = Faker::Internet.email
|
40
|
+
PERSON_CREATE_PASSWORD = Faker::Lorem.words(2).join('')
|
41
|
+
PERSON_CREATE_POSTALCODE = POSTAL_CODE
|
42
|
+
|
43
|
+
FLUSH_CACHE = true # false
|
44
|
+
|
45
|
+
describe "ThrillcallAPI" do
|
46
|
+
|
47
|
+
def setup_key
|
48
|
+
@tc = ThrillcallAPI.new(TEST_KEY, :base_url => HOST)
|
49
|
+
|
50
|
+
@tc_permissions = @tc.api_key.permissions
|
51
|
+
@tc_permissions.length
|
52
|
+
@tc_permissions = @tc_permissions.data
|
53
|
+
|
54
|
+
# api_auth permission allows you to access the Person endpoints.
|
55
|
+
# api_read permission allows you to access all other endpoints.
|
56
|
+
end
|
57
|
+
|
58
|
+
def has_permission?(p=:api_read)
|
59
|
+
(@tc_permissions.include? p.to_s)
|
60
|
+
end
|
61
|
+
|
62
|
+
def mark_pending_if_no_permission(p = :api_read)
|
63
|
+
unless has_permission? p
|
64
|
+
pending "TEST_KEY permissions #{@tc_permissions} do not include #{p}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def setup_read
|
69
|
+
if has_permission? :api_read
|
70
|
+
day_buffer = 0
|
71
|
+
range = 365
|
72
|
+
|
73
|
+
@min_date = (Time.now - 60*60*24*(range+day_buffer)).to_date.to_s
|
74
|
+
@max_date = (Time.now - 60*60*24*day_buffer).to_date.to_s
|
75
|
+
|
76
|
+
event_finder = {
|
77
|
+
:must_have_tickets => true,
|
78
|
+
:postalcode => POSTAL_CODE,
|
79
|
+
:radius => 10,
|
80
|
+
:limit => TINY_LIMIT
|
81
|
+
}
|
82
|
+
|
83
|
+
events = @tc.events(event_finder)
|
84
|
+
events.length
|
85
|
+
|
86
|
+
@event = events.first
|
87
|
+
@event_id = @event["id"]
|
88
|
+
|
89
|
+
@ticket = @tc.event(@event_id).tickets.first
|
90
|
+
@artist = @tc.event(@event_id).artists.first
|
91
|
+
@venue = @tc.event(@event_id).venue
|
92
|
+
|
93
|
+
@artist_id = @artist["id"]
|
94
|
+
@artist_norm_name = @artist["name"]
|
95
|
+
|
96
|
+
@venue_id = @venue["id"]
|
97
|
+
@venue_norm_name = @venue["name"]
|
98
|
+
@venue_zip = @venue["postalcode"]
|
99
|
+
|
100
|
+
@event_zip = @venue_zip
|
101
|
+
|
102
|
+
@ticket_id = @ticket["id"]
|
103
|
+
|
104
|
+
@lat = @venue["latitude"]
|
105
|
+
@long = @venue["longitude"]
|
106
|
+
|
107
|
+
@genre_id = @artist["primary_genre_id"]
|
108
|
+
@metro_area_id = @venue["metro_area_id"]
|
109
|
+
|
110
|
+
puts "Using Thrillcall objects:"
|
111
|
+
puts "Event: #{@event_id}"
|
112
|
+
puts "Artist: #{@artist_id} #{@artist_norm_name}"
|
113
|
+
puts "Venue: #{@venue_id} #{@venue_norm_name}"
|
114
|
+
puts "Ticket: #{@ticket_id}"
|
115
|
+
puts "Metro: #{@metro_area_id}"
|
116
|
+
puts "Genre: #{@genre_id}"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Flush memcache results
|
121
|
+
before :all do
|
122
|
+
if TEST_ENV == :development
|
123
|
+
if FLUSH_CACHE
|
124
|
+
fork do
|
125
|
+
exec "echo 'flush_all' | nc localhost 11211"
|
126
|
+
end
|
127
|
+
|
128
|
+
Process.wait
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it "the test suite should be able to retrieve the environment variables correctly" do
|
134
|
+
TEST_KEY.should_not be_nil
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should initialize properly with faraday" do
|
138
|
+
tc = nil
|
139
|
+
lambda { tc = ThrillcallAPI.new(TEST_KEY, :base_url => HOST) }.should_not raise_error
|
140
|
+
puts tc.inspect
|
141
|
+
tc.conn.class.should == Faraday::Connection
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should be able to retrieve the permissions for the api key" do
|
145
|
+
tc = ThrillcallAPI.new(TEST_KEY, :base_url => HOST)
|
146
|
+
tc_permissions = tc.api_key.permissions
|
147
|
+
tc_permissions.length
|
148
|
+
tc_permissions = tc_permissions.data
|
149
|
+
tc_permissions.class.should == Array
|
150
|
+
end
|
151
|
+
|
152
|
+
context "an authenticated user with get permission" do
|
153
|
+
|
154
|
+
before :all do
|
155
|
+
setup_key
|
156
|
+
setup_read
|
157
|
+
end
|
158
|
+
|
159
|
+
before :each do
|
160
|
+
mark_pending_if_no_permission(:api_read)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should be able to handle a method with a block used on fresh data" do
|
164
|
+
e = @tc.events(:limit => LIMIT)
|
165
|
+
c = 0
|
166
|
+
e.each do |ev|
|
167
|
+
c += 1
|
168
|
+
end
|
169
|
+
c.should == e.length
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should be able to make multiple requests after initialization" do
|
173
|
+
a = @tc.artist(@artist_id)
|
174
|
+
b = @tc.events(:limit => LIMIT)
|
175
|
+
a["id"].should == @artist_id
|
176
|
+
b.length.should == LIMIT
|
177
|
+
end
|
178
|
+
|
179
|
+
# This is the only remaining limitation of the wrapper
|
180
|
+
it "should not be able to make an additional request after using the data from an intermediate request" do
|
181
|
+
a = @tc.artist(@artist_id)
|
182
|
+
a["id"].should == @artist_id
|
183
|
+
lambda { e = a.events }.should raise_error
|
184
|
+
end
|
185
|
+
|
186
|
+
# This behavior cannot be iterated due to the previous limitation
|
187
|
+
it "should be able to build a nested request from a preexisting intermediate unfetched request" do
|
188
|
+
venue_intermediate_request = @tc.event(@event_id)
|
189
|
+
v = venue_intermediate_request.venue
|
190
|
+
v["id"].should == @venue_id
|
191
|
+
end
|
192
|
+
|
193
|
+
it "should fetch data when responding to an array or a hash method" do
|
194
|
+
a = @tc.artists(:limit => LIMIT)
|
195
|
+
r = a.pop
|
196
|
+
r["id"].should_not be_nil
|
197
|
+
|
198
|
+
e = @tc.artist(r["id"])
|
199
|
+
(e.has_key? "genre_tags").should be_true
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should raise NoMethodError when given a method the data doesn't respond to after fetched" do
|
203
|
+
a = @tc.artists(:limit => LIMIT)
|
204
|
+
a.length.should == LIMIT
|
205
|
+
lambda { a.bazooka }.should raise_error NoMethodError
|
206
|
+
end
|
207
|
+
|
208
|
+
it "should not return filtered attributes" do
|
209
|
+
v = @tc.venue(@venue_id)
|
210
|
+
v["alt_city"].should be_nil
|
211
|
+
end
|
212
|
+
|
213
|
+
context "accessing the event endpoint" do
|
214
|
+
it "should get a list of events" do
|
215
|
+
# This call sets up the Result object and returns an instance of ThrillcallAPI
|
216
|
+
e = @tc.events(:limit => LIMIT)
|
217
|
+
|
218
|
+
# This call executes fetch_data because @data responds_to .length
|
219
|
+
e.length.should == LIMIT
|
220
|
+
|
221
|
+
# Now e behaves as a hash
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should get a specific event" do
|
225
|
+
e = @tc.event(@event_id)
|
226
|
+
e["id"].should == @event_id
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should get tickets for a specific event" do
|
230
|
+
e = @tc.event(@event_id).tickets
|
231
|
+
# FIXME: "product" here should be "ticket"
|
232
|
+
e.first["id"].should == @ticket_id
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should get artists for a specific event" do
|
236
|
+
e = @tc.event(@event_id).artists
|
237
|
+
e.first["id"].should == @artist_id
|
238
|
+
end
|
239
|
+
|
240
|
+
it "should get the venue for a specific event" do
|
241
|
+
e = @tc.event(@event_id).venue
|
242
|
+
e["id"].should == @venue_id
|
243
|
+
end
|
244
|
+
|
245
|
+
it "should verify the behavior of the min_date param" do
|
246
|
+
e = @tc.events(:limit => TINY_LIMIT, :min_date => @min_date)
|
247
|
+
e.length.should == TINY_LIMIT
|
248
|
+
e.each do |ev|
|
249
|
+
DateTime.parse(ev["start_date"]).should >= DateTime.parse(@min_date)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should verify the behavior of the max_date param" do
|
254
|
+
e = @tc.events(:limit => TINY_LIMIT, :min_date => @min_date, :max_date => @max_date)
|
255
|
+
e.length.should == TINY_LIMIT
|
256
|
+
e.each do |ev|
|
257
|
+
DateTime.parse(ev["start_date"]).should < (DateTime.parse(@max_date) + 1)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should verify the behavior of the page param" do
|
262
|
+
offset = 1
|
263
|
+
e = @tc.events(:limit => TINY_LIMIT * 2)
|
264
|
+
o = @tc.events(:limit => TINY_LIMIT, :page => 1)
|
265
|
+
e.length.should == TINY_LIMIT * 2
|
266
|
+
o.length.should == TINY_LIMIT
|
267
|
+
(e - o).length.should == TINY_LIMIT
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should verify the behavior of the confirmed_events_only param" do
|
271
|
+
e = @tc.events(:limit => LIMIT, :confirmed_events_only => true)
|
272
|
+
e.each do |ev|
|
273
|
+
ev["unconfirmed_location"].should == 0
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
it "should verify the behavior of the must_have_tickets param" do
|
278
|
+
e = @tc.events(:limit => TINY_LIMIT, :must_have_tickets => true)
|
279
|
+
e.length.should == TINY_LIMIT
|
280
|
+
e.each do |ev|
|
281
|
+
t = @tc.event(ev["id"]).tickets
|
282
|
+
t.length.should_not == 0
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
it "should verify the behavior of the lat long params" do
|
287
|
+
e = @tc.events(:limit => TINY_LIMIT, :lat => @lat, :long => @long, :radius => 0)
|
288
|
+
e.each do |ev|
|
289
|
+
(@tc.event(ev["id"]).venue["latitude"].to_f - @lat).should <= 1.0
|
290
|
+
(@tc.event(ev["id"]).venue["longitude"].to_f - @long).should <= 1.0
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
it "should verify the behavior of the postalcode param" do
|
295
|
+
pending "Need to be able to access the ZipCodes table externally from Rails"
|
296
|
+
e = @tc.events(:limit => TINY_LIMIT, :postalcode => POSTAL_CODE)
|
297
|
+
e.length.should <= TINY_LIMIT
|
298
|
+
e.each do |ev|
|
299
|
+
ev["venue_id"].should_not be_nil
|
300
|
+
v = @tc.venue(ev["venue_id"])
|
301
|
+
|
302
|
+
v["postalcode"].should == POSTAL_CODE
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should verify the behavior of the radius param" do
|
307
|
+
pending
|
308
|
+
end
|
309
|
+
|
310
|
+
#############
|
311
|
+
# Can't verify the behavior below without more access to data on the Rails side
|
312
|
+
it "should verify the behavior of the ticket_type param" do
|
313
|
+
pending "Need to be able to access the Merchants table externally from Rails"
|
314
|
+
e = @tc.events(:limit => TINY_LIMIT, :must_have_tickets => true)
|
315
|
+
e.length.should == TINY_LIMIT
|
316
|
+
e.each do |ev|
|
317
|
+
t = @tc.event(ev["id"]).tickets(:ticket_type => "primary")
|
318
|
+
t.each do |ticket|
|
319
|
+
ticket
|
320
|
+
end
|
321
|
+
t.length.should be_empty
|
322
|
+
end
|
323
|
+
end
|
324
|
+
#################
|
325
|
+
|
326
|
+
end
|
327
|
+
|
328
|
+
context "accessing the artist endpoint" do
|
329
|
+
it "should get a list of artists" do
|
330
|
+
a = @tc.artists(:limit => LIMIT)
|
331
|
+
a.length.should == LIMIT
|
332
|
+
end
|
333
|
+
|
334
|
+
it "should get a specific artist" do
|
335
|
+
a = @tc.artist(@artist_id)
|
336
|
+
a["id"].should == @artist_id
|
337
|
+
end
|
338
|
+
|
339
|
+
it "should get a list of events for a specific artist" do
|
340
|
+
a = @tc.artist(@artist_id).events
|
341
|
+
found = false
|
342
|
+
a.each do |event|
|
343
|
+
found = found || (event["id"] == @event_id)
|
344
|
+
break if found
|
345
|
+
end
|
346
|
+
found.should be_true
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
context "accessing the venue endpoint" do
|
351
|
+
it "should get a list of venues" do
|
352
|
+
v = @tc.venues(:limit => LIMIT)
|
353
|
+
v.length.should == LIMIT
|
354
|
+
end
|
355
|
+
|
356
|
+
it "should get a specific venue" do
|
357
|
+
v = @tc.venue(@venue_id)
|
358
|
+
v["id"].should == @venue_id
|
359
|
+
end
|
360
|
+
|
361
|
+
it "should directly return a postalcode" do
|
362
|
+
v = @tc.venue(@venue_id)
|
363
|
+
v["postalcode"].should == @venue_zip
|
364
|
+
end
|
365
|
+
|
366
|
+
it "should return a list of events for a specific venue" do
|
367
|
+
e = @tc.venue(@venue_id).events
|
368
|
+
e.length.should > 0
|
369
|
+
end
|
370
|
+
|
371
|
+
end
|
372
|
+
|
373
|
+
context "accessing the ticket endpoint" do
|
374
|
+
it "should get a list of tickets" do
|
375
|
+
p = @tc.tickets(:limit => LIMIT)
|
376
|
+
p.length.should == LIMIT
|
377
|
+
end
|
378
|
+
|
379
|
+
it "should get a specific ticket" do
|
380
|
+
p = @tc.ticket(@ticket_id)
|
381
|
+
p["id"].should == @ticket_id
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
context "searching for an object with a term" do
|
386
|
+
it "should find the right artists" do
|
387
|
+
a = @tc.search.artists(@artist_norm_name)
|
388
|
+
found = false
|
389
|
+
a.each do |artist|
|
390
|
+
if artist["id"] == @artist_id
|
391
|
+
found = true
|
392
|
+
break
|
393
|
+
end
|
394
|
+
end
|
395
|
+
found.should be_true
|
396
|
+
end
|
397
|
+
|
398
|
+
it "should find the right venues" do
|
399
|
+
v = @tc.search.venues(@venue_norm_name)
|
400
|
+
found = false
|
401
|
+
v.each do |venue|
|
402
|
+
if venue["id"] == @venue_id
|
403
|
+
found = true
|
404
|
+
break
|
405
|
+
end
|
406
|
+
end
|
407
|
+
found.should be_true
|
408
|
+
end
|
409
|
+
|
410
|
+
end
|
411
|
+
|
412
|
+
context "accessing the metro area endpoint" do
|
413
|
+
it "should get a specific metro area" do
|
414
|
+
m = @tc.metro_area(@metro_area_id)
|
415
|
+
m["id"].should == @metro_area_id
|
416
|
+
end
|
417
|
+
|
418
|
+
it "should get a list of metro areas" do
|
419
|
+
m = @tc.metro_areas(:limit => LIMIT)
|
420
|
+
m.length.should == LIMIT
|
421
|
+
end
|
422
|
+
|
423
|
+
it "should get a list of events for a specific metro" do
|
424
|
+
e = @tc.metro_area(@metro_area_id).events
|
425
|
+
cur_venue_id = e.first["venue_id"]
|
426
|
+
|
427
|
+
@tc.venue(cur_venue_id)["metro_area_id"].should == @metro_area_id
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
context "accesing the genre endpoint" do
|
432
|
+
it "should get a specific genre" do
|
433
|
+
g = @tc.genre(@genre_id)
|
434
|
+
g["id"].should == @genre_id
|
435
|
+
end
|
436
|
+
|
437
|
+
it "should get a list of genres" do
|
438
|
+
g = @tc.genres(:limit => LIMIT)
|
439
|
+
g.length.should == LIMIT
|
440
|
+
end
|
441
|
+
|
442
|
+
it "should get a list of artists for a specific genre" do
|
443
|
+
g = @tc.genre(@genre_id).artists
|
444
|
+
g.first["primary_genre_id"].should == @genre_id
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
end
|
449
|
+
|
450
|
+
context "an authenticated user with api_auth permission" do
|
451
|
+
before :all do
|
452
|
+
setup_key
|
453
|
+
end
|
454
|
+
|
455
|
+
before :each do
|
456
|
+
mark_pending_if_no_permission(:api_auth)
|
457
|
+
end
|
458
|
+
|
459
|
+
context "accesing the person endpoint" do
|
460
|
+
it "should be able to login a person" do
|
461
|
+
# Don't forget to change the credentials in your environment variables
|
462
|
+
p = @tc.person.signin.post(:login => PERSON_LOGIN, :password => PERSON_PASSWORD)
|
463
|
+
p["login"].should == PERSON_LOGIN
|
464
|
+
end
|
465
|
+
|
466
|
+
it "should be able to create a person" do
|
467
|
+
p = @tc.person.signup.post(:first_name => PERSON_CREATE_FIRSTNAME,
|
468
|
+
:email => PERSON_CREATE_EMAIL,
|
469
|
+
:password => PERSON_CREATE_PASSWORD,
|
470
|
+
:postalcode => PERSON_CREATE_POSTALCODE,
|
471
|
+
:test => true)
|
472
|
+
p["login"].should == PERSON_CREATE_EMAIL
|
473
|
+
end
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
end
|