brotherton-erpnext/erpnext/tests/test_notifications.py

33 lines
1.1 KiB
Python
Raw Normal View History

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
import unittest
import frappe
from frappe.desk import notifications
class TestNotifications(unittest.TestCase):
def test_get_notifications_for_targets(self):
2022-03-28 13:22:46 +00:00
"""
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()
doc_target_percents = notifications.get_notifications_for_targets(config, {})
2022-03-28 13:22:46 +00:00
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, {})
2022-03-28 13:22:46 +00:00
self.assertEqual(doc_target_percents["Company"][company.name], 0)