Ejegg has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344727 )

Change subject: WIP Test audit data for Express Checkout refunds
......................................................................

WIP Test audit data for Express Checkout refunds

Looks like the Item ID is the surest thing we have to distinguish them.
The note field can be filled in at the payment console, so it's not to
be trusted.

Bug: T161121
Change-Id: Id23f49c49e9c6a685eddaafd6828448d8f68ebef
---
M audit/paypal/tests/test_trr_file.py
1 file changed, 64 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/tools 
refs/changes/27/344727/1

diff --git a/audit/paypal/tests/test_trr_file.py 
b/audit/paypal/tests/test_trr_file.py
index 00ed5b7..6c66b37 100644
--- a/audit/paypal/tests/test_trr_file.py
+++ b/audit/paypal/tests/test_trr_file.py
@@ -30,7 +30,7 @@
         "Payer's Account ID": "pranks...@anonymous.net",
         "Payer Address Status": "N",
         "Item Name": "Generous benificence",
-        "Item ID": "GIMME",
+        "Item ID": "DONATE",
         "Option 1 Name": "",
         "Option 1 Value": "",
         "Option 2 Name": "",
@@ -75,8 +75,41 @@
         "Transaction  Debit or Credit": "DR",
         "Fee Debit or Credit": "CR",
         "Fee Amount": "55",
-        "Transaction Note": "r",
-        "Payer's Account ID": "pranks...@anonymous.net"
+        "Transaction Note": "refund",
+    })
+    return row
+
+
+def get_ec_refund_row():
+
+    row = get_base_row()
+    row.update({
+        "Invoice ID": "4123422",
+        "PayPal Reference ID": "3GJH3GJ3334214812",
+        "PayPal Reference ID Type": "TXN",
+        "Transaction Event Code": "T1107",
+        "Transaction  Debit or Credit": "DR",
+        "Fee Debit or Credit": "CR",
+        "Transaction Note": "refund",
+        "Custom Field": "4123422",
+        "Item ID": "",
+    })
+    return row
+
+
+def get_ec_recurring_refund_row():
+
+    row = get_base_row()
+    row.update({
+        "Invoice ID": "4123422",
+        "PayPal Reference ID": "3GJH3GJ3334214812",
+        "PayPal Reference ID Type": "TXN",
+        "Transaction Event Code": "T1107",
+        "Transaction  Debit or Credit": "DR",
+        "Fee Debit or Credit": "CR",
+        "Transaction Note": "refund",
+        "Custom Field": "",
+        "Item ID": "",
     })
     return row
 
@@ -143,6 +176,34 @@
 @patch("queue.redis_wrap.Redis")
 @patch("civicrm.civicrm.Civicrm")
 @patch("process.globals")
+def test_ec_refund_send(MockGlobals, MockCivicrm, MockRedis):
+    '''
+    Test that express checkout refunds are marked as such
+    '''
+    row = get_ec_refund_row()
+    row_recur = get_ec_recurring_refund_row()
+
+    MockCivicrm().transaction_refunded.return_value = False
+
+    parser = audit.paypal.TrrFile.TrrFile("dummy_path")
+
+    parser.parse_line(row)
+    parser.parse_line(row_recur)
+
+    # Did we send it?
+    args = MockRedis().send.call_args
+    expected = {'last_name': 'Man', 'thankyou_date': 0, 'city': '', 
'payment_method': '', 'gateway_status': 'S', 'currency': 'USD', 'postal_code': 
'', 'date': '1474736101', 'gateway_refund_id': 'AS7D98AS7D9A8S7D9AS', 
'gateway': 'paypal_ec', 'state_province': '', 'gross': 10.0, 'first_name': 
'Banana', 'fee': 0.55, 'gateway_txn_id': 'AS7D98AS7D9A8S7D9AS', 
'gross_currency': 'USD', 'country': '', 'payment_submethod': '', 'note': 'r', 
'supplemental_address_1': '', 'settled_date': '1474736101', 
'gateway_parent_id': '3GJH3GJ3334214812', 'type': 'refund', 'email': 
'pranks...@anonymous.net', 'street_address': '', 'contribution_tracking_id': 
'4123422', 'order_id': '4123422'}
+    assert args[0][0] == 'refund'
+    actual = args[0][1]
+    assert cmp(actual, expected) == 0 
+    assert args[1][0] == 'refund'
+    actual = args[1][1]
+    assert cmp(actual, expected) == 0 
+
+
+@patch("queue.redis_wrap.Redis")
+@patch("civicrm.civicrm.Civicrm")
+@patch("process.globals")
 def test_refund_duplicate(MockGlobals, MockCivicrm, MockRedis):
     '''
     Test that we do not send a refund for a donation that is refunded

-- 
To view, visit https://gerrit.wikimedia.org/r/344727
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id23f49c49e9c6a685eddaafd6828448d8f68ebef
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/tools
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to