2017-07-18 05:05:12 +00:00
|
|
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
|
|
|
# MIT License. See license.txt
|
|
|
|
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2017-07-18 05:05:12 +00:00
|
|
|
import unittest
|
|
|
|
|
2021-09-02 11:14:59 +00:00
|
|
|
import frappe
|
2017-07-18 05:05:12 +00:00
|
|
|
from frappe.desk import notifications
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2017-07-18 05:05:12 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
"""
|
2017-07-18 05:05:12 +00:00
|
|
|
|
2019-07-25 19:08:51 +00:00
|
|
|
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)
|
2019-07-25 19:08:51 +00:00
|
|
|
|
|
|
|
frappe.db.set_value("Company", company.name, "monthly_sales_target", 2000)
|
|
|
|
frappe.db.set_value("Company", company.name, "total_monthly_sales", 0)
|
|
|
|
|
2017-07-18 05:05:12 +00:00
|
|
|
config = notifications.get_notification_config()
|
|
|
|
doc_target_percents = notifications.get_notifications_for_targets(config, {})
|
2019-07-25 19:08:51 +00:00
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
self.assertEqual(doc_target_percents["Company"][company.name], 0)
|