blob: 669bf6f3d9240cdb0576f87d8243199bd7174a5e [file] [log] [blame]
Prateeksha Singhe012e242017-07-18 10:35:12 +05301# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2# MIT License. See license.txt
3
Chillar Anand915b3432021-09-02 16:44:59 +05304
Prateeksha Singhe012e242017-07-18 10:35:12 +05305import unittest
6
Chillar Anand915b3432021-09-02 16:44:59 +05307import frappe
Prateeksha Singhe012e242017-07-18 10:35:12 +05308from frappe.desk import notifications
Chillar Anand915b3432021-09-02 16:44:59 +05309
Prateeksha Singhe012e242017-07-18 10:35:12 +053010
11class TestNotifications(unittest.TestCase):
Prateeksha Singhe012e242017-07-18 10:35:12 +053012 def test_get_notifications_for_targets(self):
13 '''
14 Test notification config entries for targets as percentages
15 '''
16
Aditya Hase8773d932019-07-26 00:38:51 +053017 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 Singhe012e242017-07-18 10:35:12 +053021 config = notifications.get_notification_config()
22 doc_target_percents = notifications.get_notifications_for_targets(config, {})
Aditya Hase8773d932019-07-26 00:38:51 +053023
24 self.assertEqual(doc_target_percents['Company'][company.name], 10)
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
32 self.assertEqual(doc_target_percents['Company'][company.name], 0)