redaranj-right_aws 1.10.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,299 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestSdb < Test::Unit::TestCase
4
+
5
+ DOMAIN_NAME = 'right_sdb_awesome_test_domain'
6
+
7
+ class Client < RightAws::ActiveSdb::Base
8
+ set_domain_name DOMAIN_NAME
9
+ end
10
+
11
+ def setup
12
+ STDOUT.sync = true
13
+ @clients = [
14
+ { 'name' => 'Bush', 'country' => 'USA', 'gender' => 'male', 'expiration' => '2009', 'post' => 'president' },
15
+ { 'name' => 'Putin', 'country' => 'Russia', 'gender' => 'male', 'expiration' => '2008', 'post' => 'president' },
16
+ { 'name' => 'Medvedev', 'country' => 'Russia', 'gender' => 'male', 'expiration' => '2012', 'post' => 'president' },
17
+ { 'name' => 'Mary', 'country' => 'USA', 'gender' => 'female', 'hobby' => ['patchwork', 'bundle jumping'] },
18
+ { 'name' => 'Sandy', 'country' => 'Russia', 'gender' => 'female', 'hobby' => ['flowers', 'cats', 'cooking'] },
19
+ { 'name' => 'Mary', 'country' => 'Russia', 'gender' => 'female', 'hobby' => ['flowers', 'cats', 'cooking'] } ]
20
+ RightAws::ActiveSdb.establish_connection(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
21
+ end
22
+
23
+ SDB_DELAY = 3
24
+
25
+ def wait(delay, msg='')
26
+ print " waiting #{delay} seconds: #{msg}"
27
+ while delay>0 do
28
+ delay -= 1
29
+ print '.'
30
+ sleep 1
31
+ end
32
+ puts
33
+ end
34
+
35
+ #---------------------------
36
+ # Rightscale::SdbInterface
37
+ #---------------------------
38
+
39
+ def test_00_delete_domain
40
+ assert RightAws::ActiveSdb.delete_domain(DOMAIN_NAME)
41
+ wait SDB_DELAY, 'test 00: after domain deletion'
42
+ end
43
+
44
+ def test_01_create_domain
45
+ # check that domain does not exist
46
+ assert !RightAws::ActiveSdb.domains.include?(DOMAIN_NAME)
47
+ # create domain
48
+ assert Client.create_domain
49
+ wait SDB_DELAY, 'test 01: after domain creation'
50
+ # check that we have received new domain from Amazin
51
+ assert RightAws::ActiveSdb.domains.include?(DOMAIN_NAME)
52
+ end
53
+
54
+ def test_02_create_items
55
+ # check that DB is empty
56
+ clients = Client.find(:all)
57
+ assert clients.blank?
58
+ # put some clients there
59
+ @clients.each do |client|
60
+ Client.create client
61
+ end
62
+ wait SDB_DELAY, 'test 02: after clients creation'
63
+ # check that DB has all the clients we just putted
64
+ clients = Client.find(:all)
65
+ assert_equal @clients.size, clients.size
66
+ end
67
+
68
+ def test_03_create_and_save_new_item
69
+ # get the db
70
+ old_clients = Client.find(:all)
71
+ # create new client
72
+ new_client = Client.new('country' => 'unknown', 'dummy' => 'yes')
73
+ wait SDB_DELAY, 'test 03: after in-memory client creation'
74
+ # get the db and ensure we created the client in-memory only
75
+ assert_equal old_clients.size, Client.find(:all).size
76
+ # put the client to DB
77
+ new_client.save
78
+ wait SDB_DELAY, 'test 03: after in-memory client saving'
79
+ # get all db again and compare to original list
80
+ assert_equal old_clients.size+1, Client.find(:all).size
81
+ end
82
+
83
+ def test_04_find_all
84
+ # retrieve all the DB, make sure all are in place
85
+ clients = Client.find(:all)
86
+ ids = clients.map{|client| client.id }[0..1]
87
+ assert_equal @clients.size + 1, clients.size
88
+ # retrieve all presidents (must find: Bush, Putin, Medvedev)
89
+ assert_equal 3, Client.find(:all, :conditions => ["[?=?]",'post','president']).size
90
+ # retrieve all russian presidents (must find: Putin, Medvedev)
91
+ assert_equal 2, Client.find(:all, :conditions => ["['post'=?] intersection ['country'=?]",'president', 'Russia']).size
92
+ # retrieve all russian presidents and all women (must find: Putin, Medvedev, 2 Maries and Sandy)
93
+ assert_equal 5, Client.find(:all, :conditions => ["['post'=?] intersection ['country'=?] union ['gender'=?]",'president', 'Russia','female']).size
94
+ # find all rissian presidents Bushes
95
+ assert_equal 0, Client.find(:all, :conditions => ["['post'=?] intersection ['country'=?] intersection ['name'=?]",'president', 'Russia','Bush']).size
96
+ # --- find by ids
97
+ # must find 1 rec (by rec id) and return it
98
+ assert_equal ids.first, Client.find(ids.first).id
99
+ # must find 1 rec (by one item array) and return an array
100
+ assert_equal ids.first, Client.find([ids.first]).first.id
101
+ # must find 2 recs (by a list of comma separated ids) and return an array
102
+ assert_equal ids.size, Client.find(*ids).size
103
+ # must find 2 recs (by an array of ids) and return an array
104
+ assert_equal ids.size, Client.find(ids).size
105
+ ids << 'dummy_id'
106
+ # must raise an error when getting unexistent record
107
+ assert_raise(RightAws::ActiveSdb::ActiveSdbError) do
108
+ Client.find(ids)
109
+ end
110
+ # find one record by unknown id
111
+ assert_raise(RightAws::ActiveSdb::ActiveSdbError) do
112
+ Client.find('dummy_id')
113
+ end
114
+ end
115
+
116
+ def test_05_find_first
117
+ # find any record
118
+ assert Client.find(:first)
119
+ # find any president
120
+ assert Client.find(:first, :conditions => ["[?=?]",'post','president'])
121
+ # find any rissian president
122
+ assert Client.find(:first, :conditions => ["['post'=?] intersection ['country'=?]",'president','Russia'])
123
+ # find any unexistent record
124
+ assert_nil Client.find(:first, :conditions => ["['post'=?] intersection ['country'=?]",'president','Rwanda'])
125
+ end
126
+
127
+ def test_06_find_all_by_helpers
128
+ # find all Bushes
129
+ assert_equal 1, Client.find_all_by_name('Bush').size
130
+ # find all russian presidents
131
+ assert_equal 2, Client.find_all_by_post_and_country('president','Russia').size
132
+ # find all women in USA that love flowers
133
+ assert_equal 2, Client.find_all_by_gender_and_country_and_hobby('female','Russia','flowers').size
134
+ # order and auto_load:
135
+ clients = Client.find_all_by_post('president', :order => 'name', :auto_load => true)
136
+ assert_equal [['Bush'], ['Medvedev'], ['Putin']], clients.map{|c| c['name']}
137
+ clients = Client.find_all_by_post('president', :order => 'name desc', :auto_load => true)
138
+ assert_equal [['Putin'], ['Medvedev'], ['Bush']], clients.map{|c| c['name']}
139
+ end
140
+
141
+ def test_07_find_by_helpers
142
+ # find mr Bush
143
+ assert Client.find_by_name('Bush')
144
+ # find any russian president
145
+ assert Client.find_by_post_and_country('president','Russia')
146
+ # find Mary in Russia that loves flowers
147
+ # order and auto_load:
148
+ assert_equal ['Bush'], Client.find_by_post('president', :order => 'name', :auto_load => true)['name']
149
+ assert_equal ['Putin'], Client.find_by_post('president', :order => 'name desc', :auto_load => true)['name']
150
+ end
151
+
152
+ def test_08_reload
153
+ putin = Client.find_by_name('Putin')
154
+ # attributes must be empty until reload (except 'id' field)
155
+ assert_nil putin['name']
156
+ assert_nil putin['country']
157
+ assert_nil putin['gender']
158
+ assert_nil putin['expiration']
159
+ assert_nil putin['post']
160
+ # reloaded attributes must have 5 items + id
161
+ putin.reload
162
+ assert_equal 6, putin.attributes.size
163
+ # check all attributes
164
+ assert_equal ['Putin'], putin['name']
165
+ assert_equal ['Russia'], putin['country']
166
+ assert_equal ['male'], putin['gender']
167
+ assert_equal ['2008'], putin['expiration']
168
+ assert_equal ['president'], putin['post']
169
+ end
170
+
171
+ def test_09_select
172
+ # select all records
173
+ assert_equal 7, Client.select(:all).size
174
+ # LIMIT
175
+ # 1 record
176
+ assert Client.select(:first).is_a?(Client)
177
+ # select 2 recs
178
+ assert_equal 2, Client.select(:all, :limit => 2).size
179
+ # ORDER
180
+ # select all recs ordered by 'expration' (must find only recs where 'expration' attribute presents)
181
+ result = Client.select(:all, :order => 'expiration')
182
+ assert_equal 3, result.size
183
+ assert_equal ['2008', '2009', '2012'], result.map{ |c| c['expiration'] }.flatten
184
+ # desc order
185
+ result = Client.select(:all, :order => 'expiration desc')
186
+ assert_equal ['2012', '2009', '2008'], result.map{ |c| c['expiration'] }.flatten
187
+ # CONDITIONS
188
+ result = Client.select(:all, :conditions => ["expiration >= ?", 2009], :order => 'name')
189
+ assert_equal ['Bush', 'Medvedev'], result.map{ |c| c['name'] }.flatten
190
+ result = Client.select(:all, :conditions => "hobby='flowers' AND gender='female'", :order => 'name')
191
+ assert_equal ['Mary', 'Sandy'], result.map{ |c| c['name'] }.flatten
192
+ # SELECT
193
+ result = Client.select(:all, :select => 'hobby', :conditions => "gender IS NOT NULL", :order => 'name')
194
+ hobbies = result.map{|c| c['hobby']}
195
+ # must return all recs
196
+ assert_equal 6, result.size
197
+ # but anly 3 of them have this field set
198
+ assert_equal 3, hobbies.compact.size
199
+ end
200
+
201
+ def test_10_select_by
202
+ assert_equal 2, Client.select_all_by_hobby('flowers').size
203
+ assert_equal 2, Client.select_all_by_hobby_and_country('flowers', 'Russia').size
204
+ assert_equal ['Putin'], Client.select_by_post_and_expiration('president','2008')['name']
205
+ end
206
+
207
+ def test_11_save_and_put
208
+ putin = Client.find_by_name('Putin')
209
+ putin.reload
210
+ putin['hobby'] = 'ski'
211
+ # SAVE method (replace values)
212
+ putin.save
213
+ wait SDB_DELAY, 'test 09: after saving'
214
+ # check that DB was updated with 'ski'
215
+ new_putin = Client.find_by_name('Putin')
216
+ new_putin.reload
217
+ assert ['ski'], new_putin['hobby']
218
+ # replace hobby
219
+ putin['hobby'] = 'dogs'
220
+ putin.save
221
+ wait SDB_DELAY, 'test 09: after saving'
222
+ # check that 'ski' in DB was replaced by 'dogs'
223
+ new_putin = Client.find_by_name('Putin')
224
+ new_putin.reload
225
+ assert ['dogs'], new_putin['hobby']
226
+ # PUT method (add values)
227
+ putin['hobby'] = 'ski'
228
+ putin.put
229
+ wait SDB_DELAY, 'test 09: after putting'
230
+ # check that 'ski' was added to 'dogs'
231
+ new_putin = Client.find_by_name('Putin')
232
+ new_putin.reload
233
+ assert ['dogs', 'ski'], new_putin['hobby'].sort
234
+ end
235
+
236
+ def test_12_save_and_put_attributes
237
+ putin = Client.find_by_name('Putin')
238
+ putin.reload
239
+ # SAVE method (replace values)
240
+ putin.save_attributes('language' => 'russian')
241
+ wait SDB_DELAY, 'test 10: after save_attributes'
242
+ # check that DB was updated with 'ski'
243
+ new_putin = Client.find_by_name('Putin')
244
+ new_putin.reload
245
+ assert ['russian'], new_putin['language']
246
+ # replace 'russian' by 'german'
247
+ putin.save_attributes('language' => 'german')
248
+ wait SDB_DELAY, 'test 10: after save_attributes'
249
+ # check that 'russian' in DB was replaced by 'german'
250
+ new_putin = Client.find_by_name('Putin')
251
+ new_putin.reload
252
+ assert ['german'], new_putin['language']
253
+ # PUT method (add values)
254
+ putin.put_attributes('language' => ['russian', 'english'])
255
+ wait SDB_DELAY, 'test 10: after put_attributes'
256
+ # now Putin must know all the languages
257
+ new_putin = Client.find_by_name('Putin')
258
+ new_putin.reload
259
+ assert ['english', 'german', 'russian'], new_putin['language'].sort
260
+ end
261
+
262
+ def test_13_delete
263
+ putin = Client.find_by_name('Putin')
264
+ putin.reload
265
+ # --- delete_values
266
+ # remove an unknown attribute
267
+ # should return an empty hash
268
+ assert_equal( {}, putin.delete_values('undefined_attribute' => 'ohoho'))
269
+ # remove 2 languages
270
+ lang_hash = {'language' => ['english', 'german']}
271
+ assert_equal lang_hash, putin.delete_values(lang_hash)
272
+ wait SDB_DELAY, 'test 11: after put_attributes'
273
+ # now Putin must know only russian lang
274
+ new_putin = Client.find_by_name('Putin')
275
+ new_putin.reload
276
+ assert ['russian'], new_putin['language'].sort
277
+ # --- delete_attributes
278
+ putin.delete_attributes('language', 'hobby')
279
+ wait SDB_DELAY, 'test 11: after delete_attributes'
280
+ # trash hoddy and langs
281
+ new_putin = Client.find_by_name('Putin')
282
+ new_putin.reload
283
+ assert_nil new_putin['language']
284
+ assert_nil new_putin['hobby']
285
+ # --- delete item
286
+ putin.delete
287
+ wait SDB_DELAY, 'test 11: after delete item'
288
+ assert_nil Client.find_by_name('Putin')
289
+ end
290
+
291
+ def test_14_delete_domain
292
+ assert Client.delete_domain
293
+ wait SDB_DELAY, 'test 12: after delete domain'
294
+ assert_raise(Rightscale::AwsError) do
295
+ Client.find :all
296
+ end
297
+ end
298
+
299
+ end
@@ -0,0 +1,3 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../../lib/right_aws'
3
+ require 'sdb/active_sdb'
@@ -0,0 +1,247 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestSdb < Test::Unit::TestCase
4
+
5
+ def setup
6
+ STDOUT.sync = true
7
+ @domain = 'right_sdb_awesome_test_domain'
8
+ @item = 'toys'
9
+ @attr = { 'Jon' => %w{beer car} }
10
+ # Interface instance
11
+ @sdb = Rightscale::SdbInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
12
+ end
13
+
14
+ SDB_DELAY = 2
15
+
16
+ def wait(delay, msg='')
17
+ print "waiting #{delay} seconds #{msg}"
18
+ while delay>0 do
19
+ delay -= 1
20
+ print '.'
21
+ sleep 1
22
+ end
23
+ puts
24
+ end
25
+
26
+ #---------------------------
27
+ # Rightscale::SdbInterface
28
+ #---------------------------
29
+
30
+ def test_00_delete_domain
31
+ # delete the domain to reset all the things
32
+ assert @sdb.delete_domain(@domain), 'delete_domain fail'
33
+ wait SDB_DELAY, 'after domain deletion'
34
+ end
35
+
36
+ def test_01_create_domain
37
+ # check that domain does not exist
38
+ assert !@sdb.list_domains[:domains].include?(@domain)
39
+ # create domain
40
+ assert @sdb.create_domain(@domain), 'create_domain fail'
41
+ wait SDB_DELAY, 'after domain creation'
42
+ # check that we have received new domain from Amazin
43
+ assert @sdb.list_domains[:domains].include?(@domain)
44
+ end
45
+
46
+ def test_02_put_attributes
47
+ # put attributes
48
+ assert @sdb.put_attributes(@domain, @item, @attr)
49
+ wait SDB_DELAY, 'after putting attributes'
50
+ end
51
+
52
+ def test_03_get_attributes
53
+ # get attributes
54
+ values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon'].to_a.sort
55
+ # compare to original list
56
+ assert_equal values, @attr['Jon'].sort
57
+ end
58
+
59
+ def test_04_add_attributes
60
+ # add new attribute
61
+ new_value = 'girls'
62
+ @sdb.put_attributes @domain, @item, {'Jon' => new_value}
63
+ wait SDB_DELAY, 'after putting attributes'
64
+ # get attributes ('girls' must be added to already existent attributes)
65
+ values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon'].to_a.sort
66
+ assert_equal values, (@attr['Jon'] << new_value).sort
67
+ end
68
+
69
+ def test_05_replace_attributes
70
+ # replace attributes
71
+ @sdb.put_attributes @domain, @item, {'Jon' => 'pub'}, :replace
72
+ wait SDB_DELAY, 'after replacing attributes'
73
+ # get attributes (all must be removed except of 'pub')
74
+ values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon']
75
+ assert_equal values, ['pub']
76
+ end
77
+
78
+ def test_06_delete_attribute
79
+ # add value 'girls' and 'vodka' to 'Jon'
80
+ @sdb.put_attributes @domain, @item, {'Jon' => ['girls','vodka']}
81
+ wait SDB_DELAY, 'after adding attributes'
82
+ # get attributes ('girls' and 'vodka' must be added 'pub')
83
+ values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon'].to_a.sort
84
+ assert_equal values, ['girls', 'pub', 'vodka']
85
+ # delete a single value 'girls' from attribute 'Jon'
86
+ @sdb.delete_attributes @domain, @item, 'Jon' => ['girls']
87
+ wait SDB_DELAY, 'after the deletion of attribute'
88
+ # get attributes ('girls' must be removed)
89
+ values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon']
90
+ assert_equal values, ['pub', 'vodka']
91
+ # delete all values from attribute 'Jon'
92
+ @sdb.delete_attributes @domain, @item, ['Jon']
93
+ wait SDB_DELAY, 'after the deletion of attributes'
94
+ # get attributes (values must be empty)
95
+ values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon']
96
+ assert_equal values, nil
97
+ end
98
+
99
+ def test_07_delete_item
100
+ @sdb.put_attributes @domain, @item, {'Volodya' => ['girls','vodka']}
101
+ wait SDB_DELAY, 'after adding attributes'
102
+ # get attributes ('girls' and 'vodka' must be there)
103
+ values = @sdb.get_attributes(@domain, @item)[:attributes]['Volodya'].to_a.sort
104
+ assert_equal values, ['girls', 'vodka']
105
+ # delete an item
106
+ @sdb.delete_attributes @domain, @item
107
+ # get attributes (values must be empty)
108
+ values = @sdb.get_attributes(@domain, @item)[:attributes]['Volodya']
109
+ assert_equal values, nil
110
+ end
111
+
112
+ def test_08_query
113
+ # add some values for query
114
+ @sdb.put_attributes @domain, @item, {'Jon' => ['girls','vodka']}
115
+ wait SDB_DELAY, 'after adding attributes'
116
+ items = @sdb.query(@domain, ['[?=?]', 'Jon','vodka'])[:items]
117
+ assert_equal items.size, 1
118
+ assert_equal items.first, @item
119
+ end
120
+
121
+ def test_09_signature_version_0
122
+ sdb = Rightscale::SdbInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :signature_version => '0')
123
+ item = 'toys'
124
+ # TODO: need to change the below test. I think Juergen's intention was to include some umlauts in the values
125
+ # put attributes
126
+ # mhhh... Not sure how to translate this: hölzchehn klötzchen grÃŒnspan buße... Lets assume this is:
127
+ attributes = { 'Jurgen' => %w{kitten puppy chickabiddy piglet} }
128
+ assert sdb.put_attributes(@domain, item, attributes)
129
+ wait SDB_DELAY, 'after putting attributes'
130
+ # get attributes
131
+ values = sdb.get_attributes(@domain, item)[:attributes]['Jurgen'].to_a.sort
132
+ # compare to original list
133
+ assert_equal values, attributes['Jurgen'].sort
134
+ # check that the request has correct signature version
135
+ assert sdb.last_request.path.include?('SignatureVersion=0')
136
+ end
137
+
138
+ def test_10_signature_version_1
139
+ sdb = Rightscale::SdbInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :signature_version => '1')
140
+ domains = nil
141
+ assert_nothing_thrown "Failed to use signature V1" do
142
+ domains = sdb.list_domains
143
+ end
144
+ assert domains
145
+ end
146
+
147
+ def test_11_signature_version_1
148
+ sdb = Rightscale::SdbInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :signature_version => '2')
149
+ domains = nil
150
+ assert_nothing_thrown "Failed to use signature V2" do
151
+ domains = sdb.list_domains
152
+ end
153
+ assert domains
154
+ end
155
+
156
+ def test_12_array_of_attrs
157
+ item = 'multiples'
158
+ assert_nothing_thrown "Failed to put multiple attrs" do
159
+ @sdb.put_attributes(@domain, item, {:one=>1, :two=>2, :three=>3})
160
+ end
161
+ end
162
+
163
+ def test_13_zero_len_attrs
164
+ item = 'zeroes'
165
+ assert_nothing_thrown "Failed to put zero-length attributes" do
166
+ @sdb.put_attributes(@domain, item, {:one=>"", :two=>"", :three=>""})
167
+ end
168
+ end
169
+
170
+ def test_14_nil_attrs
171
+ item = 'nils'
172
+ res = nil
173
+ assert_nothing_thrown do
174
+ @sdb.put_attributes(@domain, item, {:one=>nil, :two=>nil, :three=>'chunder'})
175
+ end
176
+ assert_nothing_thrown do
177
+ res = @sdb.get_attributes(@domain, item)
178
+ end
179
+ assert_nil(res[:attributes]['one'][0])
180
+ assert_nil(res[:attributes]['two'][0])
181
+ assert_not_nil(res[:attributes]['three'][0])
182
+ end
183
+
184
+ def test_15_url_escape
185
+ item = 'urlescapes'
186
+ content = {:a=>"one & two & three",
187
+ :b=>"one ? two / three"}
188
+ @sdb.put_attributes(@domain, item, content)
189
+
190
+ res = @sdb.get_attributes(@domain, item)
191
+ assert_equal(content[:a], res[:attributes]['a'][0])
192
+ assert_equal(content[:b], res[:attributes]['b'][0])
193
+ end
194
+
195
+ def test_16_put_attrs_by_post
196
+ item = 'reqgirth'
197
+ i = 0
198
+ sa = ""
199
+ while(i < 64) do
200
+ sa += "aaaaaaaa"
201
+ i += 1
202
+ end
203
+ @sdb.put_attributes(@domain, item, {:a => sa, :b => sa, :c => sa, :d => sa, :e => sa})
204
+ end
205
+
206
+ def test_20_query_with_atributes
207
+ response = @sdb.query_with_attributes(@domain)
208
+ # convers response to a hash representation
209
+ items = {};
210
+ response[:items].each{ |item| items.merge!(item) }
211
+ # check we have receied all 5 items each full of attributes
212
+ assert_equal 5, items.keys.size
213
+ assert items['toys'].size > 0
214
+ assert items['nils'].size > 0
215
+ assert items['urlescapes'].size > 0
216
+ assert items['multiples'].size > 0
217
+ assert items['reqgirth'].size > 0
218
+ # fetch only Jon's attributes from all items
219
+ response = @sdb.query_with_attributes(@domain,['Jon'])
220
+ items = {};
221
+ response[:items].each{ |item| items.merge!(item) }
222
+ # check we have receied all 5 items
223
+ # check we have receied all 5 items, but only 'toys' has attributes
224
+ puts items.inspect
225
+ assert_equal 2, items['toys']['Jon'].size
226
+ assert_equal 0, items['nils'].size
227
+ assert_equal 0, items['urlescapes'].size
228
+ assert_equal 0, items['multiples'].size
229
+ assert_equal 0, items['reqgirth'].size
230
+ # kust Jurgen's attriburs
231
+ response = @sdb.query_with_attributes(@domain,['Jurgen'], "['Jurgen'='piglet']")
232
+ items = {};
233
+ response[:items].each{ |item| items.merge!(item) }
234
+ # check we have receied an only item
235
+ assert_equal 1, items.keys.size
236
+ assert_equal ["chickabiddy", "kitten", "piglet", "puppy"], items['toys']['Jurgen'].sort
237
+ end
238
+
239
+ # Keep this test last, because it deletes the domain...
240
+ def test_21_delete_domain
241
+ assert @sdb.delete_domain(@domain), 'delete_domain fail'
242
+ wait SDB_DELAY, 'after domain deletion'
243
+ # check that domain does not exist
244
+ assert !@sdb.list_domains[:domains].include?(@domain)
245
+ end
246
+
247
+ end
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../../lib/right_aws'