blob: 752badfed070971c479bfd97969c97ece05e3321 [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):
12 test_records = [
13 {
14 "abbr": "_TC6",
15 "company_name": "_Test Company 6",
16 "country": "India",
17 "default_currency": "INR",
18 "doctype": "Company",
19 "domain": "Manufacturing",
20 "sales_target": 2000,
21 "chart_of_accounts": "Standard"
22 },
23 {
24 "abbr": "_TC7",
25 "company_name": "_Test Company 7",
26 "country": "United States",
27 "default_currency": "USD",
28 "doctype": "Company",
29 "domain": "Retail",
30 "sales_target": 10000,
31 "total_monthly_sales": 1000,
32 "chart_of_accounts": "Standard"
33 },
34 ]
35
36 make_test_objects('Company', test_records=test_records, reset=True)
37
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, {})
45 self.assertEquals(doc_target_percents['Company']['_Test Company 7'], 10)
46 self.assertEquals(doc_target_percents['Company']['_Test Company 6'], 0)