kernow-ruby-aaws 0.5.4 → 0.7.1
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/INSTALL +7 -6
- data/NEWS +600 -272
- data/README +250 -163
- data/README.rdoc +145 -129
- data/Rakefile +13 -32
- data/VERSION +1 -0
- data/example/batch_operation +27 -0
- data/example/example1 +3 -3
- data/example/item_lookup1 +5 -4
- data/example/item_lookup2 +5 -4
- data/example/multiple_operation1 +4 -3
- data/example/vehicle_search +22 -0
- data/lib/amazon.rb +34 -16
- data/lib/amazon/aws.rb +496 -161
- data/lib/amazon/aws/search.rb +148 -28
- data/ruby-aaws.gemspec +117 -0
- data/test/setup.rb +5 -2
- data/test/tc_aws.rb +2 -2
- data/test/tc_browse_node_lookup.rb +62 -0
- data/test/tc_customer_content_lookup.rb +64 -0
- data/test/tc_help.rb +60 -0
- data/test/tc_item_lookup.rb +60 -0
- data/test/tc_item_search.rb +88 -3
- data/test/tc_list_lookup.rb +55 -0
- data/test/tc_list_search.rb +55 -0
- data/test/tc_multiple_operation.rb +211 -4
- data/test/tc_seller_listing_lookup.rb +58 -0
- data/test/tc_seller_listing_search.rb +70 -0
- data/test/tc_seller_lookup.rb +54 -0
- data/test/tc_shopping_cart.rb +9 -9
- data/test/tc_similarity_lookup.rb +59 -0
- data/test/tc_tag_lookup.rb +35 -0
- data/test/tc_transaction_lookup.rb +35 -0
- data/test/tc_vehicle_operations.rb +106 -0
- data/test/ts_aws.rb +16 -4
- metadata +85 -49
- data/ruby-aws.gemspec +0 -57
- data/ruby-aws.spec +0 -177
@@ -0,0 +1,64 @@
|
|
1
|
+
# $Id: tc_customer_content_lookup.rb,v 1.1 2009/06/02 00:29:18 ianmacd Exp $
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require './setup'
|
6
|
+
|
7
|
+
class TestCustomerContentLookup < AWSTest
|
8
|
+
|
9
|
+
def test_customer_content_lookup
|
10
|
+
|
11
|
+
@req.locale = 'us'
|
12
|
+
ccl = CustomerContentLookup.new( 'AJDWXANG1SYZP' )
|
13
|
+
rg = ResponseGroup.new( :CustomerReviews )
|
14
|
+
|
15
|
+
response = @req.search( ccl, rg )
|
16
|
+
|
17
|
+
review = response.customer_content_lookup_response.customers.customer.
|
18
|
+
customer_reviews.review[0]
|
19
|
+
|
20
|
+
# Ensure we got the right review.
|
21
|
+
#
|
22
|
+
assert_equal( 3746, review.content[0].size )
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_customer_content_lookup_no_response_group
|
27
|
+
|
28
|
+
@req.locale = 'us'
|
29
|
+
ccl = CustomerContentLookup.new( 'AJDWXANG1SYZP' )
|
30
|
+
ccl.response_group = ResponseGroup.new( :CustomerReviews )
|
31
|
+
response = @req.search( ccl, nil )
|
32
|
+
|
33
|
+
review = response.customer_content_lookup_response.customers.customer.
|
34
|
+
customer_reviews.review[0]
|
35
|
+
|
36
|
+
# Ensure we got the right review.
|
37
|
+
#
|
38
|
+
assert_equal( 3746, review.content[0].size )
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_customer_content_lookup_class_method
|
43
|
+
|
44
|
+
response = Amazon::AWS.customer_content_lookup( 'AA5QZU6TJQXEN' )
|
45
|
+
|
46
|
+
nickname = response.customer_content_lookup_response.customers.customer.
|
47
|
+
nickname
|
48
|
+
|
49
|
+
assert_equal( 'jimwood43', nickname )
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_item_search_class_method_block
|
54
|
+
|
55
|
+
Amazon::AWS.customer_content_lookup( 'AA5QZU6TJQXEN' ) do |r|
|
56
|
+
|
57
|
+
nickname = r.customer_content_lookup_response.customers.customer.nickname
|
58
|
+
|
59
|
+
assert_equal( 'jimwood43', nickname )
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
data/test/tc_help.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# $Id: tc_help.rb,v 1.2 2009/06/02 00:39:23 ianmacd Exp $
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require './setup'
|
6
|
+
|
7
|
+
class TestHelp < AWSTest
|
8
|
+
|
9
|
+
def test_help
|
10
|
+
|
11
|
+
h = Help.new( 'ResponseGroup', 'Large' )
|
12
|
+
rg = ResponseGroup.new( 'Help' )
|
13
|
+
response = @req.search( h, rg )
|
14
|
+
|
15
|
+
# Get a list of valid operations for the Large response group.
|
16
|
+
#
|
17
|
+
results = response.help_response[0].information.response_group_information.
|
18
|
+
valid_operations.operation
|
19
|
+
|
20
|
+
# Ensure we got some actual results back.
|
21
|
+
#
|
22
|
+
assert( results.size > 0 )
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_help_no_response_group
|
27
|
+
|
28
|
+
h = Help.new( 'ResponseGroup', 'Large' )
|
29
|
+
h.response_group = ResponseGroup.new( 'Help' )
|
30
|
+
response = @req.search( h, nil )
|
31
|
+
|
32
|
+
# Get a list of valid operations for the Large response group.
|
33
|
+
#
|
34
|
+
results = response.help_response[0].information.response_group_information.
|
35
|
+
valid_operations.operation
|
36
|
+
|
37
|
+
# Ensure we got some actual results back.
|
38
|
+
#
|
39
|
+
assert( results.size > 0 )
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_help_class_method
|
44
|
+
|
45
|
+
response = Amazon::AWS.help( 'ResponseGroup', 'Large' )
|
46
|
+
|
47
|
+
# With no response group, Large will be tried. The resulting exception
|
48
|
+
# will be rescued and the text of the message returned by AWS will be used
|
49
|
+
# to determine a response group that will work.
|
50
|
+
#
|
51
|
+
results = response.help_response[0].information.response_group_information.
|
52
|
+
valid_operations.operation
|
53
|
+
|
54
|
+
# Ensure we got some actual results back.
|
55
|
+
#
|
56
|
+
assert( results.size > 0 )
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# $Id: tc_item_lookup.rb,v 1.2 2009/05/30 11:11:27 ianmacd Exp $
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require './setup'
|
6
|
+
|
7
|
+
class TestItemLookup < AWSTest
|
8
|
+
|
9
|
+
def test_item_lookup
|
10
|
+
|
11
|
+
is = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000AE4QEC' } )
|
12
|
+
response = @req.search( is, @rg )
|
13
|
+
|
14
|
+
results = response.kernel
|
15
|
+
|
16
|
+
# Ensure we got some actual results back.
|
17
|
+
#
|
18
|
+
assert( results.size > 0 )
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_item_lookup_no_response_group
|
23
|
+
|
24
|
+
is = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000AE4QEC' } )
|
25
|
+
is.response_group = ResponseGroup.new( :Small )
|
26
|
+
response = @req.search( is, nil )
|
27
|
+
|
28
|
+
results = response.kernel
|
29
|
+
|
30
|
+
# Ensure we got more than 10 results back.
|
31
|
+
#
|
32
|
+
assert( results.size > 0 )
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_item_lookup_class_method
|
37
|
+
|
38
|
+
response = Amazon::AWS.item_lookup( 'ASIN', { 'ItemId' => 'B000AE4QEC' } )
|
39
|
+
|
40
|
+
results = response.kernel
|
41
|
+
|
42
|
+
# Ensure we got some actual results back.
|
43
|
+
#
|
44
|
+
assert( results.size > 0 )
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_item_search_class_method_block
|
49
|
+
|
50
|
+
Amazon::AWS.item_lookup( 'ASIN', { 'ItemId' => 'B000AE4QEC' } ) do |r|
|
51
|
+
|
52
|
+
results = r.kernel
|
53
|
+
|
54
|
+
# Ensure we got some actual results back.
|
55
|
+
#
|
56
|
+
assert( results.size > 0 )
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
data/test/tc_item_search.rb
CHANGED
@@ -1,13 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# encoding: ASCII-8BIT
|
2
2
|
#
|
3
|
+
# $Id: tc_item_search.rb,v 1.6 2009/06/15 10:18:07 ianmacd Exp $
|
4
|
+
#
|
5
|
+
# The encoding at the top of this file is necessary for Ruby 1.9, which will
|
6
|
+
# otherwise choke with 'invalid multibyte char (US-ASCII)' when it reads the
|
7
|
+
# ISO-8859-1 encoded accented 'e' in the test_item_search_iso_8859_15 method.
|
3
8
|
|
4
9
|
require 'test/unit'
|
5
10
|
require './setup'
|
6
11
|
|
7
12
|
class TestItemSearch < AWSTest
|
8
13
|
|
9
|
-
def
|
10
|
-
|
14
|
+
def test_item_search_iso_8859_15
|
15
|
+
|
16
|
+
# Ensure that character set encoding works properly by manually trying
|
17
|
+
# ISO-8859-15, a.k.a. Latin-15.
|
18
|
+
#
|
19
|
+
@req.encoding = 'iso-8859-15'
|
20
|
+
|
21
|
+
str = 'Caf�'
|
22
|
+
is = ItemSearch.new( 'Books', { 'Title' => str } )
|
11
23
|
response = @req.search( is, @rg )
|
12
24
|
|
13
25
|
results = response.kernel
|
@@ -18,4 +30,77 @@ class TestItemSearch < AWSTest
|
|
18
30
|
|
19
31
|
end
|
20
32
|
|
33
|
+
def test_item_search_utf8
|
34
|
+
|
35
|
+
# Manually set UTF-8 encoding.
|
36
|
+
#
|
37
|
+
@req.encoding = 'utf-8'
|
38
|
+
|
39
|
+
str = 'Café'
|
40
|
+
is = ItemSearch.new( 'Books', { 'Title' => str } )
|
41
|
+
response = @req.search( is, @rg )
|
42
|
+
|
43
|
+
results = response.kernel
|
44
|
+
|
45
|
+
# Ensure we got some actual results back.
|
46
|
+
#
|
47
|
+
assert( results.size > 0 )
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_item_search_multiple_pages
|
52
|
+
|
53
|
+
@req.encoding = 'utf-8'
|
54
|
+
is = ItemSearch.new( 'Books', { 'Title' => 'programming' } )
|
55
|
+
responses = @req.search( is, @rg, 5 )
|
56
|
+
|
57
|
+
results = []
|
58
|
+
responses.each { |response| results += response.kernel }
|
59
|
+
|
60
|
+
# Ensure we got more than 10 results back.
|
61
|
+
#
|
62
|
+
assert( results.size > 10 )
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_item_search_no_response_group
|
67
|
+
|
68
|
+
@req.encoding = 'utf-8'
|
69
|
+
is = ItemSearch.new( 'Books', { 'Title' => 'programming' } )
|
70
|
+
is.response_group = ResponseGroup.new( :Small )
|
71
|
+
responses = @req.search( is, nil, 5 )
|
72
|
+
|
73
|
+
results = []
|
74
|
+
responses.each { |response| results += response.kernel }
|
75
|
+
|
76
|
+
# Ensure we got more than 10 results back.
|
77
|
+
#
|
78
|
+
assert( results.size > 10 )
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_item_search_class_method
|
83
|
+
|
84
|
+
response = Amazon::AWS.item_search( 'Books', { 'Title' => 'programming' } )
|
85
|
+
|
86
|
+
results = response.kernel
|
87
|
+
|
88
|
+
# Ensure we got some actual results back.
|
89
|
+
#
|
90
|
+
assert( results.size > 0 )
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_item_search_class_method_block
|
95
|
+
|
96
|
+
Amazon::AWS.item_search( 'Books', { 'Title' => 'programming' } ) do |r|
|
97
|
+
|
98
|
+
results = r.kernel
|
99
|
+
|
100
|
+
# Ensure we got some actual results back.
|
101
|
+
#
|
102
|
+
assert( results.size > 0 )
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
21
106
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# $Id: tc_list_lookup.rb,v 1.2 2009/06/03 22:33:04 ianmacd Exp $
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require './setup'
|
6
|
+
|
7
|
+
class TestListLookup < AWSTest
|
8
|
+
|
9
|
+
def test_list_lookup
|
10
|
+
|
11
|
+
@req.locale = 'us'
|
12
|
+
rg = ResponseGroup.new( :ListInfo )
|
13
|
+
ll = ListLookup.new( '3TV12MGLOJI4R', :WishList )
|
14
|
+
response = @req.search( ll, rg )
|
15
|
+
|
16
|
+
list = response.kernel
|
17
|
+
|
18
|
+
assert_equal( '2008-06-30', list.date_created )
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_list_lookup_no_response_group
|
23
|
+
|
24
|
+
@req.locale = 'us'
|
25
|
+
ll = ListLookup.new( '3P722DU4KUPCP', 'Listmania' )
|
26
|
+
ll.response_group = ResponseGroup.new( :ListInfo, :Small )
|
27
|
+
response = @req.search( ll, nil )
|
28
|
+
|
29
|
+
list = response.kernel
|
30
|
+
|
31
|
+
assert_equal( 'Computer History', list.list_name )
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_list_lookup_class_method
|
36
|
+
|
37
|
+
response = Amazon::AWS.list_lookup( 'R35BA7X0YD3YP', 'Listmania' )
|
38
|
+
|
39
|
+
list = response.kernel
|
40
|
+
|
41
|
+
assert_equal( 'examples of perfection', list.list_name )
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_item_search_class_method_block
|
46
|
+
|
47
|
+
Amazon::AWS.list_lookup( 'R35BA7X0YD3YP', :Listmania ) do |r|
|
48
|
+
|
49
|
+
list = r.kernel
|
50
|
+
|
51
|
+
assert_equal( 'examples of perfection', list.list_name )
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# $Id: tc_list_search.rb,v 1.2 2009/06/03 22:32:42 ianmacd Exp $
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require './setup'
|
6
|
+
|
7
|
+
class TestListSearch < AWSTest
|
8
|
+
|
9
|
+
def test_list_search
|
10
|
+
|
11
|
+
@req.locale = 'us'
|
12
|
+
rg = ResponseGroup.new( :ListInfo )
|
13
|
+
ls = ListSearch.new( 'WishList', { 'Name' => 'Peter Duff' } )
|
14
|
+
response = @req.search( ls, rg )
|
15
|
+
|
16
|
+
lists = response.kernel
|
17
|
+
|
18
|
+
assert( lists.collect { |l| l.list_id }.include?( '18Y9QEW3A4SRY' ) )
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_list_search_no_response_group
|
23
|
+
|
24
|
+
@req.locale = 'us'
|
25
|
+
ls = ListSearch.new( 'WishList', { 'Name' => 'Peter Duff' } )
|
26
|
+
ls.response_group = ResponseGroup.new( :ListMinimum )
|
27
|
+
response = @req.search( ls, nil )
|
28
|
+
|
29
|
+
lists = response.kernel
|
30
|
+
|
31
|
+
assert( lists.collect { |l| l.list_id }.include?( '18Y9QEW3A4SRY' ) )
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_list_search_class_method
|
36
|
+
|
37
|
+
response = Amazon::AWS.list_search( 'WishList', { :Name => 'Peter Duff' } )
|
38
|
+
|
39
|
+
lists = response.kernel
|
40
|
+
|
41
|
+
assert( lists.size > 5 )
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_item_search_class_method_block
|
46
|
+
|
47
|
+
Amazon::AWS.list_search( 'WishList', { 'Name' => 'Peter Duff' } ) do |r|
|
48
|
+
|
49
|
+
lists = r.kernel
|
50
|
+
|
51
|
+
assert( lists.size > 5 )
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id: tc_multiple_operation.rb,v 1.
|
1
|
+
# $Id: tc_multiple_operation.rb,v 1.3 2009/06/15 21:21:02 ianmacd Exp $
|
2
2
|
#
|
3
3
|
|
4
4
|
require 'test/unit'
|
@@ -6,13 +6,176 @@ require './setup'
|
|
6
6
|
|
7
7
|
class TestMultipleOperation < AWSTest
|
8
8
|
|
9
|
-
def
|
9
|
+
def test_unbatched_multiple_same_class_with_separate_response_groups
|
10
10
|
il = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000AE4QEC',
|
11
|
-
'MerchantId' => 'Amazon' },
|
12
|
-
{ 'ItemId' => 'B000051WBE',
|
13
11
|
'MerchantId' => 'Amazon' } )
|
12
|
+
il2 = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000051WBE',
|
13
|
+
'MerchantId' => 'Amazon' } )
|
14
|
+
|
15
|
+
il.response_group = ResponseGroup.new( :Large )
|
16
|
+
il2.response_group = ResponseGroup.new( :Small )
|
17
|
+
|
18
|
+
# Create a multiple operation of the ItemSearch operation and the two
|
19
|
+
# batched ItemLookup operations.
|
20
|
+
#
|
21
|
+
mo = MultipleOperation.new( il, il2 )
|
22
|
+
response = @req.search( mo, nil )
|
23
|
+
mor = response.multi_operation_response[0]
|
24
|
+
|
25
|
+
# Ensure our separate response groups were used.
|
26
|
+
#
|
27
|
+
arguments = mor.operation_request.arguments.argument
|
28
|
+
|
29
|
+
il_rg = arguments.select do |arg|
|
30
|
+
arg.attrib['name'] == 'ItemLookup.1.ResponseGroup'
|
31
|
+
end[0]
|
32
|
+
|
33
|
+
il2_rg = arguments.select do |arg|
|
34
|
+
arg.attrib['name'] == 'ItemLookup.2.ResponseGroup'
|
35
|
+
end[0]
|
36
|
+
|
37
|
+
assert_equal( 'Large', il_rg.attrib['value'] )
|
38
|
+
assert_equal( 'Small', il2_rg.attrib['value'] )
|
39
|
+
|
40
|
+
# Ensure we received a MultiOperationResponse.
|
41
|
+
#
|
42
|
+
assert_instance_of( Amazon::AWS::AWSObject::MultiOperationResponse, mor )
|
43
|
+
|
44
|
+
# Ensure response contains an ItemLookupResponse.
|
45
|
+
#
|
46
|
+
assert_instance_of( Amazon::AWS::AWSObject::ItemLookupResponse,
|
47
|
+
mor.item_lookup_response[0] )
|
48
|
+
|
49
|
+
il_set = mor.item_lookup_response[0].items
|
50
|
+
il_arr1 = il_set[0].item
|
51
|
+
il_arr2 = il_set[1].item
|
52
|
+
|
53
|
+
# Ensure that there are two <ItemSet>s for the ItemLookup, because it was
|
54
|
+
# a batched operation.
|
55
|
+
#
|
56
|
+
assert_equal( 2, il_set.size )
|
57
|
+
|
58
|
+
# Assure that all item sets have some results.
|
59
|
+
#
|
60
|
+
assert( il_arr1.size > 0 )
|
61
|
+
assert( il_arr2.size > 0 )
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_batched_multiple_with_separate_response_groups
|
65
|
+
il = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000AE4QEC',
|
66
|
+
'MerchantId' => 'Amazon' } )
|
67
|
+
il2 = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000051WBE',
|
68
|
+
'MerchantId' => 'Amazon' } )
|
69
|
+
il3 = ItemLookup.new( 'ASIN', { 'ItemId' => 'B00061F8LO',
|
70
|
+
'MerchantId' => 'Amazon' } )
|
71
|
+
|
72
|
+
il.response_group = ResponseGroup.new( :Large )
|
73
|
+
il2.response_group = ResponseGroup.new( :Small )
|
74
|
+
|
75
|
+
# Create a batch request of the two ItemLookup operations.
|
76
|
+
#
|
77
|
+
il.batch( il2 )
|
78
|
+
|
14
79
|
is = ItemSearch.new( 'Books', { 'Title' => 'Ruby' } )
|
80
|
+
is.response_group = ResponseGroup.new( :Medium, :Tags )
|
81
|
+
|
82
|
+
# Create a multiple operation of the ItemSearch operation and the two
|
83
|
+
# batched ItemLookup operations.
|
84
|
+
#
|
85
|
+
mo = MultipleOperation.new( is, il )
|
86
|
+
response = @req.search( mo, nil )
|
87
|
+
mor = response.multi_operation_response[0]
|
88
|
+
|
89
|
+
# Batch a third ItemLookup operation.
|
90
|
+
#
|
91
|
+
il.batch( il3 )
|
92
|
+
mo = MultipleOperation.new( is, il )
|
93
|
+
|
94
|
+
# Because exception classes aren't created until an exception occurs, we
|
95
|
+
# need to create the one we wish to test for now, otherwise we can't refer
|
96
|
+
# to it in our code without causing an 'uninitialized constant' error.
|
97
|
+
#
|
98
|
+
Amazon::AWS::Error.const_set( 'ExceededMaxBatchRequestsPerOperation',
|
99
|
+
Class.new( Amazon::AWS::Error::AWSError ) )
|
100
|
+
|
101
|
+
# Attempt to perform the search.
|
102
|
+
#
|
103
|
+
assert_raise( Amazon::AWS::Error::ExceededMaxBatchRequestsPerOperation ) do
|
104
|
+
@req.search( mo, nil )
|
105
|
+
end
|
106
|
+
|
107
|
+
# Ensure our separate response groups were used.
|
108
|
+
#
|
109
|
+
arguments = mor.operation_request.arguments.argument
|
110
|
+
|
111
|
+
il_rg = arguments.select do |arg|
|
112
|
+
arg.attrib['name'] == 'ItemLookup.1.ResponseGroup'
|
113
|
+
end[0]
|
114
|
+
|
115
|
+
il2_rg = arguments.select do |arg|
|
116
|
+
arg.attrib['name'] == 'ItemLookup.2.ResponseGroup'
|
117
|
+
end[0]
|
118
|
+
|
119
|
+
is_rg = arguments.select do |arg|
|
120
|
+
arg.attrib['name'] == 'ItemSearch.1.ResponseGroup'
|
121
|
+
end[0]
|
122
|
+
|
123
|
+
assert_equal( 'Large', il_rg.attrib['value'] )
|
124
|
+
assert_equal( 'Small', il2_rg.attrib['value'] )
|
125
|
+
assert_equal( 'Medium,Tags', is_rg.attrib['value'] )
|
126
|
+
|
127
|
+
# Ensure we received a MultiOperationResponse.
|
128
|
+
#
|
129
|
+
assert_instance_of( Amazon::AWS::AWSObject::MultiOperationResponse, mor )
|
15
130
|
|
131
|
+
# Ensure response contains an ItemSearchResponse.
|
132
|
+
#
|
133
|
+
assert_instance_of( Amazon::AWS::AWSObject::ItemSearchResponse,
|
134
|
+
mor.item_search_response[0] )
|
135
|
+
|
136
|
+
# Ensure response also contains an ItemLookupResponse.
|
137
|
+
#
|
138
|
+
assert_instance_of( Amazon::AWS::AWSObject::ItemLookupResponse,
|
139
|
+
mor.item_lookup_response[0] )
|
140
|
+
|
141
|
+
is_set = mor.item_search_response[0].items
|
142
|
+
il_set = mor.item_lookup_response[0].items
|
143
|
+
is_arr = is_set.item
|
144
|
+
il_arr1 = il_set[0].item
|
145
|
+
il_arr2 = il_set[1].item
|
146
|
+
|
147
|
+
# Ensure that there's one <ItemSet> for the ItemSearch.
|
148
|
+
#
|
149
|
+
assert_equal( 1, is_set.size )
|
150
|
+
|
151
|
+
# Ensure that there are two <ItemSet>s for the ItemLookup, because it was
|
152
|
+
# a batched operation.
|
153
|
+
#
|
154
|
+
assert_equal( 2, il_set.size )
|
155
|
+
|
156
|
+
# Assure that all item sets have some results.
|
157
|
+
#
|
158
|
+
assert( is_arr.size > 0 )
|
159
|
+
assert( il_arr1.size > 0 )
|
160
|
+
assert( il_arr2.size > 0 )
|
161
|
+
end
|
162
|
+
|
163
|
+
|
164
|
+
def test_batched_multiple_with_shared_response_group
|
165
|
+
il = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000AE4QEC',
|
166
|
+
'MerchantId' => 'Amazon' } )
|
167
|
+
il2 = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000051WBE',
|
168
|
+
'MerchantId' => 'Amazon' } )
|
169
|
+
|
170
|
+
# Create a batch request of the two ItemLookup operations.
|
171
|
+
#
|
172
|
+
il.batch( il2 )
|
173
|
+
|
174
|
+
is = ItemSearch.new( 'Books', { 'Title' => 'Ruby' } )
|
175
|
+
|
176
|
+
# Create a multiple operation of the ItemSearch operation and the two
|
177
|
+
# batched ItemLookup operations.
|
178
|
+
#
|
16
179
|
mo = MultipleOperation.new( is, il )
|
17
180
|
|
18
181
|
response = @req.search( mo, @rg )
|
@@ -55,4 +218,48 @@ class TestMultipleOperation < AWSTest
|
|
55
218
|
assert( il_arr2.size > 0 )
|
56
219
|
end
|
57
220
|
|
221
|
+
def test_multiple_class_method
|
222
|
+
il = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000AE4QEC',
|
223
|
+
'MerchantId' => 'Amazon' } )
|
224
|
+
il.response_group = ResponseGroup.new( :Large )
|
225
|
+
|
226
|
+
is = ItemSearch.new( 'Books', { 'Title' => 'Ruby' } )
|
227
|
+
is.response_group = ResponseGroup.new( :Medium, :Tags )
|
228
|
+
|
229
|
+
response = Amazon::AWS.multiple_operation( is, il )
|
230
|
+
mor = response.multi_operation_response[0]
|
231
|
+
|
232
|
+
# Ensure we received a MultiOperationResponse.
|
233
|
+
#
|
234
|
+
assert_instance_of( Amazon::AWS::AWSObject::MultiOperationResponse, mor )
|
235
|
+
|
236
|
+
# Ensure response contains an ItemSearchResponse.
|
237
|
+
#
|
238
|
+
assert_instance_of( Amazon::AWS::AWSObject::ItemSearchResponse,
|
239
|
+
mor.item_search_response[0] )
|
240
|
+
|
241
|
+
# Ensure response also contains an ItemLookupResponse.
|
242
|
+
#
|
243
|
+
assert_instance_of( Amazon::AWS::AWSObject::ItemLookupResponse,
|
244
|
+
mor.item_lookup_response[0] )
|
245
|
+
|
246
|
+
is_set = response.multi_operation_response.item_search_response[0].items
|
247
|
+
il_set = response.multi_operation_response.item_lookup_response[0].items
|
248
|
+
is_arr = is_set.item
|
249
|
+
il_arr = il_set[0].item
|
250
|
+
|
251
|
+
# Ensure that there's one <ItemSet> for the ItemSearch.
|
252
|
+
#
|
253
|
+
assert_equal( 1, is_set.size )
|
254
|
+
|
255
|
+
# Ensure that there's one <ItemSet> for the ItemLookup.
|
256
|
+
#
|
257
|
+
assert_equal( 1, il_set.size )
|
258
|
+
|
259
|
+
# Assure that all item sets have some results.
|
260
|
+
#
|
261
|
+
assert( is_arr.size > 0 )
|
262
|
+
assert( il_arr.size > 0 )
|
263
|
+
end
|
264
|
+
|
58
265
|
end
|