[fix] Test cases

This commit is contained in:
Nabin Hait 2016-04-01 16:07:34 +05:30
parent 5ea0799f83
commit adddf6f471
6 changed files with 24 additions and 28 deletions

View File

@ -64,22 +64,22 @@ def make_depreciation_entry(asset_name, date=None):
asset.set_status()
def get_depreciation_accounts(asset):
accounts = frappe.get_all("Asset Category Account",
fields = ['fixed_asset_account', 'accumulated_depreciation_account',
'depreciation_expense_account'],
filters={'parent': asset.asset_category, 'company_name': asset.company})
if accounts:
accounts = accounts[0]
fixed_asset_account = accounts.fixed_asset_account
accumulated_depreciation_account = accounts.accumulated_depreciation_account
depreciation_expense_account = accounts.depreciation_expense_account
fixed_asset_account = accumulated_depreciation_account = depreciation_expense_account = None
accounts = frappe.db.get_value("Asset Category Account",
filters={'parent': asset.asset_category, 'company_name': asset.company},
fieldname = ['fixed_asset_account', 'accumulated_depreciation_account',
'depreciation_expense_account'], as_dict=1)
if accounts:
fixed_asset_account = accounts.fixed_asset_account
accumulated_depreciation_account = accounts.accumulated_depreciation_account
depreciation_expense_account = accounts.depreciation_expense_account
if not accumulated_depreciation_account or not depreciation_expense_account:
accounts = frappe.db.get_value("Company", asset.company,
["accumulated_depreciation_account", "depreciation_expense_account"])
if not accumulated_depreciation_account:
accumulated_depreciation_account = accounts[0]
if not depreciation_expense_account:

View File

@ -148,7 +148,7 @@ def create_asset():
if not frappe.db.exists("Item", "Macbook Pro"):
create_fixed_asset_item()
asset = frappe.get_doc({
"doctype": "Asset",
"asset_name": "Macbook Pro 1",
@ -173,7 +173,7 @@ def create_asset_category():
asset_category.number_of_depreciations = 3
asset_category.number_of_months_in_a_period = 3
asset_category.append("accounts", {
"company": "_Test Company",
"company_name": "_Test Company",
"fixed_asset_account": "_Test Fixed Asset - _TC",
"accumulated_depreciation_account": "_Test Accumulated Depreciations - _TC",
"depreciation_expense_account": "_Test Depreciations - _TC"
@ -189,8 +189,9 @@ def create_fixed_asset_item():
"description": "Macbook Pro Retina Display",
"item_group": "All Item Groups",
"stock_uom": "Nos",
"is_stock_item": 0
}).insert()
"is_stock_item": 0,
"is_fixed_asset": 1
}).insert()
except frappe.DuplicateEntryError:
pass

View File

@ -5,10 +5,11 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import cint
from frappe.model.document import Document
class AssetCategory(Document):
def validate(self):
for field in ("number_of_depreciations", "number_of_months_in_a_period"):
if int(self.get(field))<1:
frappe.throw(_("{0} must be greater than 0").format(self.meta.get_label(field)))
if cint(self.get(field))<1:
frappe.throw(_("{0} must be greater than 0").format(self.meta.get_label(field)), frappe.MandatoryError)

View File

@ -16,7 +16,7 @@ class TestAssetCategory(unittest.TestCase):
asset_category.number_of_depreciations = 3
asset_category.number_of_months_in_a_period = 3
asset_category.append("accounts", {
"company": "_Test Company",
"company_name": "_Test Company",
"fixed_asset_account": "_Test Fixed Asset - _TC",
"accumulated_depreciation_account": "_Test Accumulated Depreciations - _TC",
"depreciation_expense_account": "_Test Depreciations - _TC"

View File

@ -43,8 +43,8 @@ def before_tests():
"company_abbr" :"WP",
"industry" :"Manufacturing",
"country" :"United States",
"fy_start_date" :"2014-01-01",
"fy_end_date" :"2014-12-31",
"fy_start_date" :"2011-01-01",
"fy_end_date" :"2011-12-31",
"language" :"english",
"company_tagline" :"Testing",
"email" :"test@erpnext.com",

View File

@ -96,13 +96,6 @@ class TestShoppingCart(unittest.TestCase):
self.assertEquals(quotation.net_total, 20)
self.assertEquals(len(quotation.get("items")), 1)
# remove second item
update_cart("_Test Item 2", 0)
quotation = self.test_get_cart_customer()
self.assertEquals(len(quotation.get("items")), 0)
self.assertEquals(quotation.net_total, 0)
def test_tax_rule(self):
self.login_as_customer()
quotation = self.create_quotation()
@ -197,6 +190,7 @@ class TestShoppingCart(unittest.TestCase):
def remove_all_items_from_cart(self):
quotation = _get_cart_quotation()
quotation.flags.ignore_permissions=True
quotation.delete()
def create_user_if_not_exists(self, email, first_name = None):