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 | |
| 4 | from __future__ import unicode_literals |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 5 | |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 6 | import unittest |
| 7 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 8 | import frappe |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 9 | from frappe.desk import notifications |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 10 | |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 11 | |
| 12 | class TestNotifications(unittest.TestCase): |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 13 | def test_get_notifications_for_targets(self): |
| 14 | ''' |
| 15 | Test notification config entries for targets as percentages |
| 16 | ''' |
| 17 | |
Aditya Hase | 8773d93 | 2019-07-26 00:38:51 +0530 | [diff] [blame] | 18 | company = frappe.get_all("Company")[0] |
| 19 | frappe.db.set_value("Company", company.name, "monthly_sales_target", 10000) |
| 20 | frappe.db.set_value("Company", company.name, "total_monthly_sales", 1000) |
| 21 | |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 22 | config = notifications.get_notification_config() |
| 23 | doc_target_percents = notifications.get_notifications_for_targets(config, {}) |
Aditya Hase | 8773d93 | 2019-07-26 00:38:51 +0530 | [diff] [blame] | 24 | |
| 25 | self.assertEqual(doc_target_percents['Company'][company.name], 10) |
| 26 | |
| 27 | frappe.db.set_value("Company", company.name, "monthly_sales_target", 2000) |
| 28 | frappe.db.set_value("Company", company.name, "total_monthly_sales", 0) |
| 29 | |
| 30 | config = notifications.get_notification_config() |
| 31 | doc_target_percents = notifications.get_notifications_for_targets(config, {}) |
| 32 | |
| 33 | self.assertEqual(doc_target_percents['Company'][company.name], 0) |