From e6b3fe1215a2d433d6f9f29ca4c0232c7e5a4cf5 Mon Sep 17 00:00:00 2001 From: tunde Date: Fri, 22 Sep 2017 16:04:07 +0100 Subject: [PATCH] add tests for payment term template --- .../test_payment_terms_template.py | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py b/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py index ec370668a0..c1b76a33ce 100644 --- a/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py +++ b/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py @@ -4,6 +4,46 @@ from __future__ import unicode_literals import unittest +import frappe + class TestPaymentTermsTemplate(unittest.TestCase): - pass + def tearDown(self): + frappe.delete_doc('Payment Terms Template', '_Test Payment Terms Template', force=1) + + def test_create_template(self): + template = frappe.get_doc({ + 'doctype': 'Payment Terms Template', + 'template_name': '_Test Payment Terms Template', + 'terms': [{ + 'doctype': 'Payment Terms Template Detail', + 'invoice_portion': 50.00, + 'credit_days_based_on': 'Day(s) after invoice date', + 'credit_days': 30 + }] + }) + + self.assertRaises(frappe.ValidationError, template.insert) + + template.append('terms', { + 'doctype': 'Payment Terms Template Detail', + 'invoice_portion': 50.00, + 'credit_days_based_on': 'Day(s) after invoice date', + 'credit_days': 0 + }) + + template.insert() + + def test_credit_days(self): + template = frappe.get_doc({ + 'doctype': 'Payment Terms Template', + 'template_name': '_Test Payment Terms Template', + 'terms': [{ + 'doctype': 'Payment Terms Template Detail', + 'invoice_portion': 100.00, + 'credit_days_based_on': 'Day(s) after invoice date', + 'credit_days': -30 + }] + }) + + self.assertRaises(frappe.ValidationError, template.insert) \ No newline at end of file