imap_to_rss 1.0.1 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,737 @@
1
+ require 'imap_to_rss/test_case'
2
+
3
+ class TestIMAPToRSSHandlerAmazon < IMAPToRSS::TestCase
4
+
5
+ def setup
6
+ super IMAPToRSS::Handler::Amazon.new
7
+ end
8
+
9
+ def test_add_item
10
+ @handler.mail = util_mail
11
+
12
+ @handler.add_item 'toy', 'fun to play with', 'http://example.com/item'
13
+
14
+ assert_equal 1, @itor.rss_items.length
15
+
16
+ rss_item = @itor.rss_items.first
17
+ assert_equal 'toy', rss_item.title
18
+ assert_equal 'fun to play with', rss_item.description
19
+ assert_equal ['from@example.com'], rss_item.author
20
+ assert_equal Time.at(0), rss_item.pub_date
21
+ assert_equal 'http://example.com/item', rss_item.link
22
+ assert_equal nil, rss_item.guid
23
+ assert_equal 'Amazon', rss_item.category
24
+ end
25
+
26
+ def test_add_order
27
+ @handler.mail = util_mail :body => <<-BODY
28
+ Thanks for ordering from Amazon.com! Your purchase information appears below.
29
+
30
+ Want to manage your order online?
31
+ If you need to check the status of your order or make changes, please visit our home page at Amazon.com and click on Your Account at the top of any page.
32
+ ***********************************************************
33
+ BILLING AND SHIPPING INFORMATION
34
+ ***********************************************************
35
+ E-mail Address: nobody@example.com
36
+ Billing Address:
37
+ Eric Hodel
38
+ 100 Any Street
39
+ Seattle, WA 98122
40
+ United States
41
+
42
+ Order Grand Total: $51.45
43
+
44
+ Get the Amazon.com Visa Card, the Amazon.com Business Visa Card or the Amazon.com Student Visa Card instantly and automatically get $30 back after your first purchase. Plus get up to 3% rewards. Click http://www.amazon.com/InstantRewards for more information.
45
+
46
+ ***********************************************************
47
+ ORDER DETAILS
48
+ ***********************************************************
49
+
50
+ Please note: Pre-order Price Guarantee covers one or more item(s) in this order. If the Amazon.com price decreases between your order time and the release date, you'll receive the lowest price. See details here http://www.amazon.com/exec/obidos/tg/browse/-/468502
51
+
52
+ Shipping Details
53
+
54
+ (order will arrive in 1 shipment)
55
+ ***********************************************************
56
+ Order number: 000-1111111-2222222
57
+ View your Order Summary online: https://www.amazon.com/gp/css/history/view.html
58
+ Shipping Method: FREE Super Saver Shipping
59
+ Shipping Preference: Group my items into as few shipments as possible
60
+
61
+ Subtotal of Items: $46.99
62
+ Shipping & Handling: $4.49
63
+ Super Saver Discount: -$4.49
64
+ Pre-order Guarantee: -$0.00
65
+ ---------
66
+ Total before tax: $46.99
67
+ Estimated Tax: $4.46
68
+ ---------
69
+ Total for this Order: $51.45
70
+
71
+ Shipping To
72
+
73
+ Eric Hodel
74
+ 100 Any Street
75
+ Seattle, WA 98122
76
+ United States
77
+
78
+ Shipping estimate for these items: September 28, 2009
79
+
80
+ 1 "Katamari Forever"
81
+ Video Game; $46.99
82
+
83
+ Sold by: Amazon.com, LLC
84
+
85
+ Because of Pre-order Price Guarantee, you might pay less. Learn more at http://www.amazon.com/exec/obidos/tg/browse/-/468502
86
+
87
+ ***********************************************************
88
+ Our Pre-order Price Guarantee covers one or more item(s) in this order. If the Amazon.com price decreases between the time you place your order and the end of the day of the release date, you'll receive the lowest price.
89
+ ***********************************************************
90
+ Need to give a gift? Not sure what to buy?
91
+ Amazon.com gift certificates/cards are availablein any dollar amount from $5 to $5,000.
92
+ We'll deliver it via e-mail--it's the perfect last-minute gift.
93
+ Learn more at http://www.amazon.com/gift-certificates
94
+ ***********************************************************
95
+ Got questions? We've got answers. Visit our online Help department, available 24 hours a day: http://www.amazon.com/help
96
+
97
+ ***********************************************************
98
+ Please note: This e-mail message was sent from a notification-only address that cannot accept incoming e-mail. Please do not reply to this message.
99
+ Thanks again for shopping with us.
100
+ -------------------------------------------------------------
101
+ Amazon.com
102
+ Earth's Biggest Selection
103
+ http://www.amazon.com
104
+ -------------------------------------------------------------
105
+ BODY
106
+
107
+ @handler.add_order @handler.mail.body
108
+
109
+ assert_equal 1, @itor.rss_items.length
110
+
111
+ rss_item = @itor.rss_items.first
112
+ assert_equal 'Amazon order 000-1111111-2222222', rss_item.title
113
+ description = <<-DESC
114
+ <p>Total: $51.45
115
+ <table>
116
+ <tr><th>Quantity<th>Description
117
+ <tr><td>1<td>Katamari Forever
118
+ </table>
119
+
120
+ DESC
121
+ assert_equal description, rss_item.description
122
+ assert_equal ['from@example.com'], rss_item.author
123
+ assert_equal Time.at(0), rss_item.pub_date
124
+ assert_equal 'https://www.amazon.com/gp/css/summary/edit.html?ie=UTF8&orderID=000-1111111-2222222',
125
+ rss_item.link
126
+ assert_equal nil, rss_item.guid
127
+ assert_equal 'Amazon', rss_item.category
128
+ end
129
+
130
+ def test_aws_bill
131
+ @handler.mail = util_mail :body => <<-BODY
132
+ Greetings from Amazon Web Services,
133
+
134
+ This e-mail confirms that your latest billing statement is available on the AWS web site. Your account will be charged the following:
135
+
136
+ Total: $0.10
137
+
138
+ Please see the Account Activity area of the AWS web site for detailed account information:
139
+
140
+ http://example.com/aws/bill
141
+
142
+ Thank you for your continuing interest in Amazon Web Services.
143
+
144
+ Sincerely,
145
+
146
+ Amazon Web Services
147
+
148
+ This message was produced and distributed by Amazon Web Services LLC, 1200 12th Avenue South, Seattle, Washington 98144-2734
149
+ BODY
150
+
151
+ @handler.aws_bill
152
+
153
+ assert_equal 1, @itor.rss_items.length
154
+
155
+ rss_item = @itor.rss_items.first
156
+ assert_equal 'Amazon Web Services Bill: $0.10', rss_item.title
157
+ assert_equal '', rss_item.description
158
+ assert_equal ['from@example.com'], rss_item.author
159
+ assert_equal Time.at(0), rss_item.pub_date
160
+ assert_equal 'http://example.com/aws/bill', rss_item.link
161
+ assert_equal nil, rss_item.guid
162
+ assert_equal 'Amazon', rss_item.category
163
+ end
164
+
165
+ def test_gift_card
166
+ @handler.mail = util_mail :body => <<-BODY
167
+ You've received an Amazon.com gift card! The generous person who gave you this gift is
168
+ listed below.
169
+
170
+ DON'T DELETE THIS MESSAGE! You'll need the claim code below to place your order.
171
+
172
+ Happy shopping!
173
+
174
+
175
+ Amazon.com Gift Cards Team
176
+ http://www.amazon.com/gc
177
+
178
+ ***********************************************************************
179
+
180
+ To: Me
181
+ Amount: $100.00
182
+ From: You
183
+ Gift Message: Thanks!
184
+
185
+ Claim code AAAA-BBBBBB-CCCC
186
+ Order DDD-EEEEEEE-FFFFFFF
187
+
188
+ To begin shopping now:
189
+
190
+ 1. Visit our Web site at http://www.amazon.com
191
+
192
+ 2. Select the items you want; you can add them to your Shopping Cart or use 1-Click ordering.
193
+
194
+ 3. If you're checking out from the Shopping Cart, redeem your gift card by entering the claim code on the order form.
195
+ If you're placing an order with 1-Click:
196
+ Click the "Review or edit your 1-Click orders" link that you'll see after clicking the
197
+ "Buy now with 1-Click" button and enter the code in the Payment section on the next page.
198
+
199
+ Not ready to use it yet?
200
+
201
+ Just add the gift card funds to your account so they'll be there when you're ready!
202
+
203
+ 1. Go to Your Account.
204
+ 2. Click "Apply a gift card to your account" under "Payment Settings".
205
+ 3. Sign in with your e-mail address and password.
206
+ 4. Enter your claim code and click "Redeem now". Your funds will automatically be applied to your next order.
207
+
208
+ For more information on using your gift card, visit http://www.amazon.com/help/gc
209
+
210
+
211
+ TERMS AND CONDITIONS:
212
+ 1. Redemption. Gift Cards must be redeemed through the Amazon.com Web site, http://www.amazon.com, toward the purchase of eligible products. Purchases are deducted from the Gift Card balance. Any unused balance will be placed in the recipient's Gift Card account when redeemed. If an order exceeds the amount of the Gift Card, the balance must be paid with a credit card or other available payment method. To redeem or view Gift Card balances, visit "Your Account" on Amazon.com.
213
+ 2. Limitations.
214
+ * Gift Cards cannot be redeemed for purchases of from some third party sellers (including Eddie Bauer, Newport News, and The Bombay Company), or at Amazon Auctions. Additional ineligible sellers may be added. Please check the Amazon.com Web site at http://www.amazon.com/gc-legal for the most current list.
215
+ * Gift Cards may not be redeemed for the purchase of products through in-store pickup, or at Amazon.co.uk, Amazon.de, Amazon.fr, Amazon.co.jp, Amazon.ca, or any other Web site operated by Amazon.com, its affiliates, or any other person or entity.
216
+ * Gift Cards cannot be used to purchase other Gift Cards, such as Amazon.com Gift Cards, Target Gift Cards, or Borders Gift Cards.
217
+ * Gift Cards cannot be reloaded, resold, transferred for value, redeemed for cash or applied to any other account, except to the extent required by law. Unused Gift Card balances in an Amazon account may not be transferred.
218
+ 3. Our Policies. Gift Cards and their use on the Amazon.com Web site are subject to Amazon.com's general Conditions of Use and Privacy Notice. Amazon.com may provide Gift Card purchasers with information about the redemption status of Gift Cards.
219
+ 4. Risk of Loss. The risk of loss and title for Gift Cards pass to the purchaser upon our electronic transmission to the recipient or delivery to the carrier, whichever is applicable. We are not responsible for lost or stolen Gift Cards. If you have any questions, please see www.amazon.com/gc.
220
+ 5. Fraud. Amazon.com will have the right to close customer accounts and request alternative forms of payment if a fraudulently obtained Gift Card is either redeemed through the Amazon.com Web site or is redeemed and used to make purchases on the Amazon.com Web site.
221
+ 6. Limitation of Liability. ACI GIFT CARDS, INC. ("ACI") AND ITS AFFILIATES MAKE NO WARRANTIES, EXPRESS OR IMPLIED, WITH RESPECT TO GIFT CARDS, INCLUDING WITHOUT LIMITATION, ANY EXPRESS OR IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN THE EVENT A GIFT CARD CODE IS NON-FUNCTIONAL, YOUR SOLE REMEDY, AND OUR SOLE LIABILITY, SHALL BE THE REPLACEMENT OF SUCH GIFT CARD. CERTAIN STATE LAWS DO NOT ALLOW LIMITATIONS ON IMPLIED WARRANTIES OR THE EXCLUSION OR LIMITATION OF CERTAIN DAMAGES. IF THESE LAWS APPLY TO YOU, SOME OR ALL OF THE ABOVE DISCLAIMERS, EXCLUSIONS, OR LIMITATIONS MAY NOT APPLY TO YOU, AND YOU MIGHT HAVE ADDITIONAL RIGHTS.
222
+ 7. Disputes. Any dispute relating in any way to Amazon.com Gift Cards in which the aggregate total claim for relief sought on behalf of one or more parties exceeds $7,500 shall be adjudicated in any state or federal court in King County, Washington, and you consent to exclusive jurisdiction and venue in such courts.
223
+ 8. General Terms. Amazon.com Gift Cards are issued by ACI, a Washington corporation. By visiting Amazon.com, you agree that the laws of the State of Washington, without regard to principles of conflict of laws, will govern these Gift Card terms and conditions. ACI reserves the right to change these terms and conditions from time to time in its discretion. All terms and conditions are applicable to the extent permitted by law.
224
+
225
+
226
+ ***********************************************************************
227
+ BODY
228
+
229
+ @handler.gift_card
230
+
231
+ assert_equal 1, @itor.rss_items.length
232
+
233
+ rss_item = @itor.rss_items.first
234
+ assert_equal 'Amazon Gift Card from You - $100.00!', rss_item.title
235
+ description = <<-DESC.strip
236
+ <p><strong>You sent you a $100.00 gift card!</strong>
237
+
238
+ <p>Thanks!
239
+
240
+ <h2>AAAA-BBBBBB-CCCC</h2>
241
+
242
+ <p><a href="https://www.amazon.com/gp/css/account/payment/view-gc-balance.html">Claim your gift card</a>
243
+ DESC
244
+ assert_equal description, rss_item.description
245
+ assert_equal ['from@example.com'], rss_item.author
246
+ assert_equal Time.at(0), rss_item.pub_date
247
+ assert_equal 'https://www.amazon.com/gp/css/account/payment/view-gc-balance.html',
248
+ rss_item.link
249
+ assert_equal nil, rss_item.guid
250
+ assert_equal 'Amazon', rss_item.category
251
+ end
252
+
253
+ def test_order_cancelation
254
+ @handler.mail = util_mail :body => <<-BODY
255
+ Dear Eric Hodel,
256
+
257
+ Your order has been successfully canceled. For your reference, here's a
258
+ summary of your order:
259
+
260
+ You just canceled order #000-1111111-2222222 placed on MM DD, YYYY.
261
+
262
+ Status: CANCELED
263
+
264
+ _____________________________________________________________________
265
+
266
+ 1 of A. [CD-ROM]
267
+ 1 of B [CD-ROM]
268
+ 1 of C [CD-ROM]
269
+ 1 of D
270
+
271
+ _____________________________________________________________________
272
+
273
+ Because you only pay for items when we ship them to you, you won't be
274
+ charged for any items that you cancel.
275
+
276
+ Thank you for visiting Amazon.com!
277
+
278
+ ---------------------------------------------------------------------
279
+ Amazon.com
280
+ Earth's Biggest Selection
281
+ http://www.amazon.com
282
+ ---------------------------------------------------------------------
283
+ BODY
284
+
285
+ @handler.order_cancellation
286
+
287
+ assert_equal 1, @itor.rss_items.length
288
+
289
+ rss_item = @itor.rss_items.first
290
+ assert_equal 'Amazon order cancellation 000-1111111-2222222', rss_item.title
291
+ description = <<-DESC
292
+ <p>You cancelled your order:
293
+
294
+ <table>
295
+ <tr><th>Quantity<th>Description
296
+ <tr><td><td>your order:
297
+ <tr><td>1<td>A. [CD-ROM]
298
+ <tr><td>1<td>B [CD-ROM]
299
+ <tr><td>1<td>C [CD-ROM]
300
+ <tr><td>1<td>D
301
+ </table>
302
+
303
+ DESC
304
+ assert_equal description, rss_item.description
305
+ assert_equal ['from@example.com'], rss_item.author
306
+ assert_equal Time.at(0), rss_item.pub_date
307
+ assert_equal 'https://www.amazon.com/gp/css/summary/edit.html?ie=UTF8&orderID=000-1111111-2222222', rss_item.link
308
+ assert_equal nil, rss_item.guid
309
+ assert_equal 'Amazon', rss_item.category
310
+ end
311
+
312
+ def test_order_shipped
313
+ @handler.mail = util_mail :subject => 'Your Amazon.com order has shipped (#000-1111111-2222222)',
314
+ :body => <<-BODY
315
+ Greetings from Amazon.com.
316
+
317
+ We thought you'd like to know that we shipped your items, and that this
318
+ completes your order. Your order is being shipped and cannot be changed
319
+ by you or by our customer service department.
320
+
321
+ You can track the status of this order, and all your orders, online by
322
+ visiting Your Account at http://www.amazon.com/gp/css/history/view.html
323
+
324
+ There you can:
325
+ * Track your shipment
326
+ * View the status of unshipped items
327
+ * Cancel unshipped items
328
+ * Return items
329
+ * And do much more
330
+
331
+ The following items have been shipped to you by Amazon.com:
332
+ --------------------------------------------------------------------
333
+ Qty Item Price Shipped Subtotal
334
+
335
+ ---------------------------------------------------------------------
336
+
337
+ Amazon.com items (Sold by Amazon.com, LLC):
338
+
339
+ 1 2001 - A Space Odyssey [Bl... $17.99 1 $17.99
340
+
341
+ Shipped via USPS
342
+
343
+ Tracking number: 9102999999999999999999
344
+
345
+ ---------------------------------------------------------------------
346
+ Item Subtotal: $17.99
347
+ Shipping and handling: $2.98
348
+
349
+ Sales Tax: $1.99
350
+
351
+ Total: $22.96
352
+
353
+ Paid by Mastercard: $22.96
354
+
355
+ --------------------------------------------------------------------
356
+
357
+ This shipment was sent to:
358
+
359
+ Eric Hodel
360
+ 101 Any Street
361
+ Seattle, WA 98122
362
+ United States
363
+
364
+ via USPS (estimated delivery date: July 1,2009).
365
+
366
+ For your reference, the number you can use to track your package is
367
+ 9102999999999999999999.Visit http://www.amazon.com/wheres-my-stuff to
368
+ track your shipment.Please note that tracking information may not be
369
+ available immediately.
370
+
371
+ If you need to print an invoice for this order, visit Your Account
372
+ (www.amazon.com/your-account) and click to view open and recently shipped
373
+ orders. Find the order in the list and click the "View order" button.
374
+ You'll find a button to print an invoice on the next page.
375
+
376
+ If you ever need to return an order, visit our Online Returns Center:
377
+ www.amazon.com/returns
378
+
379
+ If you've explored the links on the Your Account page but still need
380
+ assistance with your order, you'll find links to e-mail or call
381
+ Amazon.com Customer Service
382
+ in our Help department at http://www.amazon.com/help/
383
+
384
+ ---------------------------------------------------------------------
385
+ Please be aware that items in this order may be subject to California's
386
+ Electronic Waste Recycling Act. If any items in this order are subject
387
+ to that Act, the seller of that item has elected to pay any fees due
388
+ on your behalf.
389
+ ---------------------------------------------------------------------
390
+ Please note: This e-mail was sent from a notification-only address
391
+ that cannot accept incoming e-mail. Please do not reply to this message.
392
+
393
+ Thank you for shopping with us.
394
+
395
+ ---------------------------------------------------------------------
396
+ Amazon.com... and you're done!
397
+ http://www.amazon.com/
398
+ ---------------------------------------------------------------------
399
+
400
+ BODY
401
+
402
+ @handler.order_shipped
403
+
404
+ assert_equal 1, @itor.rss_items.length
405
+
406
+ rss_item = @itor.rss_items.first
407
+ assert_equal 'Your Amazon.com order has shipped (#000-1111111-2222222)',
408
+ rss_item.title
409
+ description = <<-DESC.strip
410
+ <table>
411
+ <tr><th>Quantity<th>Description
412
+ <tr><td>1<td>2001 - A Space Odyssey [Bl...
413
+ </table>
414
+
415
+ <p>Via <a href=\"http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?strOrigTrackNum=9102999999999999999999\">USPS</a>
416
+
417
+ <p>To:<br>
418
+ Eric Hodel<br />
419
+ 101 Any Street<br />
420
+ Seattle, WA 98122<br />
421
+ United States
422
+ DESC
423
+ assert_equal description, rss_item.description
424
+ assert_equal ['from@example.com'], rss_item.author
425
+ assert_equal Time.at(0), rss_item.pub_date
426
+ assert_equal 'http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?strOrigTrackNum=9102999999999999999999',
427
+ rss_item.link
428
+ assert_equal nil, rss_item.guid
429
+ assert_equal 'Amazon', rss_item.category
430
+ end
431
+
432
+ def test_order_shipped_2
433
+ @handler.mail = util_mail :subject => 'Your Amazon.com order has shipped (#000-1111111-2222222)',
434
+ :body => <<-BODY
435
+ Greetings from Amazon.com.
436
+
437
+ We thought you'd like to know that we shipped your items, and that this
438
+ completes your order. Your order is being shipped and cannot be changed
439
+ by you or by our customer service department.
440
+
441
+ You can track the status of this order, and all your orders, online by
442
+ visiting Your Account at http://www.amazon.com/gp/css/history/view.html
443
+
444
+ There you can:
445
+ * Track your shipment
446
+ * View the status of unshipped items
447
+ * Cancel unshipped items
448
+ * Return items
449
+ * And do much more
450
+
451
+ The following items have been shipped to you by Amazon.com:
452
+ --------------------------------------------------------------------
453
+ Qty Item Price Shipped Subtotal
454
+
455
+ ---------------------------------------------------------------------
456
+
457
+ Amazon.com items (Sold by Amazon.com, LLC):
458
+
459
+ 1 Fujitsu ScanSnap S1500M In... $404.99 1 $404.99
460
+
461
+ Shipped via UPS
462
+
463
+ Tracking number: 1A222B333333333333
464
+
465
+ ---------------------------------------------------------------------
466
+ Item Subtotal: $404.99
467
+ Shipping and handling: $11.48
468
+
469
+ Super Saver Discount: $-11.48
470
+
471
+ Reward Applied: $0.00
472
+
473
+ Sales Tax: $38.46
474
+
475
+ Total: $443.45
476
+
477
+ Paid by Mastercard: $443.45
478
+
479
+ --------------------------------------------------------------------
480
+
481
+ This shipment was sent to:
482
+
483
+ Eric Hodel
484
+ 101 Any Street
485
+ Seattle, WA 98122
486
+ United States
487
+
488
+ via UPS (estimated delivery date: September 3, 2009).
489
+
490
+ For your reference, the number you can use to track your package is
491
+ 1A222B333333333333.Visit http://www.amazon.com/wheres-my-stuff to track
492
+ your shipment.Please note that tracking information may not be available
493
+ immediately.
494
+
495
+ Please note that a signature may be required for the delivery of any
496
+ package where the value of the contents is greater than $400. If no
497
+ one will be available to sign for this package, you may wish to make
498
+ alternate delivery arrangements with the carrier.
499
+
500
+ If you need to print an invoice for this order, visit Your Account
501
+ (www.amazon.com/your-account) and click to view open and recently shipped
502
+ orders. Find the order in the list and click the "View order" button.
503
+ You'll find a button to print an invoice on the next page.
504
+
505
+ If you ever need to return an order, visit our Online Returns Center:
506
+ www.amazon.com/returns
507
+
508
+ If you've explored the links on the Your Account page but still need
509
+ assistance with your order, you'll find links to e-mail or call
510
+ Amazon.com Customer Service
511
+ in our Help department at http://www.amazon.com/help/
512
+
513
+ ---------------------------------------------------------------------
514
+ Please be aware that items in this order may be subject to California's
515
+ Electronic Waste Recycling Act. If any items in this order are subject
516
+ to that Act, the seller of that item has elected to pay any fees due
517
+ on your behalf.
518
+ ---------------------------------------------------------------------
519
+ Please note: This e-mail was sent from a notification-only address
520
+ that cannot accept incoming e-mail. Please do not reply to this message.
521
+
522
+ Thank you for shopping with us.
523
+
524
+ ---------------------------------------------------------------------
525
+ Amazon.com... and you're done!
526
+ http://www.amazon.com/
527
+ ---------------------------------------------------------------------
528
+
529
+
530
+ BODY
531
+
532
+ @handler.order_shipped
533
+
534
+ assert_equal 1, @itor.rss_items.length
535
+
536
+ rss_item = @itor.rss_items.first
537
+ assert_equal 'Your Amazon.com order has shipped (#000-1111111-2222222)',
538
+ rss_item.title
539
+ description = <<-DESC.strip
540
+ <table>
541
+ <tr><th>Quantity<th>Description
542
+ <tr><td>1<td>Fujitsu ScanSnap S1500M In...
543
+ </table>
544
+
545
+ <p>Via <a href=\"http://wwwapps.ups.com/WebTracking/processInputRequest?InquiryNumber1=1A222B333333333333\">UPS</a>
546
+
547
+ <p>To:<br>
548
+ Eric Hodel<br />
549
+ 101 Any Street<br />
550
+ Seattle, WA 98122<br />
551
+ United States
552
+ DESC
553
+ assert_equal description, rss_item.description
554
+ assert_equal ['from@example.com'], rss_item.author
555
+ assert_equal Time.at(0), rss_item.pub_date
556
+ assert_equal 'http://wwwapps.ups.com/WebTracking/processInputRequest?InquiryNumber1=1A222B333333333333',
557
+ rss_item.link
558
+ assert_equal nil, rss_item.guid
559
+ assert_equal 'Amazon', rss_item.category
560
+ end
561
+
562
+ def test_order_shipped_bang
563
+ @handler.mail = util_mail :subject => 'Your Amazon.com order 000-1111111-2222222 has shipped!',
564
+ :body => <<-BODY
565
+
566
+ Dear drbrain@segment7.net,
567
+
568
+ Today Smart Home Systems, Inc. shipped item(s) in your order, placed on
569
+ June 20,2009.
570
+
571
+ ==================================================
572
+ SHIPPING DETAILS
573
+ ==================================================
574
+
575
+ The following items were sold by and shipped from Smart Home Systems, Inc.
576
+ in package 1 of this shipment:
577
+
578
+ 2 of X10 PRO Wall Switch White
579
+
580
+ Shipping Carrier: USPS
581
+
582
+ Ship Date: June 22,2009
583
+ Shipping Speed: Standard
584
+ Carrier Tracking ID: 9101999999999999999999
585
+
586
+ Your shipping address:
587
+
588
+ Eric Hodel
589
+ 101 Any Street
590
+ Seattle, WA 98122
591
+ United States
592
+
593
+ If you have additional items in your order, you will receive an e-mail
594
+ when those items have shipped.
595
+
596
+ QUESTIONS?
597
+
598
+ If you have questions about this order, including the status of your
599
+ shipment, you can either visit http://www.amazon.com/wheres-my-stuff or
600
+ e-mail amazonorders@smarthomeusa.com to get in touch directly with Smart
601
+ Home Systems, Inc..
602
+
603
+ **************************************************
604
+ Safe Shopping Tips
605
+ Amazon.com works hard to protect our customers. For your safety, when
606
+ ordering items advertised by sellers other than Amazon.com:
607
+
608
+ * Always place your orders directly through the Amazon.com shopping cart
609
+ using Amazon Payments. Never send money directly to sellers through wire
610
+ transfers or checks; we do not guarantee such transactions.
611
+
612
+ * Beware of e-mails that request direct payments, request payment to
613
+ international locations, or ask for personal information. Amazon.com will
614
+ never e-mail you to pay for Marketplace transactions outside our shopping
615
+ cart, or ask you to confirm personal information such as a credit card
616
+ number or password via e-mail. If a particular e-mail looks suspicious or
617
+ unusual, please contact us directly.
618
+
619
+ Reporting suspicious activity at
620
+ http://www.amazon.com/gp/help/reports/contact-us will help us enhance
621
+ marketplace safety and serve you better in the future.
622
+
623
+ For more safe-shopping tips, read about Safe Online Transactions at
624
+ http://www.amazon.com/safe-secure.
625
+ **************************************************
626
+
627
+ ==================================================
628
+ Order Details
629
+ ==================================================
630
+
631
+ Date: June 20,2009
632
+
633
+ Amazon Order #: 000-1111111-2222222
634
+
635
+ Smart Home Systems, Inc. Order #: 33333
636
+
637
+ 2 of X10 PRO Wall Switch White, $11.95*
638
+
639
+ *above item(s) sold by and shipped from Smart Home Systems, Inc.
640
+ ---------------------------------------------------------------------
641
+ Item Subtotal: $23.90
642
+ Shipping & Handling: $8.95
643
+
644
+ Total: $32.85
645
+
646
+ Paid by Mastercard: $32.85
647
+
648
+ ---------------------------------------------------------------------
649
+
650
+ Thanks for shopping at Amazon.com.
651
+
652
+ http://www.amazon.com/
653
+ Earth's Biggest Selection
654
+ Find, Discover & Buy Virtually Anything
655
+
656
+ BODY
657
+
658
+ @handler.order_shipped_bang
659
+
660
+ assert_equal 1, @itor.rss_items.length
661
+
662
+ rss_item = @itor.rss_items.first
663
+ assert_equal 'Your Amazon.com order 000-1111111-2222222 has shipped!',
664
+ rss_item.title
665
+ description = <<-DESC
666
+ <table>
667
+ <tr><th>Quantity<th>Description
668
+ <tr><td>2<td>X10 PRO Wall Switch White
669
+ </table>
670
+
671
+ DESC
672
+ assert_equal description, rss_item.description
673
+ assert_equal ['from@example.com'], rss_item.author
674
+ assert_equal Time.at(0), rss_item.pub_date
675
+ assert_equal nil, rss_item.link
676
+ assert_equal nil, rss_item.guid
677
+ assert_equal 'Amazon', rss_item.category
678
+ end
679
+
680
+ def test_order_revision
681
+ @handler.mail = util_mail :body => <<-BODY
682
+ Dear Eric Hodel,
683
+
684
+ Thanks for approving the delay in your order #000-1111111-2222222.
685
+
686
+ We appreciate your patience, and we apologize for any inconvenience. Please note that we don't charge you for an item until we're ready to ship it. On the day we ship your order, we'll send you an e-mail message confirming its contents and the shipping method.
687
+
688
+ Thank you for visiting Amazon.com!
689
+
690
+ ---------------------------------------------------------------------
691
+ Amazon.com
692
+ Earth's Biggest Selection
693
+ http://www.amazon.com
694
+ ---------------------------------------------------------------------
695
+ BODY
696
+
697
+ @handler.order_revision '000-1111111-2222222'
698
+
699
+ assert_equal 1, @itor.rss_items.length
700
+
701
+ rss_item = @itor.rss_items.first
702
+ assert_equal 'Order Revision (000-1111111-2222222)', rss_item.title
703
+ assert_equal '<p>Thanks for approving the delay in your order #000-1111111-2222222.',
704
+ rss_item.description
705
+ assert_equal ['from@example.com'], rss_item.author
706
+ assert_equal Time.at(0), rss_item.pub_date
707
+ assert_equal 'https://www.amazon.com/gp/css/summary/edit.html?ie=UTF8&orderID=000-1111111-2222222',
708
+ rss_item.link
709
+ assert_equal nil, rss_item.guid
710
+ assert_equal 'Amazon', rss_item.category
711
+ end
712
+
713
+ def test_order_table
714
+ items = [
715
+ [2, "rubber chickens\n"],
716
+ [5, 'whoopie cushions']
717
+ ]
718
+
719
+ expected = <<-TABLE
720
+ <table>
721
+ <tr><th>Quantity<th>Description
722
+ <tr><td>2<td>rubber chickens
723
+ <tr><td>5<td>whoopie cushions
724
+ </table>
725
+
726
+ TABLE
727
+
728
+ assert_equal expected, @handler.order_table(items)
729
+ end
730
+
731
+ def test_order_url
732
+ assert_equal "https://www.amazon.com/gp/css/summary/edit.html?ie=UTF8&orderID=000-1111111-2222222",
733
+ @handler.order_url('000-1111111-2222222')
734
+ end
735
+
736
+ end
737
+