Hi,
I’ve tried to create simple unittest for custom app.
But when I tried to create Sales Order using make_sales_order
, I got LinkValidationError
I know that creating _Test Company, _Test Item and _Test Warehouse - _TC will solve the problem.
My question is
Is there a function or database can be use for creating test data for default ERPNext doctype ?
Error
======================================================================
ERROR: test_transaction_base (custom_app.test.test_money_in_words.TestMoneyInWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/frappe/bench/apps/custom_app/custom_app/test/test_money_in_words.py", line 10, in test_transaction_base
amount='2134.23',
File "/home/frappe/bench/apps/erpnext/erpnext/selling/doctype/sales_order/test_sales_order.py", line 901, in make_sales_order
so.insert()
File "/home/frappe/bench/apps/frappe/frappe/model/document.py", line 224, in insert
self._validate_links()
File "/home/frappe/bench/apps/frappe/frappe/model/document.py", line 766, in _validate_links
frappe.LinkValidationError)
File "/home/frappe/bench/apps/frappe/frappe/__init__.py", line 377, in throw
msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable)
File "/home/frappe/bench/apps/frappe/frappe/__init__.py", line 356, in msgprint
_raise_exception()
File "/home/frappe/bench/apps/frappe/frappe/__init__.py", line 316, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.LinkValidationError: Could not find Company: _Test Company, Row #1: Item Code: _Test Item, Row #1: Delivery Warehouse: _Test Warehouse - _TC
----------------------------------------------------------------------
Ran 1 test in 1.398s
FAILED (errors=1)
Code
import frappe
import unittest
class TestMoneyInWords(unittest.TestCase):
def test_transaction_base(self):
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
so = make_sales_order(
currency='NGN',
amount='2134.23',
)
self.assertEqual(so.base_rounded_total, 'aaa')
self.assertEqual(so.grand_total, 'aaa')