fixes in Test Cases
diff --git a/erpnext/hr/doctype/expense_claim/test_expense_claim.py b/erpnext/hr/doctype/expense_claim/test_expense_claim.py
index 2867548..f5ae93c 100644
--- a/erpnext/hr/doctype/expense_claim/test_expense_claim.py
+++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.py
@@ -9,8 +9,8 @@
class TestExpenseClaim(unittest.TestCase):
def test_total_expense_claim_for_project(self):
- frappe.db.sql("delete from `tabTask`")
- frappe.db.sql("delete from `tabProject`")
+ frappe.db.sql("""delete from `tabTask` where project = "_Test Project 1" """)
+ frappe.db.sql("""delete from `tabProject` where name = "_Test Project 1" """)
frappe.get_doc({
"project_name": "_Test Project 1",
diff --git a/erpnext/projects/doctype/activity_cost/activity_cost.json b/erpnext/projects/doctype/activity_cost/activity_cost.json
index b44e310..7f7720a 100644
--- a/erpnext/projects/doctype/activity_cost/activity_cost.json
+++ b/erpnext/projects/doctype/activity_cost/activity_cost.json
@@ -7,7 +7,7 @@
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
- "document_type": "",
+ "document_type": "Master",
"fields": [
{
"allow_on_submit": 0,
@@ -135,7 +135,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 0,
- "modified": "2015-04-01 02:06:37.510007",
+ "modified": "2015-04-14 02:08:33.690406",
"modified_by": "Administrator",
"module": "Projects",
"name": "Activity Cost",
diff --git a/erpnext/projects/doctype/activity_cost/activity_cost.py b/erpnext/projects/doctype/activity_cost/activity_cost.py
index fb2d666..121e650 100644
--- a/erpnext/projects/doctype/activity_cost/activity_cost.py
+++ b/erpnext/projects/doctype/activity_cost/activity_cost.py
@@ -7,6 +7,8 @@
from frappe import _
from frappe.model.document import Document
+class DuplicationError(frappe.ValidationError): pass
+
class ActivityCost(Document):
def validate(self):
self.set_title()
@@ -19,4 +21,4 @@
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)):
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)
diff --git a/erpnext/projects/doctype/activity_cost/test_activity_cost.py b/erpnext/projects/doctype/activity_cost/test_activity_cost.py
index e9ec0b3..5afd97f 100644
--- a/erpnext/projects/doctype/activity_cost/test_activity_cost.py
+++ b/erpnext/projects/doctype/activity_cost/test_activity_cost.py
@@ -6,7 +6,19 @@
import frappe
import unittest
-test_records = frappe.get_test_records('Activity Cost')
+from erpnext.projects.doctype.activity_cost.activity_cost import DuplicationError
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 )
diff --git a/erpnext/projects/doctype/activity_cost/test_records.json b/erpnext/projects/doctype/activity_cost/test_records.json
index 30c9c9e..0637a08 100644
--- a/erpnext/projects/doctype/activity_cost/test_records.json
+++ b/erpnext/projects/doctype/activity_cost/test_records.json
@@ -1,9 +1 @@
-[
- {
- "employee": "_T-Employee-0001",
- "employee_name": "_Test Employee",
- "activity_type": "_Test Activity Type",
- "billing_rate": 100,
- "costing_rate": 50
- }
-]
\ No newline at end of file
+[]
\ No newline at end of file
diff --git a/erpnext/projects/doctype/time_log/test_time_log.py b/erpnext/projects/doctype/time_log/test_time_log.py
index fad2433..019d596 100644
--- a/erpnext/projects/doctype/time_log/test_time_log.py
+++ b/erpnext/projects/doctype/time_log/test_time_log.py
@@ -86,8 +86,8 @@
frappe.db.sql("delete from `tabTime Log`")
def test_total_activity_cost_for_project(self):
- frappe.db.sql("delete from `tabTask`")
- frappe.db.sql("delete from `tabProject`")
+ frappe.db.sql("""delete from `tabTask` where project = "_Test Project 1" """)
+ frappe.db.sql("""delete from `tabProject` where name = "_Test Project 1" """)
frappe.get_doc({
"project_name": "_Test Project 1",
@@ -116,8 +116,8 @@
self.assertEqual(time_log.billing_amount, 200)
time_log.submit()
- self.assertEqual(frappe.db.get_value("Task", task_name, "actual_cost"), 200)
- self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_activity_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_billing_amount"), 200)
time_log2 = frappe.get_doc({
"activity_type": "_Test Activity Type",
@@ -132,13 +132,13 @@
})
time_log2.save()
- self.assertEqual(frappe.db.get_value("Task", task_name, "actual_cost"), 400)
- self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_activity_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_billing_amount"), 400)
time_log2.cancel()
- self.assertEqual(frappe.db.get_value("Task", task_name, "actual_cost"), 200)
- self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_activity_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_billing_amount"), 200)
test_records = frappe.get_test_records('Time Log')
test_ignore = ["Time Log Batch", "Sales Invoice"]