915b34391c
* chore: Added isort to pre-commit config * chore: Sort imports with isort * chore: Clean up imports with pycln * chore: Sort imports with isort * chore: Fix import issues * chore: Clean up sider issues * chore: Remove import errors from flake8 ignore list * chore: Clean up lint issues
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
|
# MIT License. See license.txt
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import unittest
|
|
|
|
import frappe
|
|
from frappe.desk import notifications
|
|
|
|
|
|
class TestNotifications(unittest.TestCase):
|
|
def test_get_notifications_for_targets(self):
|
|
'''
|
|
Test notification config entries for targets as percentages
|
|
'''
|
|
|
|
company = frappe.get_all("Company")[0]
|
|
frappe.db.set_value("Company", company.name, "monthly_sales_target", 10000)
|
|
frappe.db.set_value("Company", company.name, "total_monthly_sales", 1000)
|
|
|
|
config = notifications.get_notification_config()
|
|
doc_target_percents = notifications.get_notifications_for_targets(config, {})
|
|
|
|
self.assertEqual(doc_target_percents['Company'][company.name], 10)
|
|
|
|
frappe.db.set_value("Company", company.name, "monthly_sales_target", 2000)
|
|
frappe.db.set_value("Company", company.name, "total_monthly_sales", 0)
|
|
|
|
config = notifications.get_notification_config()
|
|
doc_target_percents = notifications.get_notifications_for_targets(config, {})
|
|
|
|
self.assertEqual(doc_target_percents['Company'][company.name], 0)
|