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 |
| 5 | import unittest |
| 6 | |
| 7 | from frappe.desk import notifications |
| 8 | from frappe.test_runner import make_test_objects |
| 9 | |
| 10 | class TestNotifications(unittest.TestCase): |
| 11 | def setUp(self): |
Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 12 | test_records_company = [ |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 13 | { |
Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 14 | "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 Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 22 | }, |
| 23 | { |
Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 24 | "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 Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 33 | }, |
| 34 | ] |
| 35 | |
Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 36 | make_test_objects('Company', test_records=test_records_company, reset=True) |
Prateeksha Singh | e012e24 | 2017-07-18 10:35:12 +0530 | [diff] [blame] | 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, {}) |
Achilles Rasquinha | 6465228 | 2018-02-28 21:13:51 +0530 | [diff] [blame] | 45 | self.assertEqual(doc_target_percents['Company']['_Test Company 7'], 10) |
| 46 | self.assertEqual(doc_target_percents['Company']['_Test Company 6'], 0) |