Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 1 | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
| 2 | # MIT License. See license.txt |
| 3 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 4 | |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 5 | import unittest |
| 6 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 7 | import frappe |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 8 | from frappe.desk import notifications |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 9 | |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 10 | |
| 11 | class TestNotifications(unittest.TestCase): |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 12 | def test_get_notifications_for_targets(self): |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 13 | """ |
| 14 | Test notification config entries for targets as percentages |
| 15 | """ |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 16 | |
Aditya Hase | 8773d93 | 2019-07-26 00:38:51 +0530 | [diff] [blame] | 17 | company = frappe.get_all("Company")[0] |
| 18 | frappe.db.set_value("Company", company.name, "monthly_sales_target", 10000) |
| 19 | frappe.db.set_value("Company", company.name, "total_monthly_sales", 1000) |
| 20 | |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 21 | config = notifications.get_notification_config() |
| 22 | doc_target_percents = notifications.get_notifications_for_targets(config, {}) |
Aditya Hase | 8773d93 | 2019-07-26 00:38:51 +0530 | [diff] [blame] | 23 | |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 24 | self.assertEqual(doc_target_percents["Company"][company.name], 10) |
Aditya Hase | 8773d93 | 2019-07-26 00:38:51 +0530 | [diff] [blame] | 25 | |
| 26 | frappe.db.set_value("Company", company.name, "monthly_sales_target", 2000) |
| 27 | frappe.db.set_value("Company", company.name, "total_monthly_sales", 0) |
| 28 | |
| 29 | config = notifications.get_notification_config() |
| 30 | doc_target_percents = notifications.get_notifications_for_targets(config, {}) |
| 31 | |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 32 | self.assertEqual(doc_target_percents["Company"][company.name], 0) |