-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: configuration to notify reposting errors to specific role
- Loading branch information
1 parent
9aa6465
commit c7b6201
Showing
3 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 33 additions & 2 deletions
35
erpnext/stock/doctype/stock_reposting_settings/test_stock_reposting_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,40 @@ | ||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors | ||
# See license.txt | ||
|
||
# import frappe | ||
import unittest | ||
|
||
import frappe | ||
|
||
from erpnext.stock.doctype.repost_item_valuation.repost_item_valuation import get_recipients | ||
|
||
|
||
class TestStockRepostingSettings(unittest.TestCase): | ||
pass | ||
def test_notify_reposting_error_to_role(self): | ||
role = "Notify Reposting Role" | ||
|
||
if not frappe.db.exists("Role", role): | ||
frappe.get_doc({"doctype": "Role", "role_name": role}).insert(ignore_permissions=True) | ||
|
||
user = "notify_reposting_error@test.com" | ||
if not frappe.db.exists("User", user): | ||
frappe.get_doc( | ||
{ | ||
"doctype": "User", | ||
"email": user, | ||
"first_name": "Test", | ||
"language": "en", | ||
"time_zone": "Asia/Kolkata", | ||
"send_welcome_email": 0, | ||
"roles": [{"role": role}], | ||
} | ||
).insert(ignore_permissions=True) | ||
|
||
frappe.db.set_single_value("Stock Reposting Settings", "notify_reposting_error_to_role", "") | ||
|
||
users = get_recipients() | ||
self.assertFalse(user in users) | ||
|
||
frappe.db.set_single_value("Stock Reposting Settings", "notify_reposting_error_to_role", role) | ||
|
||
users = get_recipients() | ||
self.assertTrue(user in users) |