Skip to content

Commit

Permalink
test(payments): use test record loader
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Oct 30, 2023
1 parent 25fdcf5 commit 07a0f23
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 54 deletions.
54 changes: 0 additions & 54 deletions erpnext/accounts/doctype/payment_request/test_payment_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,8 @@

test_dependencies = ["Currency Exchange", "Journal Entry", "Contact", "Address"]

payment_gateway_settings = {
"doctype": "DocType",
"module": "Accounts",
"custom": 1,
"fields": [{"label": "Name", "fieldname": "name", "fieldtype": "Data"}],
"name": "Test Gateway Settings",
}

payment_gateway_controller = {
"doctype": "Test Gateway Settings",
"name": "_Test Gateway Controller",
}

payment_gateway = {
"doctype": "Payment Gateway",
"gateway": "_Test Gateway",
"gateway_settings": payment_gateway_settings_doctype["name"],
"gateway_controller": payment_gateway_settings["name"],
}

payment_method = [
{
"doctype": "Payment Gateway Account",
"is_default": 1,
"payment_gateway": "_Test Gateway",
"payment_account": "_Test Bank - _TC",
"currency": "INR",
},
{
"doctype": "Payment Gateway Account",
"payment_gateway": "_Test Gateway",
"payment_account": "_Test Bank USD - _TC",
"currency": "USD",
},
]


class TestPaymentRequest(unittest.TestCase):
def setUp(self):
if not frappe.db.exists("DocType", payment_gateway_settings["name"]):
frappe.get_doc(payment_gateway_settings).insert(ignore_permissions=True)

if not frappe.db.exists(payment_gateway_settings["name"], payment_gateway_controller["name"]):
frappe.get_doc(payment_gateway_controller).insert(ignore_permissions=True)

if not frappe.db.get_value("Payment Gateway", payment_gateway["gateway"], "name"):
frappe.get_doc(payment_gateway).insert(ignore_permissions=True)

for method in payment_method:
if not frappe.db.get_value(
"Payment Gateway Account",
{"payment_gateway": method["payment_gateway"], "currency": method["currency"]},
"name",
):
frappe.get_doc(method).insert(ignore_permissions=True)

def test_payment_request_linkings(self):
so_inr = make_sales_order(currency="INR", do_not_save=True)
so_inr.disable_rounded_total = 1
Expand Down
32 changes: 32 additions & 0 deletions erpnext/accounts/doctype/payment_request/test_records.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"doctype": "DocType",
"module": "Accounts",
"custom": 1,
"fields": [{"label": "Name", "fieldname": "name", "fieldtype": "Data"}],
"name": "Test Gateway Settings"
},
{
"doctype": "Test Gateway Settings",
"name": "_Test Gateway Controller"
},
{
"doctype": "Payment Gateway",
"gateway": "_Test Gateway",
"gateway_settings": "Test Gateway Settings",
"gateway_controller": "_Test Gateway Controller"
},
{
"doctype": "Payment Gateway Account",
"is_default": 1,
"payment_gateway": "_Test Gateway",
"payment_account": "_Test Bank - _TC",
"currency": "INR"
},
{
"doctype": "Payment Gateway Account",
"payment_gateway": "_Test Gateway",
"payment_account": "_Test Bank USD - _TC",
"currency": "USD"
}
]

0 comments on commit 07a0f23

Please sign in to comment.