aws-sdb 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ Spec::Rake::SpecTask.new
7
7
  gem_spec = Gem::Specification.new do |s|
8
8
  s.name = "aws-sdb"
9
9
  s.rubyforge_project = s.name
10
- s.version = "0.3.0"
10
+ s.version = "0.3.1"
11
11
  s.platform = Gem::Platform::RUBY
12
12
  s.has_rdoc = true
13
13
  s.extra_rdoc_files = ["README", "LICENSE"]
@@ -137,7 +137,7 @@ module AwsSdb
137
137
  uri = URI.parse(url)
138
138
  @logger.debug("#{url}") if @logger
139
139
  response =
140
- Net::HTTP.new(uri.host, uri.port).send_request(method, url)
140
+ Net::HTTP.new(uri.host, uri.port).send_request(method, uri.request_uri)
141
141
  @logger.debug("#{response.code}\n#{response.body}") if @logger
142
142
  raise(ConnectionError.new(response)) unless (200..400).include?(
143
143
  response.code.to_i
@@ -13,65 +13,23 @@ describe Service, "when creating a new domain" do
13
13
  before(:all) do
14
14
  @service = AwsSdb::Service.new
15
15
  @domain = "test-#{UUID.random_create.to_s}"
16
- # domains = @service.list_domains[0]
17
- # domains.each do |d|
18
- # @service.delete_domain(d) if d =~ /^test/
19
- # end
16
+ domains = @service.list_domains[0]
17
+ domains.each do |d|
18
+ @service.delete_domain(d) if d =~ /^test/
19
+ end
20
20
  end
21
21
 
22
22
  after(:all) do
23
- # @service.delete_domain(@domain)
24
- end
25
-
26
- def stub_success
27
- resp = mock(Net::HTTPResponse)
28
- resp.stub!(:code).and_return("200")
29
- resp.stub!(:body).and_return(
30
- """
31
- <CreateDomainResponse>
32
- <ResponseStatus>
33
- <StatusCode>Success</StatusCode>
34
- <RequestID>#{UUID.random_create.to_s}</RequestID>
35
- <BoxUsage>0.001</BoxUsage>
36
- </ResponseStatus>
37
- </CreateDomainResponse>
38
- """
39
- )
40
- http = mock(Net::HTTP)
41
- http.stub!(:send_request).and_return(resp)
42
- Net::HTTP.stub!(:new).and_return(http)
43
- end
44
-
45
- def stub_error(code, type, message)
46
- resp = mock(Net::HTTPResponse)
47
- resp.stub!(:code).and_return(code)
48
- resp.stub!(:body).and_return(
49
- """
50
- <Response>
51
- <Errors>
52
- <Error>
53
- <Code>#{type}</Code>
54
- <Message>#{message}</Message>
55
- </Error>
56
- </Errors>
57
- <RequestID>#{UUID.random_create.to_s}</RequestID>
58
- </Response>
59
- """
60
- )
61
- http = mock(Net::HTTP)
62
- http.stub!(:send_request).and_return(resp)
63
- Net::HTTP.stub!(:new).and_return(http)
23
+ @service.delete_domain(@domain)
64
24
  end
65
25
 
66
26
  it "should not raise an error if a valid new domain name is given" do
67
- stub_success
68
27
  lambda {
69
28
  @service.create_domain("test-#{UUID.random_create.to_s}")
70
29
  }.should_not raise_error
71
30
  end
72
31
 
73
32
  it "should not raise an error if the domain name already exists" do
74
- stub_success
75
33
  domain = "test-#{UUID.random_create.to_s}"
76
34
  lambda {
77
35
  @service.create_domain(domain)
@@ -80,52 +38,27 @@ describe Service, "when creating a new domain" do
80
38
  end
81
39
 
82
40
  it "should raise an error if an a nil or '' domain name is given" do
83
- stub_error(
84
- 400,
85
- :InvalidParameterValue,
86
- "Value () for parameter DomainName is invalid."
87
- )
88
41
  lambda {
89
42
  @service.create_domain('')
90
43
  }.should raise_error(InvalidParameterValueError)
91
44
  lambda {
92
45
  @service.create_domain(nil)
93
46
  }.should raise_error(InvalidParameterValueError)
94
- stub_error(
95
- 400,
96
- :InvalidParameterValue,
97
- "Value ( ) for parameter DomainName is invalid."
98
- )
99
47
  lambda {
100
48
  @service.create_domain(' ')
101
49
  }.should raise_error(InvalidParameterValueError)
102
50
  end
103
51
 
104
52
  it "should raise an error if the domain name length is < 3 or > 255" do
105
- stub_error(
106
- 400,
107
- :InvalidParameterValue,
108
- "Value (xx) for parameter DomainName is invalid."
109
- )
110
53
  lambda {
111
54
  @service.create_domain('xx')
112
55
  }.should raise_error(InvalidParameterValueError)
113
- stub_error(
114
- 400,
115
- :InvalidParameterValue,
116
- "Value (#{:x.to_s*256}) for parameter DomainName is invalid."
117
- )
118
56
  lambda {
119
57
  @service.create_domain('x'*256)
120
58
  }.should raise_error(InvalidParameterValueError)
121
59
  end
122
60
 
123
61
  it "should only accept domain names with a-z, A-Z, 0-9, '_', '-', and '.' " do
124
- stub_error(
125
- 400,
126
- :InvalidParameterValue,
127
- "Value (@$^*()) for parameter DomainName is invalid."
128
- )
129
62
  lambda {
130
63
  @service.create_domain('@$^*()')
131
64
  }.should raise_error(InvalidParameterValueError)
@@ -144,41 +77,21 @@ describe Service, "when listing domains" do
144
77
  before(:all) do
145
78
  @service = AwsSdb::Service.new
146
79
  @domain = "test-#{UUID.random_create.to_s}"
147
- # @service.list_domains[0].each do |d|
148
- # @service.delete_domain(d) if d =~ /^test/
149
- # end
150
- # @service.create_domain(@domain)
80
+ @service.list_domains[0].each do |d|
81
+ @service.delete_domain(d) if d =~ /^test/
82
+ end
83
+ @service.create_domain(@domain)
151
84
  end
152
85
 
153
86
  after(:all) do
154
- # @service.delete_domain(@domain)
87
+ @service.delete_domain(@domain)
155
88
  end
156
89
 
157
90
  it "should return a complete list" do
158
- resp = mock(Net::HTTPResponse)
159
- resp.stub!(:code).and_return("200")
160
- resp.stub!(:body).and_return(
161
- """
162
- <ListDomainsResponse>
163
- <ResponseStatus>
164
- <StatusCode>Success</StatusCode>
165
- <RequestID>#{UUID.random_create.to_s}</RequestID>
166
- <BoxUsage/>
167
- </ResponseStatus>
168
- <DomainName>#{@domain}</DomainName>
169
- </ListDomainsResponse>
170
- """
171
- )
172
- http = mock(Net::HTTP)
173
- http.stub!(:send_request).and_return(resp)
174
- Net::HTTP.stub!(:new).and_return(http)
175
-
176
91
  result = nil
177
92
  lambda { result = @service.list_domains[0] }.should_not raise_error
178
93
  result.should_not be_nil
179
94
  result.should_not be_empty
180
- result.size.should == 1
181
- result.should_not be_nil
182
95
  result.include?(@domain).should == true
183
96
  end
184
97
  end
@@ -187,42 +100,21 @@ describe Service, "when deleting domains" do
187
100
  before(:all) do
188
101
  @service = AwsSdb::Service.new
189
102
  @domain = "test-#{UUID.random_create.to_s}"
190
- # @service.list_domains[0].each do |d|
191
- # @service.delete_domain(d) if d =~ /^test/
192
- # end
193
- # @service.create_domain(@domain)
103
+ @service.list_domains[0].each do |d|
104
+ @service.delete_domain(d) if d =~ /^test/
105
+ end
106
+ @service.create_domain(@domain)
194
107
  end
195
108
 
196
109
  after do
197
- # @service.delete_domain(@domain)
198
- end
199
-
200
- def stub_success
201
- resp = mock(Net::HTTPResponse)
202
- resp.stub!(:code).and_return("200")
203
- resp.stub!(:body).and_return(
204
- """
205
- <DeleteDomainResponse>
206
- <ResponseStatus>
207
- <StatusCode>Success</StatusCode>
208
- <RequestID>#{UUID.random_create.to_s}</RequestID>
209
- <BoxUsage/>
210
- </ResponseStatus>
211
- </DeleteDomainResponse>
212
- """
213
- )
214
- http = mock(Net::HTTP)
215
- http.stub!(:send_request).and_return(resp)
216
- Net::HTTP.stub!(:new).and_return(http)
110
+ @service.delete_domain(@domain)
217
111
  end
218
112
 
219
113
  it "should be able to delete an existing domain" do
220
- stub_success
221
114
  lambda { @service.delete_domain(@domain) }.should_not raise_error
222
115
  end
223
116
 
224
117
  it "should not raise an error trying to delete a non-existing domain" do
225
- stub_success
226
118
  lambda {
227
119
  @service.delete_domain(UUID.random_create.to_s)
228
120
  }.should_not raise_error
@@ -233,10 +125,10 @@ describe Service, "when managing items" do
233
125
  before(:all) do
234
126
  @service = AwsSdb::Service.new
235
127
  @domain = "test-#{UUID.random_create.to_s}"
236
- # @service.list_domains[0].each do |d|
237
- # @service.delete_domain(d) if d =~ /^test/
238
- # end
239
- # @service.create_domain(@domain)
128
+ @service.list_domains[0].each do |d|
129
+ @service.delete_domain(d) if d =~ /^test/
130
+ end
131
+ @service.create_domain(@domain)
240
132
  @item = "test-#{UUID.random_create.to_s}"
241
133
  @attributes = {
242
134
  :question => 'What is the answer?',
@@ -245,118 +137,16 @@ describe Service, "when managing items" do
245
137
  end
246
138
 
247
139
  after(:all) do
248
- # @service.delete_domain(@domain)
249
- end
250
-
251
- def stub_put
252
- resp = mock(Net::HTTPResponse)
253
- resp.stub!(:code).and_return("200")
254
- resp.stub!(:body).and_return(
255
- """
256
- <PutAttributesResponse>
257
- <ResponseStatus><StatusCode>Success</StatusCode>
258
- <RequestID>#{UUID.random_create.to_s}</RequestID>
259
- <BoxUsage/>
260
- </ResponseStatus>
261
- </PutAttributesResponse>
262
- """
263
- )
264
- http = mock(Net::HTTP)
265
- http.stub!(:send_request).and_return(resp)
266
- Net::HTTP.stub!(:new).and_return(http)
267
- end
268
-
269
- def stub_get
270
- resp = mock(Net::HTTPResponse)
271
- resp.stub!(:code).and_return("200")
272
- resp.stub!(:body).and_return(
273
- """
274
- <GetAttributesResponse>
275
- <ResponseStatus>
276
- <StatusCode>Success</StatusCode>
277
- <RequestID>#{UUID.random_create.to_s}</RequestID>
278
- <BoxUsage/>
279
- </ResponseStatus>
280
- <Attribute>
281
- <Name>question</Name>
282
- <Value>What is the answer?</Value>
283
- </Attribute>
284
- <Attribute>
285
- <Name>answer</Name>
286
- <Value>true</Value>
287
- </Attribute>
288
- <Attribute>
289
- <Name>answer</Name>
290
- <Value>testing123</Value>
291
- </Attribute>
292
- <Attribute>
293
- <Name>answer</Name>
294
- <Value>4.2</Value>
295
- </Attribute>
296
- <Attribute>
297
- <Name>answer</Name>
298
- <Value>42</Value>
299
- </Attribute>
300
- <Attribute>
301
- <Name>answer</Name>
302
- <Value>420</Value>
303
- </Attribute>
304
- </GetAttributesResponse>
305
- """
306
- )
307
- http = mock(Net::HTTP)
308
- http.stub!(:send_request).and_return(resp)
309
- Net::HTTP.stub!(:new).and_return(http)
310
- end
311
-
312
- def stub_query
313
- resp = mock(Net::HTTPResponse)
314
- resp.stub!(:code).and_return("200")
315
- resp.stub!(:body).and_return(
316
- """
317
- <QueryResponse>
318
- <ResponseStatus>
319
- <StatusCode>Success</StatusCode>
320
- <RequestID>#{UUID.random_create.to_s}</RequestID>
321
- <BoxUsage/>
322
- </ResponseStatus>
323
- <ItemName>#{@item}</ItemName>
324
- </QueryResponse>
325
- """
326
- )
327
- http = mock(Net::HTTP)
328
- http.stub!(:send_request).and_return(resp)
329
- Net::HTTP.stub!(:new).and_return(http)
330
- end
331
-
332
- def stub_delete
333
- resp = mock(Net::HTTPResponse)
334
- resp.stub!(:code).and_return("200")
335
- resp.stub!(:body).and_return(
336
- """
337
- <DeleteAttributesResponse>
338
- <ResponseStatus>
339
- <StatusCode>Success</StatusCode>
340
- <RequestID>#{UUID.random_create.to_s}</RequestID>
341
- <BoxUsage/>
342
- </ResponseStatus>
343
- </DeleteAttributesResponse>
344
- """
345
- )
346
- http = mock(Net::HTTP)
347
- http.stub!(:send_request).and_return(resp)
348
- Net::HTTP.stub!(:new).and_return(http)
140
+ @service.delete_domain(@domain)
349
141
  end
350
142
 
351
143
  it "should be able to put attributes" do
352
- stub_put
353
144
  lambda {
354
145
  @service.put_attributes(@domain, @item, @attributes)
355
146
  }.should_not raise_error
356
147
  end
357
148
 
358
149
  it "should be able to get attributes" do
359
- stub_get
360
150
  result = nil
361
151
  lambda {
362
152
  result = @service.get_attributes(@domain, @item)
@@ -370,7 +160,6 @@ describe Service, "when managing items" do
370
160
  end
371
161
 
372
162
  it "should be able to query" do
373
- stub_query
374
163
  result = nil
375
164
  lambda {
376
165
  result = @service.query(@domain, "[ 'answer' = '42' ]")[0]
@@ -382,7 +171,6 @@ describe Service, "when managing items" do
382
171
  end
383
172
 
384
173
  it "should be able to delete attributes" do
385
- stub_delete
386
174
  lambda {
387
175
  @service.delete_attributes(@domain, @item)
388
176
  }.should_not raise_error
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Dysinger