perf(tests): Do not unnecessarily create companies
This commit is contained in:
parent
0d333894c9
commit
8773d931be
@ -2,45 +2,31 @@
|
|||||||
# MIT License. See license.txt
|
# MIT License. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from frappe.desk import notifications
|
from frappe.desk import notifications
|
||||||
from frappe.test_runner import make_test_objects
|
from frappe.test_runner import make_test_objects
|
||||||
|
|
||||||
class TestNotifications(unittest.TestCase):
|
class TestNotifications(unittest.TestCase):
|
||||||
def setUp(self):
|
|
||||||
test_records_company = [
|
|
||||||
{
|
|
||||||
"abbr": "_TC6",
|
|
||||||
"company_name": "_Test Company 6",
|
|
||||||
"country": "India",
|
|
||||||
"default_currency": "INR",
|
|
||||||
"doctype": "Company",
|
|
||||||
"domain": "Manufacturing",
|
|
||||||
"monthly_sales_target": 2000,
|
|
||||||
"chart_of_accounts": "Standard"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"abbr": "_TC7",
|
|
||||||
"company_name": "_Test Company 7",
|
|
||||||
"country": "United States",
|
|
||||||
"default_currency": "USD",
|
|
||||||
"doctype": "Company",
|
|
||||||
"domain": "Retail",
|
|
||||||
"monthly_sales_target": 10000,
|
|
||||||
"total_monthly_sales": 1000,
|
|
||||||
"chart_of_accounts": "Standard"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
make_test_objects('Company', test_records=test_records_company, reset=True)
|
|
||||||
|
|
||||||
def test_get_notifications_for_targets(self):
|
def test_get_notifications_for_targets(self):
|
||||||
'''
|
'''
|
||||||
Test notification config entries for targets as percentages
|
Test notification config entries for targets as percentages
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
company = frappe.get_all("Company")[0]
|
||||||
|
frappe.db.set_value("Company", company.name, "monthly_sales_target", 10000)
|
||||||
|
frappe.db.set_value("Company", company.name, "total_monthly_sales", 1000)
|
||||||
|
|
||||||
config = notifications.get_notification_config()
|
config = notifications.get_notification_config()
|
||||||
doc_target_percents = notifications.get_notifications_for_targets(config, {})
|
doc_target_percents = notifications.get_notifications_for_targets(config, {})
|
||||||
self.assertEqual(doc_target_percents['Company']['_Test Company 7'], 10)
|
|
||||||
self.assertEqual(doc_target_percents['Company']['_Test Company 6'], 0)
|
self.assertEqual(doc_target_percents['Company'][company.name], 10)
|
||||||
|
|
||||||
|
frappe.db.set_value("Company", company.name, "monthly_sales_target", 2000)
|
||||||
|
frappe.db.set_value("Company", company.name, "total_monthly_sales", 0)
|
||||||
|
|
||||||
|
config = notifications.get_notification_config()
|
||||||
|
doc_target_percents = notifications.get_notifications_for_targets(config, {})
|
||||||
|
|
||||||
|
self.assertEqual(doc_target_percents['Company'][company.name], 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user