active_fulfillment 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/lib/active_fulfillment/fulfillment/service.rb +13 -6
- data/lib/active_fulfillment/fulfillment/services/amazon.rb +62 -51
- data/lib/active_fulfillment/fulfillment/services/amazon_mws.rb +35 -23
- data/lib/active_fulfillment/fulfillment/services/shipwire.rb +8 -6
- data/lib/active_fulfillment/fulfillment/services/webgistix.rb +76 -66
- data/lib/active_fulfillment/fulfillment/version.rb +1 -1
- data/test/remote/amazon_mws_test.rb +17 -10
- data/test/remote/amazon_test.rb +22 -15
- data/test/remote/shipwire_test.rb +36 -28
- data/test/remote/webgistix_test.rb +25 -16
- data/test/unit/services/amazon_mws_test.rb +36 -11
- data/test/unit/services/amazon_test.rb +46 -36
- data/test/unit/services/shipwire_test.rb +22 -22
- data/test/unit/services/webgistix_test.rb +45 -33
- metadata +1 -1
@@ -5,12 +5,12 @@ class RemoteWebgistixTest < Test::Unit::TestCase
|
|
5
5
|
Base.mode = :test
|
6
6
|
|
7
7
|
@service = WebgistixService.new( fixtures(:webgistix) )
|
8
|
-
|
9
|
-
@options = {
|
8
|
+
|
9
|
+
@options = {
|
10
10
|
:shipping_method => 'Ground',
|
11
11
|
:email => 'buyer@jadedpallet.com'
|
12
12
|
}
|
13
|
-
|
13
|
+
|
14
14
|
@address = { :name => 'Fred Brooks',
|
15
15
|
:address1 => '1234 Penny Lane',
|
16
16
|
:city => 'Jonsetown',
|
@@ -18,13 +18,13 @@ class RemoteWebgistixTest < Test::Unit::TestCase
|
|
18
18
|
:country => 'US',
|
19
19
|
:zip => '23456'
|
20
20
|
}
|
21
|
-
|
21
|
+
|
22
22
|
@line_items = [
|
23
23
|
{ :sku => 'WX-01-4001',
|
24
24
|
:quantity => 2
|
25
25
|
}
|
26
26
|
]
|
27
|
-
|
27
|
+
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_successful_order_submission
|
@@ -33,20 +33,20 @@ class RemoteWebgistixTest < Test::Unit::TestCase
|
|
33
33
|
assert response.test?
|
34
34
|
assert_equal WebgistixService::SUCCESS_MESSAGE, response.message
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def test_order_multiple_line_items
|
38
38
|
@line_items.push(
|
39
39
|
{ :sku => 'WX-01-1020',
|
40
40
|
:quantity => 3
|
41
41
|
}
|
42
42
|
)
|
43
|
-
|
43
|
+
|
44
44
|
response = @service.fulfill('123456', @address, @line_items, @options)
|
45
45
|
assert response.success?
|
46
46
|
assert response.test?
|
47
47
|
assert_equal WebgistixService::SUCCESS_MESSAGE, response.message
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def test_invalid_sku_during_fulfillment
|
51
51
|
line_items = [ { :sku => 'invalid', :quantity => 1 } ]
|
52
52
|
response = @service.fulfill('123456', @address, line_items, @options)
|
@@ -54,18 +54,18 @@ class RemoteWebgistixTest < Test::Unit::TestCase
|
|
54
54
|
assert response.test?
|
55
55
|
assert_equal WebgistixService::FAILURE_MESSAGE, response.message
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def test_invalid_credentials_during_fulfillment
|
59
59
|
service = WebgistixService.new(
|
60
60
|
:login => 'your@email.com',
|
61
61
|
:password => 'password')
|
62
|
-
|
62
|
+
|
63
63
|
response = service.fulfill('123456', @address, @line_items, @options)
|
64
64
|
assert !response.success?
|
65
65
|
assert response.test?
|
66
66
|
assert_equal "Invalid Credentials", response.message
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
def test_get_inventory
|
70
70
|
response = @service.fetch_stock_levels
|
71
71
|
assert response.success?
|
@@ -73,7 +73,16 @@ class RemoteWebgistixTest < Test::Unit::TestCase
|
|
73
73
|
assert_equal 90, response.stock_levels['WX-01-3022']
|
74
74
|
assert_equal 140, response.stock_levels['WX-04-1080']
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
|
+
def test_fetch_tracking_data
|
78
|
+
response = @service.fetch_tracking_numbers([
|
79
|
+
'1254658', 'FAItest123', 'Flat Rate Test Order 4'
|
80
|
+
])
|
81
|
+
assert response.success?
|
82
|
+
assert_equal ['4209073191018052136352154'], response.tracking_numbers['1254658']
|
83
|
+
assert_equal ['UPS'], response.tracking_companies['1254658']
|
84
|
+
end
|
85
|
+
|
77
86
|
def test_fetch_tracking_numbers
|
78
87
|
response = @service.fetch_tracking_numbers([
|
79
88
|
'1254658', 'FAItest123', 'Flat Rate Test Order 4'
|
@@ -83,16 +92,16 @@ class RemoteWebgistixTest < Test::Unit::TestCase
|
|
83
92
|
assert_equal ['9101805213907472080032'], response.tracking_numbers['Flat Rate Test Order 4']
|
84
93
|
assert_nil response.tracking_numbers['FAItest123'] # 'Not Shipped'
|
85
94
|
end
|
86
|
-
|
95
|
+
|
87
96
|
def test_valid_credentials
|
88
97
|
assert @service.valid_credentials?
|
89
98
|
end
|
90
|
-
|
99
|
+
|
91
100
|
def test_invalid_credentials
|
92
101
|
service = WebgistixService.new(
|
93
102
|
:login => 'your@email.com',
|
94
103
|
:password => 'password')
|
95
|
-
|
104
|
+
|
96
105
|
assert !service.valid_credentials?
|
97
106
|
end
|
98
|
-
end
|
107
|
+
end
|
@@ -6,14 +6,14 @@ class AmazonMarketplaceWebServiceTest < Test::Unit::TestCase
|
|
6
6
|
:login => 'l',
|
7
7
|
:password => 'p'
|
8
8
|
)
|
9
|
-
|
10
|
-
@options = {
|
9
|
+
|
10
|
+
@options = {
|
11
11
|
:shipping_method => 'Standard',
|
12
12
|
:order_date => Time.now.utc.yesterday,
|
13
13
|
:comment => "Delayed due to tornados"
|
14
14
|
}
|
15
|
-
|
16
|
-
@address = {
|
15
|
+
|
16
|
+
@address = {
|
17
17
|
:name => 'Johnny Chase',
|
18
18
|
:address1 => '100 Information Super Highway',
|
19
19
|
:address2 => 'Suite 66',
|
@@ -23,7 +23,18 @@ class AmazonMarketplaceWebServiceTest < Test::Unit::TestCase
|
|
23
23
|
:zip => '90210',
|
24
24
|
:phone => "(555)555-5555"
|
25
25
|
}
|
26
|
-
|
26
|
+
|
27
|
+
@canadian_address = {
|
28
|
+
:name => 'Johnny Bouchard',
|
29
|
+
:address1 => '100 Canuck St',
|
30
|
+
:address2 => 'Room 56',
|
31
|
+
:city => 'Ottawa',
|
32
|
+
:state => 'ON',
|
33
|
+
:country => 'CA',
|
34
|
+
:zip => 'h0h0h0',
|
35
|
+
:phone => "(555)555-5555"
|
36
|
+
}
|
37
|
+
|
27
38
|
@line_items = [
|
28
39
|
{ :sku => 'SETTLERS1',
|
29
40
|
:quantity => 1,
|
@@ -77,7 +88,7 @@ class AmazonMarketplaceWebServiceTest < Test::Unit::TestCase
|
|
77
88
|
"Action" => "SubmitFeed",
|
78
89
|
"FeedType" => "_POST_INVENTORY_AVAILABILITY_DATA_",
|
79
90
|
"Marketplace" => "ATExampleER",
|
80
|
-
"Merchant" => "A1ExampleE6",
|
91
|
+
"Merchant" => "A1ExampleE6",
|
81
92
|
"SignatureMethod" => "HmacSHA256",
|
82
93
|
"SignatureVersion" => "2",
|
83
94
|
"Timestamp" => "2009-08-20T01:10:27.607Z",
|
@@ -85,7 +96,7 @@ class AmazonMarketplaceWebServiceTest < Test::Unit::TestCase
|
|
85
96
|
}
|
86
97
|
|
87
98
|
uri = URI.parse("https://#{AmazonMarketplaceWebService::ENDPOINTS[:us]}")
|
88
|
-
|
99
|
+
|
89
100
|
assert_equal expected_signature, service.sign(:POST, uri, options)
|
90
101
|
end
|
91
102
|
|
@@ -110,6 +121,11 @@ class AmazonMarketplaceWebServiceTest < Test::Unit::TestCase
|
|
110
121
|
assert_equal expected_items, @service.build_address(@address)
|
111
122
|
end
|
112
123
|
|
124
|
+
def test_build_address_upcases_postal_code
|
125
|
+
address = @service.build_address(@canadian_address)
|
126
|
+
assert_equal address["DestinationAddress.PostalCode"], "H0H0H0"
|
127
|
+
end
|
128
|
+
|
113
129
|
def test_build_address_with_missing_fields
|
114
130
|
expected_items = {
|
115
131
|
"DestinationAddress.Name" => @address[:name],
|
@@ -143,7 +159,7 @@ class AmazonMarketplaceWebServiceTest < Test::Unit::TestCase
|
|
143
159
|
}
|
144
160
|
|
145
161
|
actual_items = @service.build_items(@line_items)
|
146
|
-
|
162
|
+
|
147
163
|
assert_equal expected_items, @service.build_items(@line_items)
|
148
164
|
end
|
149
165
|
|
@@ -191,14 +207,14 @@ class AmazonMarketplaceWebServiceTest < Test::Unit::TestCase
|
|
191
207
|
@service.expects(:ssl_post).with() { |uri, query, headers|
|
192
208
|
query.include?('ListInventorySupply') && !query.include?('ListInventorySupplyByNextToken')
|
193
209
|
}.returns(xml_fixture('amazon_mws/inventory_list_inventory_supply_by_next_token'))
|
194
|
-
|
210
|
+
|
195
211
|
@service.expects(:ssl_post).with() { |uri, query, headers|
|
196
212
|
query.include?('ListInventorySupplyByNextToken') && query.include?('NextToken')
|
197
213
|
}.returns(xml_fixture('amazon_mws/inventory_list_inventory_supply'))
|
198
214
|
|
199
215
|
response = @service.fetch_stock_levels
|
200
216
|
assert response.success?
|
201
|
-
|
217
|
+
|
202
218
|
assert_equal 202, response.stock_levels['GN-00-01A']
|
203
219
|
assert_equal 199, response.stock_levels['GN-00-02A']
|
204
220
|
assert_equal 0, response.stock_levels['GN-01-01A']
|
@@ -221,7 +237,6 @@ class AmazonMarketplaceWebServiceTest < Test::Unit::TestCase
|
|
221
237
|
assert_nil response.tracking_numbers['extern_id_1154539615777']
|
222
238
|
end
|
223
239
|
|
224
|
-
|
225
240
|
def test_fetch_multiple_tracking_numbers
|
226
241
|
@service.expects(:ssl_post).returns(xml_fixture('amazon_mws/fulfillment_get_fullfillment_order_with_multiple_tracking_numbers'))
|
227
242
|
|
@@ -230,6 +245,16 @@ class AmazonMarketplaceWebServiceTest < Test::Unit::TestCase
|
|
230
245
|
assert_equal %w{93YY00 93ZZ00}, response.tracking_numbers['extern_id_1154539615776']
|
231
246
|
end
|
232
247
|
|
248
|
+
def test_fetch_tracking_data
|
249
|
+
@service.expects(:ssl_post).returns(xml_fixture('amazon_mws/fulfillment_get_fulfillment_order'))
|
250
|
+
|
251
|
+
response = @service.fetch_tracking_data(['extern_id_1154539615776'])
|
252
|
+
assert response.success?
|
253
|
+
assert_equal %w{93ZZ00}, response.tracking_numbers['extern_id_1154539615776']
|
254
|
+
assert_equal %w{UPS}, response.tracking_companies['extern_id_1154539615776']
|
255
|
+
assert_equal({}, response.tracking_urls)
|
256
|
+
end
|
257
|
+
|
233
258
|
def test_that_generated_requests_do_not_double_escape_spaces
|
234
259
|
fulfillment_request = @service.send(:build_fulfillment_request, "12345", @address, @line_items, @options)
|
235
260
|
result = @service.build_full_query(:post, URI.parse("http://example.com/someservice/2011"), fulfillment_request)
|
@@ -6,13 +6,13 @@ class AmazonTest < Test::Unit::TestCase
|
|
6
6
|
:login => 'l',
|
7
7
|
:password => 'p'
|
8
8
|
)
|
9
|
-
|
10
|
-
@options = {
|
9
|
+
|
10
|
+
@options = {
|
11
11
|
:shipping_method => 'Standard',
|
12
12
|
:order_date => Time.now.utc.yesterday,
|
13
13
|
:comment => "Delayed due to tornados"
|
14
14
|
}
|
15
|
-
|
15
|
+
|
16
16
|
@address = { :name => 'Johnny Chase',
|
17
17
|
:address1 => '100 Information Super Highway',
|
18
18
|
:address2 => 'Suite 66',
|
@@ -21,39 +21,39 @@ class AmazonTest < Test::Unit::TestCase
|
|
21
21
|
:country => 'US',
|
22
22
|
:zip => '90210'
|
23
23
|
}
|
24
|
-
|
24
|
+
|
25
25
|
@line_items = [
|
26
26
|
{ :sku => 'SETTLERS1',
|
27
27
|
:quantity => 1,
|
28
28
|
:comment => 'Awesome'
|
29
29
|
}
|
30
30
|
]
|
31
|
-
end
|
32
|
-
|
31
|
+
end
|
32
|
+
|
33
33
|
def test_successful_fulfillment
|
34
34
|
@service.expects(:ssl_post).returns(successful_fulfillment_response)
|
35
35
|
response = @service.fulfill('12345678', @address, @line_items, @options)
|
36
36
|
assert response.success?
|
37
37
|
end
|
38
|
-
|
39
|
-
def test_invalid_arguments
|
38
|
+
|
39
|
+
def test_invalid_arguments
|
40
40
|
http_response = build_mock_response(invalid_create_response, "", "500")
|
41
41
|
@service.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(http_response))
|
42
42
|
response = @service.fulfill('12345678', @address, @line_items, @options)
|
43
43
|
assert !response.success?
|
44
44
|
assert_equal "aws:Client.MissingParameter The request must contain the parameter Item.", response.params['response_comment']
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
def test_missing_order_comment
|
48
48
|
@options.delete(:comment)
|
49
49
|
assert_raise(ArgumentError) { @service.fulfill('12345678', @address, @line_items, @options) }
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
def test_missing_order_date
|
53
53
|
@options.delete(:order_date)
|
54
54
|
assert_raise(ArgumentError) { @service.fulfill('12345678', @address, @line_items, @options) }
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
def test_missing_shipping_method
|
58
58
|
@options.delete(:shipping_method)
|
59
59
|
assert_raise(ArgumentError) { @service.fulfill('12345678', @address, @line_items, @options) }
|
@@ -69,7 +69,7 @@ class AmazonTest < Test::Unit::TestCase
|
|
69
69
|
|
70
70
|
def test_list_inventory
|
71
71
|
@service.expects(:ssl_post).returns(xml_fixture('amazon/inventory_list_response'))
|
72
|
-
|
72
|
+
|
73
73
|
response = @service.fetch_stock_levels
|
74
74
|
assert response.success?
|
75
75
|
assert_equal 202, response.stock_levels['GN-00-01A']
|
@@ -89,13 +89,13 @@ class AmazonTest < Test::Unit::TestCase
|
|
89
89
|
assert_equal 123, response.stock_levels['GN-02-01A']
|
90
90
|
assert_equal 555, response.stock_levels['GN-02-02A']
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
def test_fetch_tracking_numbers
|
94
94
|
@service.expects(:ssl_post).twice.returns(
|
95
95
|
xml_fixture('amazon/tracking_response_1'),
|
96
96
|
xml_fixture('amazon/tracking_response_2')
|
97
97
|
)
|
98
|
-
|
98
|
+
|
99
99
|
response = @service.fetch_tracking_numbers(['TEST-00000001', 'TEST-00000002'])
|
100
100
|
assert response.success?
|
101
101
|
assert_equal %w{UPS00000001}, response.tracking_numbers['TEST-00000001']
|
@@ -107,12 +107,12 @@ class AmazonTest < Test::Unit::TestCase
|
|
107
107
|
response.stubs(:code).returns(500)
|
108
108
|
response.stubs(:message).returns('Internal Server Error')
|
109
109
|
response.stubs(:body).returns(xml_fixture('amazon/tracking_response_not_found'))
|
110
|
-
|
110
|
+
|
111
111
|
@service.expects(:ssl_post).times(3).
|
112
112
|
returns(xml_fixture('amazon/tracking_response_1')).
|
113
113
|
raises(ActiveMerchant::ResponseError.new(response)).
|
114
114
|
returns(xml_fixture('amazon/tracking_response_2'))
|
115
|
-
|
115
|
+
|
116
116
|
response = @service.fetch_tracking_numbers(['TEST-00000001', '#1337-1', 'TEST-00000002'])
|
117
117
|
assert response.success?
|
118
118
|
assert_equal %w{UPS00000001}, response.tracking_numbers['TEST-00000001']
|
@@ -123,20 +123,30 @@ class AmazonTest < Test::Unit::TestCase
|
|
123
123
|
response.stubs(:code).returns(500)
|
124
124
|
response.stubs(:message).returns('Internal Server Error')
|
125
125
|
response.stubs(:body).returns(xml_fixture('amazon/tracking_response_error'))
|
126
|
-
|
126
|
+
|
127
127
|
@service.expects(:ssl_post).twice.
|
128
128
|
returns(xml_fixture('amazon/tracking_response_1')).
|
129
129
|
raises(ActiveMerchant::ResponseError.new(response))
|
130
|
-
|
130
|
+
|
131
131
|
response = @service.fetch_tracking_numbers(['TEST-00000001', 'ERROR', 'TEST-00000002'])
|
132
132
|
assert !response.success?
|
133
133
|
assert_equal 'Something bad happened!', response.faultstring
|
134
134
|
end
|
135
135
|
|
136
|
+
def test_fetch_tracking_data
|
137
|
+
@service.expects(:ssl_post).returns(xml_fixture('amazon/tracking_response_1'))
|
138
|
+
|
139
|
+
response = @service.fetch_tracking_data(['TEST-00000001'])
|
140
|
+
assert response.success?
|
141
|
+
assert_equal %w{UPS00000001}, response.tracking_numbers['TEST-00000001']
|
142
|
+
assert_equal %W{UPS}, response.tracking_companies['TEST-00000001']
|
143
|
+
assert_equal({}, response.tracking_urls)
|
144
|
+
end
|
145
|
+
|
136
146
|
def test_404_error
|
137
147
|
http_response = build_mock_response(response_from_404, "Not Found", "404")
|
138
148
|
@service.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(http_response))
|
139
|
-
|
149
|
+
|
140
150
|
response = @service.fulfill('12345678', @address, @line_items, @options)
|
141
151
|
assert !response.success?
|
142
152
|
assert_equal "404: Not Found", response.message
|
@@ -144,49 +154,49 @@ class AmazonTest < Test::Unit::TestCase
|
|
144
154
|
assert_equal "Not Found", response.params["http_message"]
|
145
155
|
assert_equal response_from_404, response.params["http_body"]
|
146
156
|
end
|
147
|
-
|
157
|
+
|
148
158
|
def test_soap_fault
|
149
159
|
http_response = build_mock_response(invalid_create_response, "500", "")
|
150
160
|
@service.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(http_response))
|
151
|
-
|
161
|
+
|
152
162
|
response = @service.fulfill('12345678', @address, @line_items, @options)
|
153
163
|
assert !response.success?
|
154
164
|
assert_equal 'aws:Client.MissingParameter', response.params['faultcode']
|
155
165
|
assert_equal 'The request must contain the parameter Item.', response.params['faultstring']
|
156
166
|
assert_equal 'aws:Client.MissingParameter The request must contain the parameter Item.', response.message
|
157
167
|
end
|
158
|
-
|
168
|
+
|
159
169
|
def test_valid_credentials
|
160
170
|
@service.expects(:ssl_post).returns(successful_status_response)
|
161
171
|
assert @service.valid_credentials?
|
162
172
|
end
|
163
|
-
|
173
|
+
|
164
174
|
def test_invalid_credentials
|
165
175
|
http_response = build_mock_response(invalid_login_response, "500", "")
|
166
176
|
@service.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(http_response))
|
167
177
|
assert !@service.valid_credentials?
|
168
178
|
end
|
169
|
-
|
179
|
+
|
170
180
|
def test_successful_service_status
|
171
181
|
@service.expects(:ssl_request).returns(successful_status_response)
|
172
|
-
|
182
|
+
|
173
183
|
response = @service.status
|
174
184
|
assert response.success?
|
175
185
|
end
|
176
|
-
|
186
|
+
|
177
187
|
private
|
178
|
-
|
188
|
+
|
179
189
|
def build_mock_response(response, message, code = "200")
|
180
190
|
http_response = mock(:code => code, :message => message)
|
181
191
|
http_response.stubs(:body).returns(response)
|
182
192
|
http_response
|
183
193
|
end
|
184
|
-
|
194
|
+
|
185
195
|
def response_for_empty_request
|
186
196
|
'<ns:GetErrorResponse xmlns:ns="http://xino.amazonaws.com/doc/"><ns:Error><ns:Code>MissingDateHeader</ns:Code><ns:Message>Authorized request must have a "date" or "x-amz-date" header.</ns:Message></ns:Error><ns:RequestID>79ceaffe-e5a3-46a5-b36a-9ce958d68939</ns:RequestID></ns:GetErrorResponse>'
|
187
197
|
end
|
188
198
|
|
189
|
-
|
199
|
+
|
190
200
|
def invalid_login_response
|
191
201
|
<<-XML
|
192
202
|
<?xml version="1.0"?>
|
@@ -200,10 +210,10 @@ class AmazonTest < Test::Unit::TestCase
|
|
200
210
|
</detail>
|
201
211
|
</env:Fault>
|
202
212
|
</env:Body>
|
203
|
-
</env:Envelope>
|
213
|
+
</env:Envelope>
|
204
214
|
XML
|
205
215
|
end
|
206
|
-
|
216
|
+
|
207
217
|
def invalid_create_response
|
208
218
|
<<-XML
|
209
219
|
<?xml version="1.0"?>
|
@@ -220,11 +230,11 @@ class AmazonTest < Test::Unit::TestCase
|
|
220
230
|
</env:Envelope>
|
221
231
|
XML
|
222
232
|
end
|
223
|
-
|
233
|
+
|
224
234
|
def response_from_404
|
225
235
|
'<html><head><title>Apache Tomcat/5.5.9 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - Servlet XinoServlet is not available</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Servlet XinoServlet is not available</u></p><p><b>description</b> <u>The requested resource (Servlet XinoServlet is not available) is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/5.5.9</h3></body></html>'
|
226
236
|
end
|
227
|
-
|
237
|
+
|
228
238
|
def successful_fulfillment_response
|
229
239
|
<<-XML
|
230
240
|
<?xml version="1.0"?>
|
@@ -239,8 +249,8 @@ class AmazonTest < Test::Unit::TestCase
|
|
239
249
|
</env:Envelope>
|
240
250
|
XML
|
241
251
|
end
|
242
|
-
|
243
|
-
|
252
|
+
|
253
|
+
|
244
254
|
def successful_status_response
|
245
255
|
<<-XML
|
246
256
|
<?xml version="1.0"?>
|
@@ -255,7 +265,7 @@ class AmazonTest < Test::Unit::TestCase
|
|
255
265
|
</ns1:ResponseMetadata>
|
256
266
|
</ns1:GetServiceStatusResponse>
|
257
267
|
</env:Body>
|
258
|
-
</env:Envelope>
|
268
|
+
</env:Envelope>
|
259
269
|
XML
|
260
270
|
end
|
261
271
|
end
|
@@ -3,18 +3,18 @@ require 'test_helper'
|
|
3
3
|
class ShipwireTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
5
|
Base.mode = :test
|
6
|
-
|
6
|
+
|
7
7
|
@shipwire = ShipwireService.new(
|
8
8
|
:login => 'cody@example.com',
|
9
9
|
:password => 'test'
|
10
10
|
)
|
11
|
-
|
12
|
-
@options = {
|
11
|
+
|
12
|
+
@options = {
|
13
13
|
:warehouse => '01',
|
14
14
|
:shipping_method => 'UPS Ground'
|
15
15
|
}
|
16
|
-
|
17
|
-
@address = {
|
16
|
+
|
17
|
+
@address = {
|
18
18
|
:name => 'Fred Brooks',
|
19
19
|
:address1 => '1234 Penny Lane',
|
20
20
|
:city => 'Jonsetown',
|
@@ -24,28 +24,28 @@ class ShipwireTest < Test::Unit::TestCase
|
|
24
24
|
:company => 'MyCorp',
|
25
25
|
:email => 'buyer@jadedpallet.com'
|
26
26
|
}
|
27
|
-
|
27
|
+
|
28
28
|
@line_items = [ { :sku => '9999', :quantity => 25 } ]
|
29
|
-
end
|
30
|
-
|
29
|
+
end
|
30
|
+
|
31
31
|
def test_missing_login
|
32
32
|
assert_raise(ArgumentError) do
|
33
33
|
ShipwireService.new(:password => 'test')
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def test_missing_password
|
38
38
|
assert_raise(ArgumentError) do
|
39
39
|
ShipwireService.new(:login => 'cody')
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def test_missing_credentials
|
44
44
|
assert_raise(ArgumentError) do
|
45
45
|
ShipwireService.new(:password => 'test')
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def test_credentials_present
|
50
50
|
assert_nothing_raised do
|
51
51
|
ShipwireService.new(
|
@@ -54,7 +54,7 @@ class ShipwireTest < Test::Unit::TestCase
|
|
54
54
|
)
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def test_country_format
|
59
59
|
xml = REXML::Document.new(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
|
60
60
|
country_node = REXML::XPath.first(xml, "//Country")
|
@@ -104,11 +104,11 @@ class ShipwireTest < Test::Unit::TestCase
|
|
104
104
|
assert response.success?
|
105
105
|
assert_equal Hash.new, response.tracking_numbers
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
def test_successful_tracking
|
109
109
|
expected = { "2986" => ["1ZW682E90326614239"],
|
110
110
|
"2987" => ["1ZW682E90326795080"] }
|
111
|
-
|
111
|
+
|
112
112
|
successful_tracking_response = xml_fixture('shipwire/successful_tracking_response')
|
113
113
|
@shipwire.expects(:ssl_post).returns(successful_tracking_response)
|
114
114
|
response = @shipwire.fetch_tracking_numbers(["2986", "2987"])
|
@@ -116,10 +116,10 @@ class ShipwireTest < Test::Unit::TestCase
|
|
116
116
|
assert_equal "3", response.params["total_orders"]
|
117
117
|
assert_equal "Test", response.params["status"]
|
118
118
|
assert_equal "2", response.params["total_shipped_orders"]
|
119
|
-
|
119
|
+
|
120
120
|
assert_equal expected, response.tracking_numbers
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
def test_successful_tracking_with_live_data
|
124
124
|
successful_live_tracking_response = xml_fixture('shipwire/successful_live_tracking_response')
|
125
125
|
@shipwire.expects(:ssl_post).returns(successful_live_tracking_response)
|
@@ -132,21 +132,21 @@ class ShipwireTest < Test::Unit::TestCase
|
|
132
132
|
assert_equal "15", response.params["total_orders"]
|
133
133
|
assert_equal "0", response.params["status"]
|
134
134
|
assert_equal "13", response.params["total_shipped_orders"]
|
135
|
-
|
135
|
+
|
136
136
|
assert_equal 13, response.tracking_numbers.size
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
def test_successful_tracking_with_urls
|
140
140
|
successful_tracking_response_with_urls = xml_fixture('shipwire/successful_tracking_response_with_tracking_urls')
|
141
141
|
@shipwire.expects(:ssl_post).returns(successful_tracking_response_with_urls)
|
142
|
-
response = @shipwire.
|
142
|
+
response = @shipwire.fetch_tracking_data(["40289"])
|
143
143
|
assert response.success?
|
144
144
|
assert_equal "1", response.params["total_orders"]
|
145
145
|
assert_equal "Test", response.params["status"]
|
146
146
|
assert_equal "1", response.params["total_shipped_orders"]
|
147
147
|
|
148
148
|
assert_equal ["9400110200793596422990"], response.tracking_numbers["40298"]
|
149
|
-
assert_equal "USPS", response.
|
149
|
+
assert_equal "USPS", response.tracking_companies["40298"]
|
150
150
|
assert_equal ["http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=9400110200793596422990"], response.tracking_urls["40298"]
|
151
151
|
end
|
152
152
|
|
@@ -155,7 +155,7 @@ class ShipwireTest < Test::Unit::TestCase
|
|
155
155
|
@shipwire.expects(:ssl_post).returns(successful_empty_tracing_response)
|
156
156
|
assert @shipwire.valid_credentials?
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
def test_invalid_credentials
|
160
160
|
invalid_login_response = xml_fixture('shipwire/invalid_login_response')
|
161
161
|
@shipwire.expects(:ssl_post).returns(invalid_login_response)
|
@@ -173,7 +173,7 @@ class ShipwireTest < Test::Unit::TestCase
|
|
173
173
|
def test_company_name_in_request
|
174
174
|
xml = REXML::Document.new(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
|
175
175
|
company_node = REXML::XPath.first(xml, "//Company")
|
176
|
-
assert_equal 'MyCorp', company_node.text
|
176
|
+
assert_equal 'MyCorp', company_node.text
|
177
177
|
end
|
178
178
|
|
179
179
|
def test_order_excludes_note_by_default
|