fixes in Test Cases
This commit is contained in:
parent
9789d06b3e
commit
05f15bbb88
@ -9,8 +9,8 @@ test_records = frappe.get_test_records('Expense Claim')
|
|||||||
|
|
||||||
class TestExpenseClaim(unittest.TestCase):
|
class TestExpenseClaim(unittest.TestCase):
|
||||||
def test_total_expense_claim_for_project(self):
|
def test_total_expense_claim_for_project(self):
|
||||||
frappe.db.sql("delete from `tabTask`")
|
frappe.db.sql("""delete from `tabTask` where project = "_Test Project 1" """)
|
||||||
frappe.db.sql("delete from `tabProject`")
|
frappe.db.sql("""delete from `tabProject` where name = "_Test Project 1" """)
|
||||||
|
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
"project_name": "_Test Project 1",
|
"project_name": "_Test Project 1",
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"custom": 0,
|
"custom": 0,
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "",
|
"document_type": "Master",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -135,7 +135,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"modified": "2015-04-01 02:06:37.510007",
|
"modified": "2015-04-14 02:08:33.690406",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Projects",
|
"module": "Projects",
|
||||||
"name": "Activity Cost",
|
"name": "Activity Cost",
|
||||||
|
@ -7,6 +7,8 @@ import frappe
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class DuplicationError(frappe.ValidationError): pass
|
||||||
|
|
||||||
class ActivityCost(Document):
|
class ActivityCost(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_title()
|
self.set_title()
|
||||||
@ -19,4 +21,4 @@ class ActivityCost(Document):
|
|||||||
if frappe.db.sql("""select name from `tabActivity Cost` where employee_name= %s and activity_type= %s and name != %s""",
|
if frappe.db.sql("""select name from `tabActivity Cost` where employee_name= %s and activity_type= %s and name != %s""",
|
||||||
(self.employee_name, self.activity_type, self.name)):
|
(self.employee_name, self.activity_type, self.name)):
|
||||||
frappe.throw(_("Activity Cost exists for Employee {0} against Activity Type - {1}")
|
frappe.throw(_("Activity Cost exists for Employee {0} against Activity Type - {1}")
|
||||||
.format(self.employee, self.activity_type))
|
.format(self.employee, self.activity_type), DuplicationError)
|
||||||
|
@ -6,7 +6,19 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Activity Cost')
|
from erpnext.projects.doctype.activity_cost.activity_cost import DuplicationError
|
||||||
|
|
||||||
class TestActivityCost(unittest.TestCase):
|
class TestActivityCost(unittest.TestCase):
|
||||||
pass
|
def test_duplication(self):
|
||||||
|
frappe.db.sql("delete from `tabActivity Cost`")
|
||||||
|
activity_cost1 = frappe.new_doc('Activity Cost')
|
||||||
|
activity_cost1.update({
|
||||||
|
"employee": "_T-Employee-0001",
|
||||||
|
"employee_name": "_Test Employee",
|
||||||
|
"activity_type": "_Test Activity Type",
|
||||||
|
"billing_rate": 100,
|
||||||
|
"costing_rate": 50
|
||||||
|
})
|
||||||
|
activity_cost1.insert()
|
||||||
|
activity_cost2 = frappe.copy_doc(activity_cost1)
|
||||||
|
self.assertRaises(DuplicationError, activity_cost2.insert )
|
||||||
|
@ -1,9 +1 @@
|
|||||||
[
|
[]
|
||||||
{
|
|
||||||
"employee": "_T-Employee-0001",
|
|
||||||
"employee_name": "_Test Employee",
|
|
||||||
"activity_type": "_Test Activity Type",
|
|
||||||
"billing_rate": 100,
|
|
||||||
"costing_rate": 50
|
|
||||||
}
|
|
||||||
]
|
|
@ -86,8 +86,8 @@ class TestTimeLog(unittest.TestCase):
|
|||||||
frappe.db.sql("delete from `tabTime Log`")
|
frappe.db.sql("delete from `tabTime Log`")
|
||||||
|
|
||||||
def test_total_activity_cost_for_project(self):
|
def test_total_activity_cost_for_project(self):
|
||||||
frappe.db.sql("delete from `tabTask`")
|
frappe.db.sql("""delete from `tabTask` where project = "_Test Project 1" """)
|
||||||
frappe.db.sql("delete from `tabProject`")
|
frappe.db.sql("""delete from `tabProject` where name = "_Test Project 1" """)
|
||||||
|
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
"project_name": "_Test Project 1",
|
"project_name": "_Test Project 1",
|
||||||
@ -116,8 +116,8 @@ class TestTimeLog(unittest.TestCase):
|
|||||||
self.assertEqual(time_log.billing_amount, 200)
|
self.assertEqual(time_log.billing_amount, 200)
|
||||||
time_log.submit()
|
time_log.submit()
|
||||||
|
|
||||||
self.assertEqual(frappe.db.get_value("Task", task_name, "actual_cost"), 200)
|
self.assertEqual(frappe.db.get_value("Task", task_name, "total_billing_amount"), 200)
|
||||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_activity_cost"), 200)
|
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_billing_amount"), 200)
|
||||||
|
|
||||||
time_log2 = frappe.get_doc({
|
time_log2 = frappe.get_doc({
|
||||||
"activity_type": "_Test Activity Type",
|
"activity_type": "_Test Activity Type",
|
||||||
@ -132,13 +132,13 @@ class TestTimeLog(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
time_log2.save()
|
time_log2.save()
|
||||||
|
|
||||||
self.assertEqual(frappe.db.get_value("Task", task_name, "actual_cost"), 400)
|
self.assertEqual(frappe.db.get_value("Task", task_name, "total_billing_amount"), 400)
|
||||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_activity_cost"), 400)
|
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_billing_amount"), 400)
|
||||||
|
|
||||||
time_log2.cancel()
|
time_log2.cancel()
|
||||||
|
|
||||||
self.assertEqual(frappe.db.get_value("Task", task_name, "actual_cost"), 200)
|
self.assertEqual(frappe.db.get_value("Task", task_name, "total_billing_amount"), 200)
|
||||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_activity_cost"), 200)
|
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_billing_amount"), 200)
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Time Log')
|
test_records = frappe.get_test_records('Time Log')
|
||||||
test_ignore = ["Time Log Batch", "Sales Invoice"]
|
test_ignore = ["Time Log Batch", "Sales Invoice"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user