test case fixes
This commit is contained in:
parent
2eba53f763
commit
fd4bcd855b
@ -279,7 +279,7 @@ class BuyingController(StockController):
|
||||
|
||||
def set_qty_as_per_stock_uom(self):
|
||||
for d in self.get("items"):
|
||||
if d.meta.get_field("stock_qty") and not d.stock_qty:
|
||||
if d.meta.get_field("stock_qty"):
|
||||
if not d.conversion_factor:
|
||||
frappe.throw(_("Row {0}: Conversion Factor is mandatory").format(d.idx))
|
||||
d.stock_qty = flt(d.qty) * flt(d.conversion_factor)
|
||||
|
@ -92,7 +92,7 @@ def unsubscribe(email, name):
|
||||
return
|
||||
|
||||
subs_id = frappe.db.get_value("Newsletter List Subscriber", {"email": email, "newsletter_list": name})
|
||||
if name:
|
||||
if subs_id:
|
||||
subscriber = frappe.get_doc("Newsletter List Subscriber", subs_id)
|
||||
subscriber.unsubscribed = 1
|
||||
subscriber.save(ignore_permissions=True)
|
||||
|
@ -9,7 +9,16 @@ from urllib import unquote
|
||||
|
||||
class TestNewsletter(unittest.TestCase):
|
||||
def setUp(self):
|
||||
frappe.db.sql("update `tabNewsletter List Subscriber` set unsubscribed = 0")
|
||||
if not frappe.get_all("Newsletter List Subscriber"):
|
||||
for email in ["test_subscriber1@example.com", "test_subscriber2@example.com",
|
||||
"test_subscriber3@example.com"]:
|
||||
frappe.get_doc({
|
||||
"doctype": "Newsletter List Subscriber",
|
||||
"email": email,
|
||||
"newsletter_list": "_Test Newsletter List"
|
||||
}).insert()
|
||||
else:
|
||||
frappe.db.sql("update `tabNewsletter List Subscriber` set unsubscribed = 0")
|
||||
|
||||
def test_send(self):
|
||||
self.send_newsletter()
|
||||
@ -39,6 +48,4 @@ class TestNewsletter(unittest.TestCase):
|
||||
|
||||
newsletter.send_emails()
|
||||
|
||||
|
||||
|
||||
test_dependencies = ["Newsletter List"]
|
||||
|
@ -6,8 +6,6 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
# test_records = frappe.get_test_records('Newletter List')
|
||||
|
||||
class TestNewletterList(unittest.TestCase):
|
||||
def test_import(self):
|
||||
new_list = frappe.get_doc({
|
||||
@ -15,13 +13,13 @@ class TestNewletterList(unittest.TestCase):
|
||||
"title": "_Test Newsletter List 1"
|
||||
}).insert()
|
||||
|
||||
n_leads = frappe.db.count("Lead")
|
||||
|
||||
n_leads = frappe.db.sql("select count(distinct email_id) from `tabLead`")[0][0]
|
||||
|
||||
added = new_list.import_from("Lead")
|
||||
|
||||
self.assertEquals(added, n_leads)
|
||||
|
||||
frappe.delete_doc("Newsletter List", new_list.name)
|
||||
def tearDown(self):
|
||||
frappe.delete_doc("Newsletter List", "_Test Newsletter List 1")
|
||||
|
||||
test_dependencies = ["Lead"]
|
||||
|
||||
|
@ -2,20 +2,5 @@
|
||||
{
|
||||
"doctype": "Newsletter List",
|
||||
"title": "_Test Newsletter List"
|
||||
},
|
||||
{
|
||||
"doctype": "Newsletter List Subscriber",
|
||||
"email": "test_subscriber1@example.com",
|
||||
"newsletter_list": "_Test Newsletter List"
|
||||
},
|
||||
{
|
||||
"doctype": "Newsletter List Subscriber",
|
||||
"email": "test_subscriber2@example.com",
|
||||
"newsletter_list": "_Test Newsletter List"
|
||||
},
|
||||
{
|
||||
"doctype": "Newsletter List Subscriber",
|
||||
"email": "test_subscriber3@example.com",
|
||||
"newsletter_list": "_Test Newsletter List"
|
||||
}
|
||||
]
|
||||
|
@ -10,4 +10,4 @@ class NewsletterListSubscriber(Document):
|
||||
pass
|
||||
|
||||
def after_doctype_insert():
|
||||
frappe.db.add_unique("Newsletter List Subscriber", ("name", "email"))
|
||||
frappe.db.add_unique("Newsletter List Subscriber", ("newsletter_list", "email"))
|
||||
|
@ -130,10 +130,9 @@ class TestProductionOrder(unittest.TestCase):
|
||||
prod_order = make_prod_order_test_record(item="_Test FG Item 2",
|
||||
planned_start_date="2014-11-25 00:00:00", qty=1, do_not_save=True)
|
||||
prod_order.set_production_order_operations()
|
||||
prod_order.save()
|
||||
cost = prod_order.planned_operating_cost
|
||||
prod_order.qty = 2
|
||||
prod_order.save()
|
||||
prod_order.set_production_order_operations()
|
||||
self.assertEqual(prod_order.planned_operating_cost, cost*2)
|
||||
|
||||
def make_prod_order_test_record(**args):
|
||||
|
@ -34,6 +34,9 @@ class TestCustomer(unittest.TestCase):
|
||||
|
||||
make_test_records("Address")
|
||||
make_test_records("Contact")
|
||||
frappe.db.set_value("Contact", "_Test Contact For _Test Customer-_Test Customer",
|
||||
"is_primary_contact", 1)
|
||||
|
||||
details = get_party_details("_Test Customer")
|
||||
|
||||
for key, value in to_check.iteritems():
|
||||
|
@ -7,7 +7,7 @@ import unittest
|
||||
import frappe
|
||||
import json
|
||||
import frappe.defaults
|
||||
from frappe.utils import cint, nowdate, nowtime, cstr, add_days
|
||||
from frappe.utils import cint, nowdate, nowtime, cstr, add_days, flt
|
||||
from erpnext.stock.stock_ledger import get_previous_sle
|
||||
from erpnext.accounts.utils import get_balance_on
|
||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \
|
||||
@ -136,7 +136,7 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
|
||||
# check stock in hand balance
|
||||
bal = get_balance_on(stock_in_hand_account)
|
||||
self.assertEquals(bal, prev_bal - stock_value_diff)
|
||||
self.assertEquals(flt(bal, 2), flt(prev_bal - stock_value_diff, 2))
|
||||
|
||||
dn.cancel()
|
||||
self.assertFalse(get_gl_entries("Delivery Note", dn.name))
|
||||
|
@ -81,17 +81,21 @@ class TestStockEntry(unittest.TestCase):
|
||||
template = frappe.get_doc("Item", item.variant_of)
|
||||
else:
|
||||
template = item
|
||||
|
||||
projected_qty, actual_qty = frappe.db.get_value("Bin", {"item_code": item_code,
|
||||
"warehouse": "_Test Warehouse - _TC"}, ["projected_qty", "actual_qty"]) or 0
|
||||
|
||||
# stock entry reqd for auto-reorder
|
||||
create_stock_reconciliation(item_code=item_code, warehouse="_Test Warehouse - _TC",
|
||||
qty=10, rate=100)
|
||||
|
||||
frappe.db.set_value("Stock Settings", None, "auto_indent", 1)
|
||||
projected_qty = frappe.db.get_value("Bin", {"item_code": item_code,
|
||||
qty = actual_qty + abs(projected_qty) + 10, rate=100)
|
||||
|
||||
projected_qty = projected_qty = frappe.db.get_value("Bin", {"item_code": item_code,
|
||||
"warehouse": "_Test Warehouse - _TC"}, "projected_qty") or 0
|
||||
|
||||
|
||||
frappe.db.set_value("Stock Settings", None, "auto_indent", 1)
|
||||
|
||||
# update re-level qty so that it is more than projected_qty
|
||||
if projected_qty > template.reorder_levels[0].warehouse_reorder_level:
|
||||
if projected_qty >= template.reorder_levels[0].warehouse_reorder_level:
|
||||
template.reorder_levels[0].warehouse_reorder_level += projected_qty
|
||||
template.save()
|
||||
|
||||
|
@ -227,7 +227,7 @@ class StockReconciliation(StockController):
|
||||
msgprint(_("Please enter Expense Account"), raise_exception=1)
|
||||
elif not frappe.db.sql("""select name from `tabStock Ledger Entry` limit 1"""):
|
||||
if frappe.db.get_value("Account", self.expense_account, "report_type") == "Profit and Loss":
|
||||
frappe.throw(_("Difference Account must be a 'Liability' type account, since this Stock Reconciliation is an Opening Entry"), OpeningEntryAccountError)
|
||||
frappe.throw(_("Difference Account must be a Asset/Liability type account, since this Stock Reconciliation is an Opening Entry"), OpeningEntryAccountError)
|
||||
|
||||
def get_items_for(self, warehouse):
|
||||
self.items = []
|
||||
|
@ -97,7 +97,8 @@ def create_stock_reconciliation(**args):
|
||||
sr.posting_time = args.posting_time or nowtime()
|
||||
sr.company = args.company or "_Test Company"
|
||||
sr.fiscal_year = get_fiscal_year(sr.posting_date)[0]
|
||||
sr.expense_account = args.expense_account or "Stock Adjustment - _TC"
|
||||
sr.expense_account = args.expense_account or \
|
||||
("Stock Adjustment - _TC" if frappe.get_all("Stock Ledger Entry") else "Temporary Opening - _TC")
|
||||
sr.cost_center = args.cost_center or "_Test Cost Center - _TC"
|
||||
sr.append("items", {
|
||||
"item_code": args.item_code or "_Test Item",
|
||||
|
@ -11,10 +11,7 @@ def reorder_item():
|
||||
if not frappe.db.sql("select name from `tabFiscal Year` limit 1"):
|
||||
return
|
||||
|
||||
if getattr(frappe.local, "auto_indent", None) is None:
|
||||
frappe.local.auto_indent = cint(frappe.db.get_value('Stock Settings', None, 'auto_indent'))
|
||||
|
||||
if frappe.local.auto_indent:
|
||||
if cint(frappe.db.get_value('Stock Settings', None, 'auto_indent')):
|
||||
return _reorder_item()
|
||||
|
||||
def _reorder_item():
|
||||
|
Loading…
x
Reference in New Issue
Block a user