def setUp(self): test_records_company = [ { "abbr": "_TC6", "company_name": "_Test Company 6", "country": "India", "default_currency": "INR", "doctype": "Company", "domain": "Manufacturing", "monthly_sales_target": 2000, "chart_of_accounts": "Standard" }, { "abbr": "_TC7", "company_name": "_Test Company 7", "country": "United States", "default_currency": "USD", "doctype": "Company", "domain": "Retail", "monthly_sales_target": 10000, "total_monthly_sales": 1000, "chart_of_accounts": "Standard" }, ] make_test_objects('Company', test_records=test_records_company, reset=True)
def tearDown(self): dataent.db.sql( 'delete from `tabProperty Setter` where doc_type="Event"') dataent.clear_cache(doctype='Event') dataent.db.sql('delete from `tabEvent`') dataent.db.sql('delete from __global_search') make_test_objects('Event') dataent.db.commit()
def test_get_item_details(self): # delete modified item price record and make as per test_records dataent.db.sql("""delete from `tabItem Price`""") to_check = { "item_code": "_Test Item", "item_name": "_Test Item", "description": "_Test Item 1", "warehouse": "_Test Warehouse - _TC", "income_account": "Sales - _TC", "expense_account": "_Test Account Cost for Goods Sold - _TC", "cost_center": "_Test Cost Center - _TC", "qty": 1.0, "price_list_rate": 100.0, "base_price_list_rate": 0.0, "discount_percentage": 0.0, "rate": 0.0, "base_rate": 0.0, "amount": 0.0, "base_amount": 0.0, "batch_no": None, "item_tax_rate": '{}', "uom": "_Test UOM", "conversion_factor": 1.0, } make_test_objects("Item Price") details = get_item_details({ "item_code": "_Test Item", "company": "_Test Company", "price_list": "_Test Price List", "currency": "_Test Currency", "doctype": "Sales Order", "conversion_rate": 1, "price_list_currency": "_Test Currency", "plc_conversion_rate": 1, "order_type": "Sales", "customer": "_Test Customer", "conversion_factor": 1, "price_list_uom_dependant": 1, "ignore_pricing_rule": 1 }) for key, value in iteritems(to_check): self.assertEqual(value, details.get(key))
def test_get_diff(self): test_records = make_test_objects('Event', reset=True) old_doc = dataent.get_doc("Event", test_records[0]) new_doc = copy.deepcopy(old_doc) old_doc.color = None new_doc.color = '#fafafa' diff = get_diff(old_doc, new_doc)['changed'] self.assertEqual(get_fieldnames(diff)[0], 'color') self.assertTrue(get_old_values(diff)[0] is None) self.assertEqual(get_new_values(diff)[0], '#fafafa') new_doc.starts_on = "2017-07-20" diff = get_diff(old_doc, new_doc)['changed'] self.assertEqual(get_fieldnames(diff)[0], 'starts_on') self.assertEqual(get_old_values(diff)[0], '01-01-2014 00:00:00') self.assertEqual(get_new_values(diff)[0], '07-20-2017 00:00:00')
def setUp(self): dataent.db.sql('delete from tabEvent') make_test_objects('Event', reset=True) self.test_records = dataent.get_test_records('Event') self.test_user = "******"
def setUp(self): make_test_objects('Event', reset=True)
def _make_test_records(verbose): from dataent.test_runner import make_test_objects accounts = [ # [account_name, parent_account, is_group] ["_Test Bank", "Bank Accounts", 0, "Bank", None], ["_Test Bank USD", "Bank Accounts", 0, "Bank", "USD"], ["_Test Bank EUR", "Bank Accounts", 0, "Bank", "EUR"], ["_Test Cash", "Cash In Hand", 0, "Cash", None], ["_Test Account Stock Expenses", "Direct Expenses", 1, None, None], [ "_Test Account Shipping Charges", "_Test Account Stock Expenses", 0, "Chargeable", None ], [ "_Test Account Customs Duty", "_Test Account Stock Expenses", 0, "Tax", None ], [ "_Test Account Insurance Charges", "_Test Account Stock Expenses", 0, "Chargeable", None ], [ "_Test Account Stock Adjustment", "_Test Account Stock Expenses", 0, "Stock Adjustment", None ], ["_Test Employee Advance", "Current Liabilities", 0, None, None], ["_Test Account Tax Assets", "Current Assets", 1, None, None], ["_Test Account VAT", "_Test Account Tax Assets", 0, "Tax", None], [ "_Test Account Service Tax", "_Test Account Tax Assets", 0, "Tax", None ], [ "_Test Account Reserves and Surplus", "Current Liabilities", 0, None, None ], ["_Test Account Cost for Goods Sold", "Expenses", 0, None, None], [ "_Test Account Excise Duty", "_Test Account Tax Assets", 0, "Tax", None ], [ "_Test Account Education Cess", "_Test Account Tax Assets", 0, "Tax", None ], [ "_Test Account S&H Education Cess", "_Test Account Tax Assets", 0, "Tax", None ], ["_Test Account CST", "Direct Expenses", 0, "Tax", None], ["_Test Account Discount", "Direct Expenses", 0, None, None], ["_Test Write Off", "Indirect Expenses", 0, None, None], ["_Test Exchange Gain/Loss", "Indirect Expenses", 0, None, None], # related to Account Inventory Integration ["_Test Account Stock In Hand", "Current Assets", 0, None, None], # fixed asset depreciation ["_Test Fixed Asset", "Current Assets", 0, "Fixed Asset", None], ["_Test Accumulated Depreciations", "Current Assets", 0, None, None], ["_Test Depreciations", "Expenses", 0, None, None], ["_Test Gain/Loss on Asset Disposal", "Expenses", 0, None, None], # Receivable / Payable Account ["_Test Receivable", "Current Assets", 0, "Receivable", None], ["_Test Payable", "Current Liabilities", 0, "Payable", None], ["_Test Receivable USD", "Current Assets", 0, "Receivable", "USD"], ["_Test Payable USD", "Current Liabilities", 0, "Payable", "USD"] ] for company, abbr in [["_Test Company", "_TC"], ["_Test Company 1", "_TC1"]]: test_objects = make_test_objects( "Account", [{ "doctype": "Account", "account_name": account_name, "parent_account": parent_account + " - " + abbr, "company": company, "is_group": is_group, "account_type": account_type, "account_currency": currency } for account_name, parent_account, is_group, account_type, currency in accounts]) return test_objects
def setUpClass(cls): super(TestUtils, cls).setUpClass() make_test_objects('Address', ADDRESS_RECORDS)