active_shipping 0.1.4 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/README.markdown +0 -3
- data/lib/active_merchant/common.rb +14 -0
- data/lib/{active_shipping/lib → active_merchant/common}/connection.rb +2 -0
- data/lib/{active_shipping/lib → active_merchant/common}/country.rb +0 -0
- data/lib/active_merchant/common/error.rb +26 -0
- data/lib/active_merchant/common/post_data.rb +24 -0
- data/lib/{active_shipping/lib → active_merchant/common}/posts_data.rb +0 -0
- data/lib/{active_shipping/lib → active_merchant/common}/requires_parameters.rb +0 -0
- data/lib/{active_shipping/lib → active_merchant/common}/utils.rb +0 -0
- data/lib/{active_shipping/lib → active_merchant/common}/validateable.rb +0 -0
- data/lib/active_shipping.rb +10 -22
- data/lib/active_shipping/shipping/base.rb +2 -1
- data/lib/active_shipping/shipping/carrier.rb +0 -5
- data/lib/active_shipping/shipping/carriers.rb +2 -1
- data/lib/active_shipping/shipping/carriers/fedex.rb +7 -191
- data/lib/active_shipping/shipping/carriers/kunaki.rb +165 -0
- data/lib/active_shipping/shipping/carriers/ups.rb +2 -1
- data/lib/active_shipping/shipping/carriers/usps.rb +0 -85
- data/lib/active_shipping/shipping/location.rb +1 -4
- data/lib/active_shipping/shipping/response.rb +1 -4
- data/lib/active_shipping/version.rb +3 -0
- data/lib/vendor/quantified/lib/quantified.rb +5 -3
- metadata +68 -102
- data/.gitignore +0 -8
- data/Rakefile +0 -51
- data/VERSION +0 -1
- data/active_shipping.gemspec +0 -152
- data/init.rb +0 -1
- data/lib/active_shipping/lib/error.rb +0 -4
- data/lib/active_shipping/lib/post_data.rb +0 -22
- data/lib/active_shipping/shipping/contact.rb +0 -18
- data/lib/active_shipping/shipping/label.rb +0 -31
- data/lib/active_shipping/shipping/location_response.rb +0 -14
- data/lib/active_shipping/shipping/party.rb +0 -15
- data/lib/active_shipping/shipping/return_label_response.rb +0 -14
- data/lib/active_shipping/shipping/return_shipment.rb +0 -14
- data/lib/active_shipping/shipping/shipment.rb +0 -73
- data/test/fixtures.example.yml +0 -13
- data/test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_request.xml +0 -67
- data/test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_response.xml +0 -213
- data/test/fixtures/xml/fedex/tracking_request.xml +0 -27
- data/test/fixtures/xml/fedex/tracking_response.xml +0 -153
- data/test/fixtures/xml/shipwire/international_rates_response.xml +0 -17
- data/test/fixtures/xml/shipwire/invalid_credentials_response.xml +0 -4
- data/test/fixtures/xml/shipwire/new_carrier_rate_response.xml +0 -18
- data/test/fixtures/xml/shipwire/no_rates_response.xml +0 -7
- data/test/fixtures/xml/shipwire/rates_response.xml +0 -36
- data/test/fixtures/xml/ups/example_tracking_response.xml +0 -53
- data/test/fixtures/xml/ups/shipment_from_tiger_direct.xml +0 -222
- data/test/fixtures/xml/ups/test_real_home_as_residential_destination_response.xml +0 -1
- data/test/fixtures/xml/usps/beverly_hills_to_ottawa_book_rate_response.xml +0 -85
- data/test/fixtures/xml/usps/beverly_hills_to_ottawa_book_wii_rate_response.xml +0 -168
- data/test/fixtures/xml/usps/beverly_hills_to_ottawa_wii_rate_response.xml +0 -85
- data/test/fixtures/xml/usps/example_tracking_response.xml +0 -104
- data/test/fixtures/xml/usps/multi_tracking_example.xml +0 -105
- data/test/party_factory.rb +0 -29
- data/test/remote/fedex_test.rb +0 -160
- data/test/remote/shipwire_test.rb +0 -88
- data/test/remote/ups_test.rb +0 -207
- data/test/remote/usps_test.rb +0 -184
- data/test/shipment_factory.rb +0 -27
- data/test/test_helper.rb +0 -171
- data/test/unit/base_test.rb +0 -18
- data/test/unit/carriers/fedex_test.rb +0 -78
- data/test/unit/carriers/shipwire_test.rb +0 -130
- data/test/unit/carriers/ups_test.rb +0 -81
- data/test/unit/carriers/usps_test.rb +0 -206
- data/test/unit/location_test.rb +0 -46
- data/test/unit/package_test.rb +0 -65
- data/test/unit/party_test.rb +0 -20
- data/test/unit/response_test.rb +0 -10
- data/test/unit/shipment_test.rb +0 -43
@@ -1,88 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
|
3
|
-
class RemoteShipwireTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@packages = TestFixtures.packages
|
7
|
-
@locations = TestFixtures.locations
|
8
|
-
@carrier = Shipwire.new(fixtures(:shipwire))
|
9
|
-
@item1 = { :sku => 'AF0001', :quantity => 2 }
|
10
|
-
@item2 = { :sku => 'AF0002', :quantity => 1 }
|
11
|
-
@items = [@item1, @item2]
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_successful_domestic_rates_request_for_single_line_item
|
15
|
-
response = @carrier.find_rates(
|
16
|
-
@locations[:ottawa],
|
17
|
-
@locations[:beverly_hills],
|
18
|
-
@packages.values_at(:book, :wii),
|
19
|
-
:items => [@item1],
|
20
|
-
:order_id => '#1000'
|
21
|
-
)
|
22
|
-
|
23
|
-
assert response.success?
|
24
|
-
assert_equal 3, response.rates.size
|
25
|
-
assert_equal ['1D', '2D', 'GD'], response.rates.collect(&:service_code).sort
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_successful_domestic_rates_request_for_multiple_line_items
|
29
|
-
response = @carrier.find_rates(
|
30
|
-
@locations[:ottawa],
|
31
|
-
@locations[:beverly_hills],
|
32
|
-
@packages.values_at(:book, :wii),
|
33
|
-
:items => @items,
|
34
|
-
:order_id => '#1000'
|
35
|
-
)
|
36
|
-
|
37
|
-
assert response.success?
|
38
|
-
assert_equal 3, response.rates.size
|
39
|
-
assert_equal ['1D', '2D', 'GD'], response.rates.collect(&:service_code).sort
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_successful_international_rates_request_for_single_line_item
|
43
|
-
response = @carrier.find_rates(
|
44
|
-
@locations[:ottawa],
|
45
|
-
@locations[:london],
|
46
|
-
@packages.values_at(:book, :wii),
|
47
|
-
:items => [@item1],
|
48
|
-
:order_id => '#1000'
|
49
|
-
)
|
50
|
-
|
51
|
-
assert response.success?
|
52
|
-
assert_equal 1, response.rates.size
|
53
|
-
assert_equal ['INTL'], response.rates.collect(&:service_code)
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_invalid_credentials
|
57
|
-
shipwire = Shipwire.new(
|
58
|
-
:login => 'your@email.com',
|
59
|
-
:password => 'password'
|
60
|
-
)
|
61
|
-
|
62
|
-
begin
|
63
|
-
assert_raises(ActiveMerchant::Shipping::ResponseError) do
|
64
|
-
shipwire.find_rates(
|
65
|
-
@locations[:ottawa],
|
66
|
-
@locations[:beverly_hills],
|
67
|
-
@packages.values_at(:book, :wii),
|
68
|
-
:items => @items,
|
69
|
-
:order_id => '#1000'
|
70
|
-
)
|
71
|
-
end
|
72
|
-
rescue ResponseError => e
|
73
|
-
assert_equal "Could not verify e-mail/password combination", response.message
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_validate_credentials_with_valid_credentials
|
78
|
-
assert @carrier.valid_credentials?
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_validate_credentials_with_invalid_credentials
|
82
|
-
shipwire = Shipwire.new(
|
83
|
-
:login => 'your@email.com',
|
84
|
-
:password => 'password'
|
85
|
-
)
|
86
|
-
assert !shipwire.valid_credentials?
|
87
|
-
end
|
88
|
-
end
|
data/test/remote/ups_test.rb
DELETED
@@ -1,207 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
|
3
|
-
class UPSTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@packages = TestFixtures.packages
|
7
|
-
@locations = TestFixtures.locations
|
8
|
-
@carrier = UPS.new(fixtures(:ups))
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_tracking
|
12
|
-
assert_nothing_raised do
|
13
|
-
response = @carrier.find_tracking_info('1Z5FX0076803466397')
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_tracking_with_bad_number
|
18
|
-
assert_raises ResponseError do
|
19
|
-
response = @carrier.find_tracking_info('1Z12345')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_tracking_with_another_number
|
24
|
-
assert_nothing_raised do
|
25
|
-
response = @carrier.find_tracking_info('1Z67Y4260390005815')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_us_to_uk
|
30
|
-
response = nil
|
31
|
-
assert_nothing_raised do
|
32
|
-
response = @carrier.find_rates(
|
33
|
-
@locations[:beverly_hills],
|
34
|
-
@locations[:london],
|
35
|
-
@packages.values_at(:big_half_pound),
|
36
|
-
:test => true
|
37
|
-
)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_puerto_rico
|
42
|
-
response = nil
|
43
|
-
assert_nothing_raised do
|
44
|
-
response = @carrier.find_rates(
|
45
|
-
@locations[:beverly_hills],
|
46
|
-
Location.new(:city => 'Ponce', :country => 'US', :state => 'PR', :zip => '00733-1283'),
|
47
|
-
@packages.values_at(:big_half_pound),
|
48
|
-
:test => true
|
49
|
-
)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_just_country_given
|
54
|
-
response = @carrier.find_rates(
|
55
|
-
@locations[:beverly_hills],
|
56
|
-
Location.new(:country => 'CA'),
|
57
|
-
Package.new(100, [5,10,20])
|
58
|
-
)
|
59
|
-
assert_not_equal [], response.rates
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_ottawa_to_beverly_hills
|
63
|
-
response = nil
|
64
|
-
assert_nothing_raised do
|
65
|
-
response = @carrier.find_rates(
|
66
|
-
@locations[:ottawa],
|
67
|
-
@locations[:beverly_hills],
|
68
|
-
@packages.values_at(:book, :wii),
|
69
|
-
:test => true
|
70
|
-
)
|
71
|
-
end
|
72
|
-
|
73
|
-
assert response.success?, response.message
|
74
|
-
assert_instance_of Hash, response.params
|
75
|
-
assert_instance_of String, response.xml
|
76
|
-
assert_instance_of Array, response.rates
|
77
|
-
assert_not_equal [], response.rates
|
78
|
-
|
79
|
-
rate = response.rates.first
|
80
|
-
assert_equal 'UPS', rate.carrier
|
81
|
-
assert_equal 'CAD', rate.currency
|
82
|
-
assert_instance_of Fixnum, rate.total_price
|
83
|
-
assert_instance_of Fixnum, rate.price
|
84
|
-
assert_instance_of String, rate.service_name
|
85
|
-
assert_instance_of String, rate.service_code
|
86
|
-
assert_instance_of Array, rate.package_rates
|
87
|
-
assert_equal @packages.values_at(:book, :wii), rate.packages
|
88
|
-
|
89
|
-
package_rate = rate.package_rates.first
|
90
|
-
assert_instance_of Hash, package_rate
|
91
|
-
assert_instance_of Package, package_rate[:package]
|
92
|
-
assert_nil package_rate[:rate]
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_ottawa_to_us_fails_without_zip
|
96
|
-
assert_raises ResponseError do
|
97
|
-
@carrier.find_rates(
|
98
|
-
@locations[:ottawa],
|
99
|
-
Location.new(:country => 'US'),
|
100
|
-
@packages.values_at(:book, :wii),
|
101
|
-
:test => true
|
102
|
-
)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_ottawa_to_us_succeeds_with_only_zip
|
107
|
-
assert_nothing_raised do
|
108
|
-
@carrier.find_rates(
|
109
|
-
@locations[:ottawa],
|
110
|
-
Location.new(:country => 'US', :zip => 90210),
|
111
|
-
@packages.values_at(:book, :wii),
|
112
|
-
:test => true
|
113
|
-
)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_us_to_uk_with_different_pickup_types
|
118
|
-
assert_nothing_raised do
|
119
|
-
daily_response = @carrier.find_rates(
|
120
|
-
@locations[:beverly_hills],
|
121
|
-
@locations[:london],
|
122
|
-
@packages.values_at(:book, :wii),
|
123
|
-
:pickup_type => :daily_pickup,
|
124
|
-
:test => true
|
125
|
-
)
|
126
|
-
one_time_response = @carrier.find_rates(
|
127
|
-
@locations[:beverly_hills],
|
128
|
-
@locations[:london],
|
129
|
-
@packages.values_at(:book, :wii),
|
130
|
-
:pickup_type => :one_time_pickup,
|
131
|
-
:test => true
|
132
|
-
)
|
133
|
-
assert_not_equal daily_response.rates.map(&:price), one_time_response.rates.map(&:price)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_bare_packages
|
138
|
-
response = nil
|
139
|
-
p = Package.new(0,0)
|
140
|
-
assert_nothing_raised do
|
141
|
-
response = @carrier.find_rates(
|
142
|
-
@locations[:beverly_hills], # imperial (U.S. origin)
|
143
|
-
@locations[:ottawa],
|
144
|
-
p,
|
145
|
-
:test => true
|
146
|
-
)
|
147
|
-
end
|
148
|
-
assert response.success?, response.message
|
149
|
-
assert_nothing_raised do
|
150
|
-
response = @carrier.find_rates(
|
151
|
-
@locations[:ottawa],
|
152
|
-
@locations[:beverly_hills], # metric
|
153
|
-
p,
|
154
|
-
:test => true
|
155
|
-
)
|
156
|
-
end
|
157
|
-
assert response.success?, response.message
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_different_rates_for_residential_and_commercial_destinations
|
161
|
-
responses = {}
|
162
|
-
locations = [
|
163
|
-
:real_home_as_residential, :real_home_as_commercial,
|
164
|
-
:fake_home_as_residential, :fake_home_as_commercial,
|
165
|
-
:real_google_as_residential, :real_google_as_commercial,
|
166
|
-
:fake_google_as_residential, :fake_google_as_commercial
|
167
|
-
]
|
168
|
-
|
169
|
-
locations.each do |location|
|
170
|
-
responses[location] = @carrier.find_rates(
|
171
|
-
@locations[:beverly_hills],
|
172
|
-
@locations[location],
|
173
|
-
@packages.values_at(:chocolate_stuff)
|
174
|
-
)
|
175
|
-
end
|
176
|
-
|
177
|
-
prices_of = lambda {|sym| responses[sym].rates.map(&:price)}
|
178
|
-
|
179
|
-
# this is how UPS does things...
|
180
|
-
# if it's a real residential address and UPS knows it, then they return
|
181
|
-
# residential rates whether or not we have the ResidentialAddressIndicator:
|
182
|
-
assert_equal prices_of.call(:real_home_as_residential), prices_of.call(:real_home_as_commercial)
|
183
|
-
|
184
|
-
# if UPS doesn't know about the address, and we HAVE the ResidentialAddressIndicator,
|
185
|
-
# then UPS will default to residential rates:
|
186
|
-
assert_equal prices_of.call(:real_home_as_residential), prices_of.call(:fake_home_as_residential)
|
187
|
-
|
188
|
-
# if UPS doesn't know about the address, and we DON'T have the ResidentialAddressIndicator,
|
189
|
-
# then UPS will default to commercial rates:
|
190
|
-
assert_not_equal prices_of.call(:fake_home_as_residential), prices_of.call(:fake_home_as_commercial)
|
191
|
-
assert prices_of.call(:fake_home_as_residential).first > prices_of.call(:fake_home_as_commercial).first
|
192
|
-
|
193
|
-
|
194
|
-
# if it's a real commercial address and UPS knows it, then they return
|
195
|
-
# commercial rates whether or not we have the ResidentialAddressIndicator:
|
196
|
-
assert_equal prices_of.call(:real_google_as_commercial), prices_of.call(:real_google_as_residential)
|
197
|
-
|
198
|
-
# if UPS doesn't know about the address, and we DON'T have the ResidentialAddressIndicator,
|
199
|
-
# then UPS will default to commercial rates:
|
200
|
-
assert_equal prices_of.call(:real_google_as_commercial), prices_of.call(:fake_google_as_commercial)
|
201
|
-
|
202
|
-
# if UPS doesn't know about the address, and we HAVE the ResidentialAddressIndicator,
|
203
|
-
# then UPS will default to residential rates:
|
204
|
-
assert_not_equal prices_of.call(:fake_google_as_commercial), prices_of.call(:fake_google_as_residential)
|
205
|
-
assert prices_of.call(:fake_home_as_residential).first > prices_of.call(:fake_home_as_commercial).first
|
206
|
-
end
|
207
|
-
end
|
data/test/remote/usps_test.rb
DELETED
@@ -1,184 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
|
3
|
-
class USPSTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@packages = TestFixtures.packages
|
7
|
-
@locations = TestFixtures.locations
|
8
|
-
@carrier = USPS.new(fixtures(:usps))
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_machinable_rate_discrepancy
|
12
|
-
assert_nothing_raised do
|
13
|
-
default_machinable_response = @carrier.find_rates(
|
14
|
-
Location.new(:zip => 83843),
|
15
|
-
Location.new(:zip => 70001),
|
16
|
-
Package.new(32, [12,6,2], :units => :imperial)
|
17
|
-
)
|
18
|
-
assert default_machinable_response.request =~ /<Machinable>TRUE<\/Machinable>/
|
19
|
-
|
20
|
-
explicit_non_machinable_response = @carrier.find_rates(
|
21
|
-
Location.new(:zip => 83843),
|
22
|
-
Location.new(:zip => 70001),
|
23
|
-
Package.new(32, [12,6,2], :units => :imperial, :machinable => false)
|
24
|
-
)
|
25
|
-
assert explicit_non_machinable_response.request =~ /<Machinable>FALSE<\/Machinable>/
|
26
|
-
|
27
|
-
assert_not_equal default_machinable_response.rates.map(&:price),
|
28
|
-
explicit_non_machinable_response.rates.map(&:price)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_zip_to_zip
|
33
|
-
assert_nothing_raised do
|
34
|
-
response = @carrier.find_rates(
|
35
|
-
Location.new(:zip => 40524),
|
36
|
-
Location.new(:zip => 40515),
|
37
|
-
Package.new(16, [12,6,2], :units => :imperial)
|
38
|
-
)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_just_country_given
|
43
|
-
assert_nothing_raised do
|
44
|
-
response = @carrier.find_rates(
|
45
|
-
@locations[:beverly_hills],
|
46
|
-
Location.new(:country => 'CZ'),
|
47
|
-
Package.new(100, [5,10,20])
|
48
|
-
)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_us_to_canada
|
53
|
-
response = nil
|
54
|
-
assert_nothing_raised do
|
55
|
-
response = @carrier.find_rates(
|
56
|
-
@locations[:beverly_hills],
|
57
|
-
@locations[:ottawa],
|
58
|
-
@packages.values_at(:wii),
|
59
|
-
:test => true
|
60
|
-
)
|
61
|
-
assert_not_equal [], response.rates.length
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_domestic_rates_thoroughly
|
66
|
-
response = nil
|
67
|
-
assert_nothing_raised do
|
68
|
-
response = @carrier.find_rates(
|
69
|
-
@locations[:new_york],
|
70
|
-
@locations[:beverly_hills],
|
71
|
-
@packages.values_at(:book,:wii),
|
72
|
-
:test => true
|
73
|
-
)
|
74
|
-
end
|
75
|
-
assert response.success?, response.message
|
76
|
-
assert_instance_of Hash, response.params
|
77
|
-
assert_instance_of String, response.xml
|
78
|
-
assert_instance_of Array, response.rates
|
79
|
-
assert_not_equal [], response.rates
|
80
|
-
|
81
|
-
rate = response.rates.first
|
82
|
-
assert_equal 'USPS', rate.carrier
|
83
|
-
assert_equal 'USD', rate.currency
|
84
|
-
assert_instance_of Fixnum, rate.total_price
|
85
|
-
assert_instance_of Fixnum, rate.price
|
86
|
-
assert_instance_of String, rate.service_name
|
87
|
-
assert_instance_of String, rate.service_code
|
88
|
-
assert_instance_of Array, rate.package_rates
|
89
|
-
assert_equal @packages.values_at(:book, :wii), rate.packages
|
90
|
-
|
91
|
-
package_rate = rate.package_rates.first
|
92
|
-
assert_instance_of Hash, package_rate
|
93
|
-
assert_instance_of Package, package_rate[:package]
|
94
|
-
assert_not_nil package_rate[:rate]
|
95
|
-
|
96
|
-
other_than_two = response.rates.map(&:package_count).reject {|n| n == 2}
|
97
|
-
assert_equal [], other_than_two, "Some RateEstimates do not refer to the right number of packages (#{other_than_two.inspect})"
|
98
|
-
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_international_thoroughly
|
103
|
-
|
104
|
-
response = nil
|
105
|
-
assert_nothing_raised do
|
106
|
-
response = @carrier.find_rates(
|
107
|
-
@locations[:beverly_hills],
|
108
|
-
@locations[:ottawa],
|
109
|
-
@packages.values_at(:book, :wii),
|
110
|
-
:test => true
|
111
|
-
)
|
112
|
-
end
|
113
|
-
|
114
|
-
assert response.success?, response.message
|
115
|
-
assert_instance_of Hash, response.params
|
116
|
-
assert_instance_of String, response.xml
|
117
|
-
assert_instance_of Array, response.rates
|
118
|
-
assert_not_equal [], response.rates
|
119
|
-
|
120
|
-
rate = response.rates.first
|
121
|
-
assert_equal 'USPS', rate.carrier
|
122
|
-
assert_equal 'USD', rate.currency
|
123
|
-
assert_instance_of Fixnum, rate.total_price
|
124
|
-
assert_instance_of Fixnum, rate.price
|
125
|
-
assert_instance_of String, rate.service_name
|
126
|
-
assert_instance_of String, rate.service_code
|
127
|
-
assert_instance_of Array, rate.package_rates
|
128
|
-
assert_equal @packages.values_at(:book, :wii), rate.packages
|
129
|
-
|
130
|
-
package_rate = rate.package_rates.first
|
131
|
-
assert_instance_of Hash, package_rate
|
132
|
-
assert_instance_of Package, package_rate[:package]
|
133
|
-
assert_not_nil package_rate[:rate]
|
134
|
-
|
135
|
-
other_than_two = response.rates.map(&:package_count).reject {|n| n == 2}
|
136
|
-
assert_equal [], other_than_two, "Some RateEstimates do not refer to the right number of packages (#{other_than_two.inspect})"
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_bare_packages
|
141
|
-
response = nil
|
142
|
-
p = Package.new(0,0)
|
143
|
-
response = begin
|
144
|
-
@carrier.find_rates(
|
145
|
-
@locations[:beverly_hills], # imperial (U.S. origin)
|
146
|
-
@locations[:ottawa],
|
147
|
-
p,
|
148
|
-
:test => true
|
149
|
-
)
|
150
|
-
rescue ResponseError => e
|
151
|
-
e.response
|
152
|
-
end
|
153
|
-
assert response.success?, response.message
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_valid_credentials
|
157
|
-
assert USPS.new(fixtures(:usps).merge(:test => true)).valid_credentials?
|
158
|
-
end
|
159
|
-
|
160
|
-
# Uncomment and switch out SPECIAL_COUNTRIES with some other batch to see which
|
161
|
-
# countries are currently working. Commented out here just because it's a lot of
|
162
|
-
# hits to their server at once:
|
163
|
-
|
164
|
-
# ALL_COUNTRIES = ActiveMerchant::Country.const_get('COUNTRIES').map {|c| c[:alpha2]}
|
165
|
-
# SPECIAL_COUNTRIES = USPS.const_get('COUNTRY_NAME_CONVERSIONS').keys.sort
|
166
|
-
# NORMAL_COUNTRIES = (ALL_COUNTRIES - SPECIAL_COUNTRIES)
|
167
|
-
#
|
168
|
-
# SPECIAL_COUNTRIES.each do |code|
|
169
|
-
# unless ActiveMerchant::Country.find(code).name == USPS.const_get('COUNTRY_NAME_CONVERSIONS')[code]
|
170
|
-
# define_method("test_country_#{code}") do
|
171
|
-
# response = nil
|
172
|
-
# begin
|
173
|
-
# response = @carrier.find_rates( @locations[:beverly_hills],
|
174
|
-
# Location.new(:country => code),
|
175
|
-
# @packages.values_at(:wii),
|
176
|
-
# :test => true)
|
177
|
-
# rescue Exception => e
|
178
|
-
# flunk(e.inspect + "\nrequest: " + @carrier.last_request)
|
179
|
-
# end
|
180
|
-
# assert_not_equal [], response.rates.length
|
181
|
-
# end
|
182
|
-
# end
|
183
|
-
# end
|
184
|
-
end
|