mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 03:29:16 +00:00
chore: Refactor test cases to use context manager for user setting
This commit is contained in:
@@ -27,21 +27,18 @@ class TestWebsite(IntegrationTestCase):
|
||||
create_order_assignment(supplier="Supplier1", po=po1.name)
|
||||
create_order_assignment(supplier="Supplier2", po=po2.name)
|
||||
|
||||
frappe.set_user("Administrator")
|
||||
# checking if data consist of all order assignment of Supplier1 and Supplier2
|
||||
self.assertTrue("Supplier1" and "Supplier2" in [data.supplier for data in get_data()])
|
||||
|
||||
frappe.set_user("supplier1@gmail.com")
|
||||
# checking if data only consist of order assignment of Supplier1
|
||||
self.assertTrue("Supplier1" in [data.supplier for data in get_data()])
|
||||
self.assertFalse([data.supplier for data in get_data() if data.supplier != "Supplier1"])
|
||||
with self.set_user("supplier1@gmail.com"):
|
||||
# checking if data only consist of order assignment of Supplier1
|
||||
self.assertTrue("Supplier1" in [data.supplier for data in get_data()])
|
||||
self.assertFalse([data.supplier for data in get_data() if data.supplier != "Supplier1"])
|
||||
|
||||
frappe.set_user("supplier2@gmail.com")
|
||||
# checking if data only consist of order assignment of Supplier2
|
||||
self.assertTrue("Supplier2" in [data.supplier for data in get_data()])
|
||||
self.assertFalse([data.supplier for data in get_data() if data.supplier != "Supplier2"])
|
||||
|
||||
frappe.set_user("Administrator")
|
||||
with self.set_user("supplier2@gmail.com"):
|
||||
# checking if data only consist of order assignment of Supplier2
|
||||
self.assertTrue("Supplier2" in [data.supplier for data in get_data()])
|
||||
self.assertFalse([data.supplier for data in get_data() if data.supplier != "Supplier2"])
|
||||
|
||||
|
||||
def get_data():
|
||||
|
||||
Reference in New Issue
Block a user