fixed test cases

This commit is contained in:
Anand Doshi 2015-03-18 16:21:53 +05:30
parent 60aee54c6c
commit 9d8154dd40
5 changed files with 75 additions and 79 deletions

View File

@ -5,6 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
import frappe.permissions import frappe.permissions
from erpnext.controllers.recurring_document import date_field_map from erpnext.controllers.recurring_document import date_field_map
from frappe.utils import getdate
def test_recurring_document(obj, test_records): def test_recurring_document(obj, test_records):
from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate, add_days from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate, add_days
@ -132,19 +133,14 @@ def _test_recurring_document(obj, base_doc, date_field, first_and_last_day):
obj.assertEquals(base_doc.get(fieldname), obj.assertEquals(base_doc.get(fieldname),
new_doc.get(fieldname)) new_doc.get(fieldname))
obj.assertEquals(new_doc.get(date_field), unicode(next_date)) obj.assertEquals(new_doc.get(date_field), getdate(next_date))
obj.assertEquals(new_doc.from_date, obj.assertEquals(new_doc.from_date, getdate(add_months(base_doc.from_date, no_of_months)))
unicode(add_months(base_doc.from_date, no_of_months)))
if first_and_last_day: if first_and_last_day:
obj.assertEquals(new_doc.to_date, obj.assertEquals(new_doc.to_date, getdate(get_last_day(add_months(base_doc.to_date, no_of_months))))
unicode(get_last_day(add_months(base_doc.to_date,
no_of_months))))
else: else:
obj.assertEquals(new_doc.to_date, obj.assertEquals(new_doc.to_date, getdate(add_months(base_doc.to_date, no_of_months)))
unicode(add_months(base_doc.to_date, no_of_months)))
return new_doc return new_doc

View File

@ -7,7 +7,6 @@ from __future__ import unicode_literals
import frappe import frappe
from erpnext.accounts.utils import validate_fiscal_year from erpnext.accounts.utils import validate_fiscal_year
from frappe import _ from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
class LeaveBlockList(Document): class LeaveBlockList(Document):

View File

@ -5,6 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
import unittest import unittest
from frappe.utils import getdate
from erpnext.hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates from erpnext.hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates
class TestLeaveBlockList(unittest.TestCase): class TestLeaveBlockList(unittest.TestCase):
@ -15,7 +16,7 @@ class TestLeaveBlockList(unittest.TestCase):
frappe.set_user("test@example.com") frappe.set_user("test@example.com")
frappe.db.set_value("Department", "_Test Department", "leave_block_list", frappe.db.set_value("Department", "_Test Department", "leave_block_list",
"_Test Leave Block List") "_Test Leave Block List")
self.assertTrue("2013-01-02" in self.assertTrue(getdate("2013-01-02") in
[d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")]) [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")])
def test_get_applicable_block_dates_for_allowed_user(self): def test_get_applicable_block_dates_for_allowed_user(self):
@ -28,7 +29,7 @@ class TestLeaveBlockList(unittest.TestCase):
frappe.set_user("test1@example.com") frappe.set_user("test1@example.com")
frappe.db.set_value("Department", "_Test Department 1", "leave_block_list", frappe.db.set_value("Department", "_Test Department 1", "leave_block_list",
"_Test Leave Block List") "_Test Leave Block List")
self.assertTrue("2013-01-02" in self.assertTrue(getdate("2013-01-02") in
[d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03", all_lists=True)]) [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03", all_lists=True)])
test_dependencies = ["Employee"] test_dependencies = ["Employee"]

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _ from frappe import _
from frappe.utils import flt, cint, getdate, formatdate, comma_and, time_diff_in_seconds from frappe.utils import flt, cint, getdate, formatdate, comma_and, time_diff_in_seconds, get_datetime
from frappe.model.document import Document from frappe.model.document import Document
from dateutil.parser import parse from dateutil.parser import parse
@ -60,7 +60,7 @@ def is_within_operating_hours(workstation, operation, from_datetime, to_datetime
workstation = frappe.get_doc("Workstation", workstation) workstation = frappe.get_doc("Workstation", workstation)
for working_hour in workstation.working_hours: for working_hour in workstation.working_hours:
slot_length = (parse(working_hour.end_time) - parse(working_hour.start_time)).total_seconds() slot_length = (get_datetime(working_hour.end_time) - get_datetime(working_hour.start_time)).total_seconds()
if slot_length >= operation_length: if slot_length >= operation_length:
return return

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe, unittest import frappe, unittest
import frappe.defaults import frappe.defaults
from frappe.utils import flt, nowdate, nowtime from frappe.utils import flt, nowdate, nowtime, getdate
from erpnext.stock.doctype.serial_no.serial_no import * from erpnext.stock.doctype.serial_no.serial_no import *
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \ from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \
import set_perpetual_inventory, make_purchase_receipt import set_perpetual_inventory, make_purchase_receipt
@ -371,7 +371,7 @@ class TestStockEntry(unittest.TestCase):
self.assertEqual(len(jv.get("accounts")), 2) self.assertEqual(len(jv.get("accounts")), 2)
self.assertEqual(jv.get("voucher_type"), "Credit Note") self.assertEqual(jv.get("voucher_type"), "Credit Note")
self.assertEqual(jv.get("posting_date"), se.posting_date) self.assertEqual(jv.get("posting_date"), getdate(se.posting_date))
self.assertEqual(jv.get("accounts")[0].get("account"), "Debtors - _TC") self.assertEqual(jv.get("accounts")[0].get("account"), "Debtors - _TC")
self.assertEqual(jv.get("accounts")[0].get("party_type"), "Customer") self.assertEqual(jv.get("accounts")[0].get("party_type"), "Customer")
self.assertEqual(jv.get("accounts")[0].get("party"), "_Test Customer") self.assertEqual(jv.get("accounts")[0].get("party"), "_Test Customer")
@ -476,7 +476,7 @@ class TestStockEntry(unittest.TestCase):
self.assertEqual(len(jv.get("accounts")), 2) self.assertEqual(len(jv.get("accounts")), 2)
self.assertEqual(jv.get("voucher_type"), "Debit Note") self.assertEqual(jv.get("voucher_type"), "Debit Note")
self.assertEqual(jv.get("posting_date"), se.posting_date) self.assertEqual(jv.get("posting_date"), getdate(se.posting_date))
self.assertEqual(jv.get("accounts")[0].get("account"), "_Test Payable - _TC") self.assertEqual(jv.get("accounts")[0].get("account"), "_Test Payable - _TC")
self.assertEqual(jv.get("accounts")[0].get("party"), "_Test Supplier") self.assertEqual(jv.get("accounts")[0].get("party"), "_Test Supplier")
self.assertEqual(jv.get("accounts")[1].get("account"), "_Test Account Cost for Goods Sold - _TC") self.assertEqual(jv.get("accounts")[1].get("account"), "_Test Account Cost for Goods Sold - _TC")