test: many users linked to customer shopping cart
This commit is contained in:
parent
a3e69cf75d
commit
d636c3fb04
@ -57,13 +57,19 @@ class TestShoppingCart(unittest.TestCase):
|
|||||||
return quotation
|
return quotation
|
||||||
|
|
||||||
def test_get_cart_customer(self):
|
def test_get_cart_customer(self):
|
||||||
self.login_as_customer()
|
def validate_quotation():
|
||||||
|
# test if quotation with customer is fetched
|
||||||
|
quotation = _get_cart_quotation()
|
||||||
|
self.assertEqual(quotation.quotation_to, "Customer")
|
||||||
|
self.assertEqual(quotation.party_name, "_Test Customer")
|
||||||
|
self.assertEqual(quotation.contact_email, frappe.session.user)
|
||||||
|
return quotation
|
||||||
|
|
||||||
# test if quotation with customer is fetched
|
self.login_as_customer("test_contact_two_customer@example.com", "_Test Contact 2 For _Test Customer")
|
||||||
quotation = _get_cart_quotation()
|
validate_quotation()
|
||||||
self.assertEqual(quotation.quotation_to, "Customer")
|
|
||||||
self.assertEqual(quotation.party_name, "_Test Customer")
|
self.login_as_customer()
|
||||||
self.assertEqual(quotation.contact_email, frappe.session.user)
|
quotation = validate_quotation()
|
||||||
|
|
||||||
return quotation
|
return quotation
|
||||||
|
|
||||||
@ -254,10 +260,9 @@ class TestShoppingCart(unittest.TestCase):
|
|||||||
self.create_user_if_not_exists("test_cart_user@example.com")
|
self.create_user_if_not_exists("test_cart_user@example.com")
|
||||||
frappe.set_user("test_cart_user@example.com")
|
frappe.set_user("test_cart_user@example.com")
|
||||||
|
|
||||||
def login_as_customer(self):
|
def login_as_customer(self, email="test_contact_customer@example.com", name="_Test Contact For _Test Customer"):
|
||||||
self.create_user_if_not_exists("test_contact_customer@example.com",
|
self.create_user_if_not_exists(email, name)
|
||||||
"_Test Contact For _Test Customer")
|
frappe.set_user(email)
|
||||||
frappe.set_user("test_contact_customer@example.com")
|
|
||||||
|
|
||||||
def clear_existing_quotations(self):
|
def clear_existing_quotations(self):
|
||||||
quotations = frappe.get_all("Quotation", filters={
|
quotations = frappe.get_all("Quotation", filters={
|
||||||
|
@ -66,6 +66,20 @@ def create_test_contact_and_address():
|
|||||||
contact.add_phone("+91 0000000000", is_primary_phone=True)
|
contact.add_phone("+91 0000000000", is_primary_phone=True)
|
||||||
contact.insert()
|
contact.insert()
|
||||||
|
|
||||||
|
contact_two = frappe.get_doc({
|
||||||
|
"doctype": 'Contact',
|
||||||
|
"first_name": "_Test Contact 2 for _Test Customer",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"link_doctype": "Customer",
|
||||||
|
"link_name": "_Test Customer"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
contact_two.add_email("test_contact_two_customer@example.com", is_primary=True)
|
||||||
|
contact_two.add_phone("+92 0000000000", is_primary_phone=True)
|
||||||
|
contact_two.insert()
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def change_settings(doctype, settings_dict):
|
def change_settings(doctype, settings_dict):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user