usps
usps copied to clipboard
Problem with `rake certify`
No runtime errors, but some failing tests:
➜ usps git:(add_shipping_labels) bundle exec rake certify
/Users/alandelevie/.rbenv/versions/2.1.5/bin/ruby -rubygems -Ilib lib/usps/test.rb
Run options:
# Running tests:
[1/8] USPS::Test#test_address_standardization_1 = 0.19 s
1) Failure:
USPS::Test#test_address_standardization_1 [/Users/alandelevie/usps/lib/usps/test/address_verification.rb:14]:
<"1440"> expected but was
<"1441">.
[5/8] USPS::Test#test_tracking_lookup_1 = 0.21 s
2) Failure:
USPS::Test#test_tracking_lookup_1 [/Users/alandelevie/usps/lib/usps/test/tracking_lookup.rb:8]:
<"Your item was delivered at 8:10 am on June 1 in Wilmington DE 19801."> expected but was
<"There is no record of that mail item. If it was mailed recently, it may not yet be tracked. Please try again later.">.
[6/8] USPS::Test#test_tracking_lookup_2 = 0.20 s
3) Failure:
USPS::Test#test_tracking_lookup_2 [/Users/alandelevie/usps/lib/usps/test/tracking_lookup.rb:21]:
<"Your item was delivered at 1:39 pm on June 1 in WOBURN MA 01815."> expected but was
<"There is no record of that mail item. If it was mailed recently, it may not yet be tracked. Please try again later.">.
[7/8] USPS::Test#test_zip_code_lookup_1 = 0.12 s
4) Failure:
USPS::Test#test_zip_code_lookup_1 [/Users/alandelevie/usps/lib/usps/test/zip_code_lookup.rb:17]:
<"1440"> expected but was
<"1441">.
Finished tests in 1.065323s, 7.5095 tests/s, 26.2831 assertions/s.
8 tests, 28 assertions, 4 failures, 0 errors, 0 skips
ruby -v: ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin13.0]
rake aborted!
Command failed with status (4): [/Users/alandelevie/.rbenv/versions/2.1.5/b...]
/Users/alandelevie/usps/Rakefile:9:in `block in <top (required)>'
Tasks: TOP => certify
(See full trace by running task with --trace)
I'm wondering if the test expectations should just be updated. Thoughts, @gaffneyc?
@adelevie Seems like s/1440/1441/ would be cool, but the other ones need more investigation.
The tracker_ids hard-coded in the test/unit files don't appear to exist in the testing API.
I have different errors
root@88b3a5a2ef7c:/usr/src/app# USPS_USER="XXXXXXX" ruby -e "require 'usps/test'"
Loaded suite -e
Started
F
========================================================================================================================================
/usr/local/bundle/gems/usps-0.1.3/lib/usps/test/address_verification.rb:14:in `test_address_standardization_1'
11: assert_equal 'GREENBELT', address.city
12: assert_equal 'MD', address.state
13: assert_equal '20770', address.zip5
=> 14: assert_equal '1440', address.zip4
15: end
16:
17: def test_address_standardization_2
<"1440"> expected but was
<"1441">
diff:
? 1440
? 1
Failure: test_address_standardization_1(USPS::Test)
========================================================================================================================================
...E
========================================================================================================================================
/usr/local/bundle/gems/usps-0.1.3/lib/usps/test/tracking_lookup.rb:6:in `test_tracking_lookup_1'
3: def test_tracking_lookup_1
4: tracker_id = "EJ958083578US"
5: request = USPS::Request::TrackingLookup.new(tracker_id)
=> 6: results = request.send!
7:
8: assert_equal "Your item was delivered at 8:10 am on June 1 in Wilmington DE 19801.", results.summary
9: assert_equal 3, results.details.length
/usr/local/bundle/gems/usps-0.1.3/lib/usps/request/base.rb:22:in `send!'
/usr/local/bundle/gems/usps-0.1.3/lib/usps/client.rb:29:in `request'
Error: test_tracking_lookup_1(USPS::Test): USPS::Error: API Disabled: TrackV2. This test request is no longer valid. Please use http://stg-production.shippingapis.com/ShippingAPI.dll.
========================================================================================================================================
E
========================================================================================================================================
/usr/local/bundle/gems/usps-0.1.3/lib/usps/test/tracking_lookup.rb:19:in `test_tracking_lookup_2'
16: def test_tracking_lookup_2
17: tracker_id = "EJ958088694US"
18: request = USPS::Request::TrackingLookup.new(tracker_id)
=> 19: results = request.send!
20:
21: assert_equal "Your item was delivered at 1:39 pm on June 1 in WOBURN MA 01815.", results.summary
22: assert_equal 3, results.details.length
/usr/local/bundle/gems/usps-0.1.3/lib/usps/request/base.rb:22:in `send!'
/usr/local/bundle/gems/usps-0.1.3/lib/usps/client.rb:29:in `request'
Error: test_tracking_lookup_2(USPS::Test): USPS::Error: API Disabled: TrackV2. This test request is no longer valid. Please use http://stg-production.shippingapis.com/ShippingAPI.dll.
========================================================================================================================================
F
========================================================================================================================================
/usr/local/bundle/gems/usps-0.1.3/lib/usps/test/zip_code_lookup.rb:17:in `test_zip_code_lookup_1'
14: assert_equal 'GREENBELT', address.city
15: assert_equal 'MD', address.state
16: assert_equal '20770', address.zip5
=> 17: assert_equal '1440', address.zip4
18: end
19:
20: def test_zip_code_lookup_2
<"1440"> expected but was
<"1441">
diff:
? 1440
? 1
Failure: test_zip_code_lookup_1(USPS::Test)
========================================================================================================================================
.
Finished in 3.977059182 seconds.
----------------------------------------------------------------------------------------------------------------------------------------
8 tests, 26 assertions, 2 failures, 2 errors, 0 pendings, 0 omissions, 0 notifications
50% passed
----------------------------------------------------------------------------------------------------------------------------------------
2.01 tests/s, 6.54 assertions/s
Certification is mostly working as a result of #24, with the exception of TrackingLookup. I've sent this email to USPS support:
To: [email protected]
Subject: Testing values / testing environment for TrackV2?
Hello,
When testing TrackV2 / TrackRequest in the external test environment (http://stg-production.shippingapis.com/ShippingAPI.dll) I receive the error "UNABLE TO RESPOND".
My username is XXXXXXXX.
I would like to test against these values to receive the documented expected responses:
Test Request #1: TrackID=EJ958083578US: Your item was delivered at 8:10 am on June 1 in Wilmington DE 19801.
Test Request #1: TrackID=EJ958088694US: Your item was delivered at 1:39 pm on June 1 in WOBURN MA 01815.
I have also tried using the production environment (http://production.shippingapis.com/ShippingAPI.dll) with these values which return "A status update is not yet available on your package..."
Are there working test values/server endpoints for Track that will provide valid responses for testing purposes?
Thank you for the help!
Ben
I received a response with TrackV2 test value:
Thank you for contacting Web Tools. See below for test TrackIDs to be used in the testing environment (https://stg-secure.shippingapis.com/shippingapi.dll)
| Mail Class | TrackIDs |
|---|---|
| Priority Mail Express | 9470103699300749123003 |
| 9470103699300749123010 | |
| 9470103699300749123027 | |
| 9470103699300749123034 | |
| 9470103699300749123041 | |
| Priority Mail | 9405503699300749123052 |
| 9405503699300749123069 | |
| 9405503699300749123076 | |
| 9405503699300749123083 | |
| 9405503699300749123090 | |
| First-Class | 9474203699300749123105 |
| 9474203699300749123112 | |
| 9474203699300749123129 | |
| 9474203699300749123136 | |
| 9474203699300749123143 | |
| Parcel Select | 9464203699300749123153 |
| 9464203699300749123160 | |
| 9464203699300749123177 | |
| 9464203699300749123184 | |
| 9464203699300749123191 | |
| Parcel Select Lightweight | 9478903699300749123209 |
| 9478903699300749123216 | |
| 9478903699300749123223 | |
| 9478903699300749123230 | |
| 9478903699300749123247 | |
| Marketing Mail | 9470303699300749123250 |
| 9470303699300749123267 | |
| 9470303699300749123274 | |
| 9470303699300749123281 | |
| 9470303699300749123298 | |
| Media Mail | 9452103699300749123304 |
| 9452103699300749123311 | |
| 9452103699300749123328 | |
| 9452103699300749123335 | |
| 9452103699300749123342 | |
| Bound Printed Matter | 9445803699300749123358 |
| 9445803699300749123365 | |
| 9445803699300749123372 | |
| 9445803699300749123389 | |
| 9445803699300749123396 | |
| First-Class Package International | DS123000001GB |
| DS123000002GB | |
| DS123000003GB | |
| DS123000004GB | |
| DS123000005GB | |
| Priority Mail International | RA123000011GB |
| RA123000012GB | |
| RA123000013GB | |
| RA123000014GB | |
| RA123000015GB | |
| Priority Mail Express International | ES123000021GB |
| ES123000022GB | |
| ES123000023GB | |
| ES123000024GB | |
| ES123000025GB |