mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 06:29:20 +00:00
Test case fixes in time log batch
This commit is contained in:
@@ -5,11 +5,17 @@ import frappe
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from erpnext.projects.doctype.time_log.time_log import OverlapError
|
from erpnext.projects.doctype.time_log.time_log import OverlapError
|
||||||
|
from erpnext.projects.doctype.time_log_batch.test_time_log_batch import *
|
||||||
|
|
||||||
class TestTimeLog(unittest.TestCase):
|
class TestTimeLog(unittest.TestCase):
|
||||||
def test_duplication(self):
|
def test_duplication(self):
|
||||||
|
frappe.db.sql("delete from `tabTime Log`")
|
||||||
|
frappe.get_doc(frappe.copy_doc(test_records[0])).insert()
|
||||||
|
|
||||||
ts = frappe.get_doc(frappe.copy_doc(test_records[0]))
|
ts = frappe.get_doc(frappe.copy_doc(test_records[0]))
|
||||||
self.assertRaises(OverlapError, ts.insert)
|
self.assertRaises(OverlapError, ts.insert)
|
||||||
|
|
||||||
|
frappe.db.sql("delete from `tabTime Log`")
|
||||||
|
|
||||||
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"]
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"doctype": "Time Log Batch",
|
|
||||||
"rate": "500",
|
|
||||||
"time_log_batch_details": [
|
|
||||||
{
|
|
||||||
"doctype": "Time Log Batch Detail",
|
|
||||||
"parentfield": "time_log_batch_details",
|
|
||||||
"parenttype": "Time Log Batch",
|
|
||||||
"time_log": "_T-Time Log-00001"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -4,36 +4,57 @@
|
|||||||
import frappe, unittest
|
import frappe, unittest
|
||||||
|
|
||||||
class TimeLogBatchTest(unittest.TestCase):
|
class TimeLogBatchTest(unittest.TestCase):
|
||||||
def setUp(self):
|
|
||||||
for name in frappe.db.sql_list("select name from `tabTime Log Batch` where docstatus=1"):
|
|
||||||
frappe.get_doc("Time Log Batch", name).cancel()
|
|
||||||
frappe.delete_doc("Time Log Batch", name)
|
|
||||||
|
|
||||||
for name in frappe.db.sql_list("select name from `tabTime Log` where docstatus=1"):
|
|
||||||
frappe.get_doc("Time Log", name).cancel()
|
|
||||||
frappe.delete_doc("Time Log", name)
|
|
||||||
|
|
||||||
def test_time_log_status(self):
|
def test_time_log_status(self):
|
||||||
from erpnext.projects.doctype.time_log.test_time_log import test_records as time_log_records
|
delete_time_log_and_batch()
|
||||||
time_log = frappe.copy_doc(time_log_records[0])
|
time_log = create_time_log()
|
||||||
time_log.update({
|
|
||||||
"from_time": "2013-01-02 10:00:00.000000",
|
|
||||||
"to_time": "2013-01-02 11:00:00.000000",
|
|
||||||
"docstatus": 0
|
|
||||||
})
|
|
||||||
time_log.insert()
|
|
||||||
time_log.submit()
|
|
||||||
|
|
||||||
self.assertEquals(frappe.db.get_value("Time Log", time_log.name, "status"), "Submitted")
|
self.assertEquals(frappe.db.get_value("Time Log", time_log, "status"), "Submitted")
|
||||||
tlb = frappe.copy_doc(test_records[0])
|
|
||||||
tlb.get("time_log_batch_details")[0].time_log = time_log.name
|
|
||||||
tlb.insert()
|
|
||||||
tlb.submit()
|
|
||||||
|
|
||||||
self.assertEquals(frappe.db.get_value("Time Log", time_log.name, "status"), "Batched for Billing")
|
tlb = create_time_log_batch(time_log)
|
||||||
|
|
||||||
|
self.assertEquals(frappe.db.get_value("Time Log", time_log, "status"), "Batched for Billing")
|
||||||
tlb.cancel()
|
tlb.cancel()
|
||||||
self.assertEquals(frappe.db.get_value("Time Log", time_log.name, "status"), "Submitted")
|
self.assertEquals(frappe.db.get_value("Time Log", time_log, "status"), "Submitted")
|
||||||
|
|
||||||
|
delete_time_log_and_batch()
|
||||||
|
|
||||||
|
def delete_time_log_and_batch():
|
||||||
|
for name in frappe.db.sql_list("select name from `tabTime Log Batch` where docstatus=1"):
|
||||||
|
frappe.get_doc("Time Log Batch", name).cancel()
|
||||||
|
frappe.delete_doc("Time Log Batch", name)
|
||||||
|
|
||||||
|
for name in frappe.db.sql_list("select name from `tabTime Log` where docstatus=1"):
|
||||||
|
frappe.get_doc("Time Log", name).cancel()
|
||||||
|
frappe.delete_doc("Time Log", name)
|
||||||
|
|
||||||
|
def create_time_log():
|
||||||
|
from erpnext.projects.doctype.time_log.test_time_log import test_records as time_log_records
|
||||||
|
time_log = frappe.copy_doc(time_log_records[0])
|
||||||
|
time_log.update({
|
||||||
|
"from_time": "2013-01-02 10:00:00.000000",
|
||||||
|
"to_time": "2013-01-02 11:00:00.000000",
|
||||||
|
"docstatus": 0
|
||||||
|
})
|
||||||
|
time_log.insert()
|
||||||
|
time_log.submit()
|
||||||
|
return time_log.name
|
||||||
|
|
||||||
|
def create_time_log_batch(time_log):
|
||||||
|
tlb = frappe.get_doc({
|
||||||
|
"doctype": "Time Log Batch",
|
||||||
|
"rate": "500",
|
||||||
|
"time_log_batch_details": [
|
||||||
|
{
|
||||||
|
"doctype": "Time Log Batch Detail",
|
||||||
|
"parentfield": "time_log_batch_details",
|
||||||
|
"parenttype": "Time Log Batch",
|
||||||
|
"time_log": time_log
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
tlb.insert()
|
||||||
|
tlb.submit()
|
||||||
|
return tlb
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Time Log Batch')
|
|
||||||
test_dependencies = ["Time Log"]
|
|
||||||
test_ignore = ["Sales Invoice"]
|
test_ignore = ["Sales Invoice"]
|
||||||
|
|||||||
Reference in New Issue
Block a user