blob: 596bc80deeacfbad176afa8830d089c675ae416a [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
4from __future__ import unicode_literals
5import unittest
6
7from frappe.desk import notifications
8from frappe.test_runner import make_test_objects
9
10class TestNotifications(unittest.TestCase):
11 def setUp(self):
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053012 test_records_company = [
Prateeksha Singhe012e242017-07-18 10:35:12 +053013 {
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053014 "abbr": "_TC6",
15 "company_name": "_Test Company 6",
16 "country": "India",
17 "default_currency": "INR",
18 "doctype": "Company",
19 "domain": "Manufacturing",
20 "monthly_sales_target": 2000,
21 "chart_of_accounts": "Standard"
Prateeksha Singhe012e242017-07-18 10:35:12 +053022 },
23 {
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053024 "abbr": "_TC7",
25 "company_name": "_Test Company 7",
26 "country": "United States",
27 "default_currency": "USD",
28 "doctype": "Company",
29 "domain": "Retail",
30 "monthly_sales_target": 10000,
31 "total_monthly_sales": 1000,
32 "chart_of_accounts": "Standard"
Prateeksha Singhe012e242017-07-18 10:35:12 +053033 },
34 ]
35
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053036 make_test_objects('Company', test_records=test_records_company, reset=True)
Prateeksha Singhe012e242017-07-18 10:35:12 +053037
38 def test_get_notifications_for_targets(self):
39 '''
40 Test notification config entries for targets as percentages
41 '''
42
43 config = notifications.get_notification_config()
44 doc_target_percents = notifications.get_notifications_for_targets(config, {})
Achilles Rasquinha64652282018-02-28 21:13:51 +053045 self.assertEqual(doc_target_percents['Company']['_Test Company 7'], 10)
46 self.assertEqual(doc_target_percents['Company']['_Test Company 6'], 0)