mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
Merge remote-tracking branch 'upstream/develop' into remove-india
This commit is contained in:
@@ -1 +1 @@
|
||||
global_test_dependencies = ['User', 'Company', 'Item']
|
||||
global_test_dependencies = ["User", "Company", "Item"]
|
||||
|
||||
122
erpnext/tests/exotel_test_data.py
Normal file
122
erpnext/tests/exotel_test_data.py
Normal file
@@ -0,0 +1,122 @@
|
||||
import frappe
|
||||
|
||||
call_initiation_data = frappe._dict(
|
||||
{
|
||||
"CallSid": "23c162077629863c1a2d7f29263a162m",
|
||||
"CallFrom": "09999999991",
|
||||
"CallTo": "09999999980",
|
||||
"Direction": "incoming",
|
||||
"Created": "Wed, 23 Feb 2022 12:31:59",
|
||||
"From": "09999999991",
|
||||
"To": "09999999988",
|
||||
"CurrentTime": "2022-02-23 12:32:02",
|
||||
"DialWhomNumber": "09999999999",
|
||||
"Status": "busy",
|
||||
"EventType": "Dial",
|
||||
"AgentEmail": "test_employee_exotel@company.com",
|
||||
}
|
||||
)
|
||||
|
||||
call_end_data = frappe._dict(
|
||||
{
|
||||
"CallSid": "23c162077629863c1a2d7f29263a162m",
|
||||
"CallFrom": "09999999991",
|
||||
"CallTo": "09999999980",
|
||||
"Direction": "incoming",
|
||||
"ForwardedFrom": "null",
|
||||
"Created": "Wed, 23 Feb 2022 12:31:59",
|
||||
"DialCallDuration": "17",
|
||||
"RecordingUrl": "https://s3-ap-southeast-1.amazonaws.com/random.mp3",
|
||||
"StartTime": "2022-02-23 12:31:58",
|
||||
"EndTime": "1970-01-01 05:30:00",
|
||||
"DialCallStatus": "completed",
|
||||
"CallType": "completed",
|
||||
"DialWhomNumber": "09999999999",
|
||||
"ProcessStatus": "null",
|
||||
"flow_id": "228040",
|
||||
"tenant_id": "67291",
|
||||
"From": "09999999991",
|
||||
"To": "09999999988",
|
||||
"RecordingAvailableBy": "Wed, 23 Feb 2022 12:37:25",
|
||||
"CurrentTime": "2022-02-23 12:32:25",
|
||||
"OutgoingPhoneNumber": "09999999988",
|
||||
"Legs": [
|
||||
{
|
||||
"Number": "09999999999",
|
||||
"Type": "single",
|
||||
"OnCallDuration": "10",
|
||||
"CallerId": "09999999980",
|
||||
"CauseCode": "NORMAL_CLEARING",
|
||||
"Cause": "16",
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
call_disconnected_data = frappe._dict(
|
||||
{
|
||||
"CallSid": "d96421addce69e24bdc7ce5880d1162l",
|
||||
"CallFrom": "09999999991",
|
||||
"CallTo": "09999999980",
|
||||
"Direction": "incoming",
|
||||
"ForwardedFrom": "null",
|
||||
"Created": "Mon, 21 Feb 2022 15:58:12",
|
||||
"DialCallDuration": "0",
|
||||
"StartTime": "2022-02-21 15:58:12",
|
||||
"EndTime": "1970-01-01 05:30:00",
|
||||
"DialCallStatus": "canceled",
|
||||
"CallType": "client-hangup",
|
||||
"DialWhomNumber": "09999999999",
|
||||
"ProcessStatus": "null",
|
||||
"flow_id": "228040",
|
||||
"tenant_id": "67291",
|
||||
"From": "09999999991",
|
||||
"To": "09999999988",
|
||||
"CurrentTime": "2022-02-21 15:58:47",
|
||||
"OutgoingPhoneNumber": "09999999988",
|
||||
"Legs": [
|
||||
{
|
||||
"Number": "09999999999",
|
||||
"Type": "single",
|
||||
"OnCallDuration": "0",
|
||||
"CallerId": "09999999980",
|
||||
"CauseCode": "RING_TIMEOUT",
|
||||
"Cause": "1003",
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
call_not_answered_data = frappe._dict(
|
||||
{
|
||||
"CallSid": "fdb67a2b4b2d057b610a52ef43f81622",
|
||||
"CallFrom": "09999999991",
|
||||
"CallTo": "09999999980",
|
||||
"Direction": "incoming",
|
||||
"ForwardedFrom": "null",
|
||||
"Created": "Mon, 21 Feb 2022 15:47:02",
|
||||
"DialCallDuration": "0",
|
||||
"StartTime": "2022-02-21 15:47:02",
|
||||
"EndTime": "1970-01-01 05:30:00",
|
||||
"DialCallStatus": "no-answer",
|
||||
"CallType": "incomplete",
|
||||
"DialWhomNumber": "09999999999",
|
||||
"ProcessStatus": "null",
|
||||
"flow_id": "228040",
|
||||
"tenant_id": "67291",
|
||||
"From": "09999999991",
|
||||
"To": "09999999988",
|
||||
"CurrentTime": "2022-02-21 15:47:40",
|
||||
"OutgoingPhoneNumber": "09999999988",
|
||||
"Legs": [
|
||||
{
|
||||
"Number": "09999999999",
|
||||
"Type": "single",
|
||||
"OnCallDuration": "0",
|
||||
"CallerId": "09999999980",
|
||||
"CauseCode": "RING_TIMEOUT",
|
||||
"Cause": "1003",
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
@@ -1,4 +0,0 @@
|
||||
Disease
|
||||
Crop
|
||||
Crop Cycle
|
||||
Soil Texture
|
||||
9
erpnext/tests/test_activation.py
Normal file
9
erpnext/tests/test_activation.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
|
||||
from erpnext.utilities.activation import get_level
|
||||
|
||||
|
||||
class TestActivation(FrappeTestCase):
|
||||
def test_activation(self):
|
||||
levels = get_level()
|
||||
self.assertTrue(levels)
|
||||
68
erpnext/tests/test_exotel.py
Normal file
68
erpnext/tests/test_exotel.py
Normal file
@@ -0,0 +1,68 @@
|
||||
import frappe
|
||||
from frappe.contacts.doctype.contact.test_contact import create_contact
|
||||
from frappe.tests.test_api import FrappeAPITestCase
|
||||
|
||||
from erpnext.hr.doctype.employee.test_employee import make_employee
|
||||
|
||||
|
||||
class TestExotel(FrappeAPITestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.CURRENT_DB_CONNECTION = frappe.db
|
||||
cls.test_employee_name = make_employee(
|
||||
user="test_employee_exotel@company.com", cell_number="9999999999"
|
||||
)
|
||||
frappe.db.set_value("Exotel Settings", "Exotel Settings", "enabled", 1)
|
||||
phones = [{"phone": "+91 9999999991", "is_primary_phone": 0, "is_primary_mobile_no": 1}]
|
||||
create_contact(name="Test Contact", salutation="Mr", phones=phones)
|
||||
frappe.db.commit()
|
||||
|
||||
def test_for_successful_call(self):
|
||||
from .exotel_test_data import call_end_data, call_initiation_data
|
||||
|
||||
api_method = "handle_incoming_call"
|
||||
end_call_api_method = "handle_end_call"
|
||||
|
||||
self.emulate_api_call_from_exotel(api_method, call_initiation_data)
|
||||
self.emulate_api_call_from_exotel(end_call_api_method, call_end_data)
|
||||
call_log = frappe.get_doc("Call Log", call_initiation_data.CallSid)
|
||||
|
||||
self.assertEqual(call_log.get("from"), call_initiation_data.CallFrom)
|
||||
self.assertEqual(call_log.get("to"), call_initiation_data.DialWhomNumber)
|
||||
self.assertEqual(call_log.get("call_received_by"), self.test_employee_name)
|
||||
self.assertEqual(call_log.get("status"), "Completed")
|
||||
|
||||
def test_for_disconnected_call(self):
|
||||
from .exotel_test_data import call_disconnected_data
|
||||
|
||||
api_method = "handle_missed_call"
|
||||
self.emulate_api_call_from_exotel(api_method, call_disconnected_data)
|
||||
call_log = frappe.get_doc("Call Log", call_disconnected_data.CallSid)
|
||||
self.assertEqual(call_log.get("from"), call_disconnected_data.CallFrom)
|
||||
self.assertEqual(call_log.get("to"), call_disconnected_data.DialWhomNumber)
|
||||
self.assertEqual(call_log.get("call_received_by"), self.test_employee_name)
|
||||
self.assertEqual(call_log.get("status"), "Canceled")
|
||||
|
||||
def test_for_call_not_answered(self):
|
||||
from .exotel_test_data import call_not_answered_data
|
||||
|
||||
api_method = "handle_missed_call"
|
||||
self.emulate_api_call_from_exotel(api_method, call_not_answered_data)
|
||||
call_log = frappe.get_doc("Call Log", call_not_answered_data.CallSid)
|
||||
self.assertEqual(call_log.get("from"), call_not_answered_data.CallFrom)
|
||||
self.assertEqual(call_log.get("to"), call_not_answered_data.DialWhomNumber)
|
||||
self.assertEqual(call_log.get("call_received_by"), self.test_employee_name)
|
||||
self.assertEqual(call_log.get("status"), "No Answer")
|
||||
|
||||
def emulate_api_call_from_exotel(self, api_method, data):
|
||||
self.post(
|
||||
f"/api/method/erpnext.erpnext_integrations.exotel_integration.{api_method}",
|
||||
data=frappe.as_json(data),
|
||||
content_type="application/json",
|
||||
)
|
||||
# restart db connection to get latest data
|
||||
frappe.connect()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
frappe.db = cls.CURRENT_DB_CONNECTION
|
||||
@@ -4,7 +4,8 @@ import frappe
|
||||
|
||||
from erpnext import encode_company_abbr
|
||||
|
||||
test_records = frappe.get_test_records('Company')
|
||||
test_records = frappe.get_test_records("Company")
|
||||
|
||||
|
||||
class TestInit(unittest.TestCase):
|
||||
def test_encode_company_abbr(self):
|
||||
@@ -12,23 +13,40 @@ class TestInit(unittest.TestCase):
|
||||
abbr = "NFECT"
|
||||
|
||||
names = [
|
||||
"Warehouse Name", "ERPNext Foundation India", "Gold - Member - {a}".format(a=abbr),
|
||||
" - {a}".format(a=abbr), "ERPNext - Foundation - India",
|
||||
"Warehouse Name",
|
||||
"ERPNext Foundation India",
|
||||
"Gold - Member - {a}".format(a=abbr),
|
||||
" - {a}".format(a=abbr),
|
||||
"ERPNext - Foundation - India",
|
||||
"ERPNext Foundation India - {a}".format(a=abbr),
|
||||
"No-Space-{a}".format(a=abbr), "- Warehouse"
|
||||
"No-Space-{a}".format(a=abbr),
|
||||
"- Warehouse",
|
||||
]
|
||||
|
||||
expected_names = [
|
||||
"Warehouse Name - {a}".format(a=abbr), "ERPNext Foundation India - {a}".format(a=abbr),
|
||||
"Gold - Member - {a}".format(a=abbr), " - {a}".format(a=abbr),
|
||||
"Warehouse Name - {a}".format(a=abbr),
|
||||
"ERPNext Foundation India - {a}".format(a=abbr),
|
||||
"Gold - Member - {a}".format(a=abbr),
|
||||
" - {a}".format(a=abbr),
|
||||
"ERPNext - Foundation - India - {a}".format(a=abbr),
|
||||
"ERPNext Foundation India - {a}".format(a=abbr), "No-Space-{a} - {a}".format(a=abbr),
|
||||
"- Warehouse - {a}".format(a=abbr)
|
||||
"ERPNext Foundation India - {a}".format(a=abbr),
|
||||
"No-Space-{a} - {a}".format(a=abbr),
|
||||
"- Warehouse - {a}".format(a=abbr),
|
||||
]
|
||||
|
||||
for i in range(len(names)):
|
||||
enc_name = encode_company_abbr(names[i], abbr=abbr)
|
||||
self.assertTrue(
|
||||
enc_name == expected_names[i],
|
||||
"{enc} is not same as {exp}".format(enc=enc_name, exp=expected_names[i])
|
||||
"{enc} is not same as {exp}".format(enc=enc_name, exp=expected_names[i]),
|
||||
)
|
||||
|
||||
def test_translation_files(self):
|
||||
from frappe.tests.test_translate import verify_translation_files
|
||||
|
||||
verify_translation_files("erpnext")
|
||||
|
||||
def test_patches(self):
|
||||
from frappe.tests.test_patches import check_patch_files
|
||||
|
||||
check_patch_files("erpnext")
|
||||
|
||||
@@ -10,9 +10,9 @@ from frappe.desk import notifications
|
||||
|
||||
class TestNotifications(unittest.TestCase):
|
||||
def test_get_notifications_for_targets(self):
|
||||
'''
|
||||
Test notification config entries for targets as percentages
|
||||
'''
|
||||
"""
|
||||
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)
|
||||
@@ -21,7 +21,7 @@ class TestNotifications(unittest.TestCase):
|
||||
config = notifications.get_notification_config()
|
||||
doc_target_percents = notifications.get_notifications_for_targets(config, {})
|
||||
|
||||
self.assertEqual(doc_target_percents['Company'][company.name], 10)
|
||||
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)
|
||||
@@ -29,4 +29,4 @@ class TestNotifications(unittest.TestCase):
|
||||
config = notifications.get_notification_config()
|
||||
doc_target_percents = notifications.get_notifications_for_targets(config, {})
|
||||
|
||||
self.assertEqual(doc_target_percents['Company'][company.name], 0)
|
||||
self.assertEqual(doc_target_percents["Company"][company.name], 0)
|
||||
|
||||
@@ -14,11 +14,11 @@ from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||
class TestPointOfSale(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
frappe.db.savepoint('before_test_point_of_sale')
|
||||
frappe.db.savepoint("before_test_point_of_sale")
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls) -> None:
|
||||
frappe.db.rollback(save_point='before_test_point_of_sale')
|
||||
frappe.db.rollback(save_point="before_test_point_of_sale")
|
||||
|
||||
def test_item_search(self):
|
||||
"""
|
||||
|
||||
@@ -7,12 +7,13 @@ import erpnext
|
||||
|
||||
@erpnext.allow_regional
|
||||
def test_method():
|
||||
return 'original'
|
||||
return "original"
|
||||
|
||||
|
||||
class TestInit(unittest.TestCase):
|
||||
def test_regional_overrides(self):
|
||||
frappe.flags.country = 'Maldives'
|
||||
self.assertEqual(test_method(), 'original')
|
||||
frappe.flags.country = "Maldives"
|
||||
self.assertEqual(test_method(), "original")
|
||||
|
||||
frappe.flags.country = 'France'
|
||||
self.assertEqual(test_method(), 'overridden')
|
||||
frappe.flags.country = "France"
|
||||
self.assertEqual(test_method(), "overridden")
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
from frappe.contacts.address_and_contact import filter_dynamic_link_doctypes
|
||||
|
||||
|
||||
class TestSearch(unittest.TestCase):
|
||||
# Search for the word "cond", part of the word "conduire" (Lead) in french.
|
||||
def test_contact_search_in_foreign_language(self):
|
||||
try:
|
||||
frappe.local.lang = 'fr'
|
||||
output = filter_dynamic_link_doctypes("DocType", "cond", "name", 0, 20, {
|
||||
'fieldtype': 'HTML',
|
||||
'fieldname': 'contact_html'
|
||||
})
|
||||
result = [['found' for x in y if x=="Lead"] for y in output]
|
||||
self.assertTrue(['found'] in result)
|
||||
finally:
|
||||
frappe.local.lang = 'en'
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,132 +7,143 @@ from erpnext.buying.doctype.purchase_order.test_purchase_order import create_pur
|
||||
|
||||
class TestWebsite(unittest.TestCase):
|
||||
def test_permission_for_custom_doctype(self):
|
||||
create_user('Supplier 1', 'supplier1@gmail.com')
|
||||
create_user('Supplier 2', 'supplier2@gmail.com')
|
||||
create_supplier_with_contact('Supplier1', 'All Supplier Groups', 'Supplier 1', 'supplier1@gmail.com')
|
||||
create_supplier_with_contact('Supplier2', 'All Supplier Groups', 'Supplier 2', 'supplier2@gmail.com')
|
||||
po1 = create_purchase_order(supplier='Supplier1')
|
||||
po2 = create_purchase_order(supplier='Supplier2')
|
||||
create_user("Supplier 1", "supplier1@gmail.com")
|
||||
create_user("Supplier 2", "supplier2@gmail.com")
|
||||
create_supplier_with_contact(
|
||||
"Supplier1", "All Supplier Groups", "Supplier 1", "supplier1@gmail.com"
|
||||
)
|
||||
create_supplier_with_contact(
|
||||
"Supplier2", "All Supplier Groups", "Supplier 2", "supplier2@gmail.com"
|
||||
)
|
||||
po1 = create_purchase_order(supplier="Supplier1")
|
||||
po2 = create_purchase_order(supplier="Supplier2")
|
||||
|
||||
create_custom_doctype()
|
||||
create_webform()
|
||||
create_order_assignment(supplier='Supplier1', po = po1.name)
|
||||
create_order_assignment(supplier='Supplier2', po = po2.name)
|
||||
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()])
|
||||
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'])
|
||||
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'])
|
||||
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")
|
||||
|
||||
|
||||
def get_data():
|
||||
webform_list_contexts = frappe.get_hooks('webform_list_context')
|
||||
webform_list_contexts = frappe.get_hooks("webform_list_context")
|
||||
if webform_list_contexts:
|
||||
context = frappe._dict(frappe.get_attr(webform_list_contexts[0])('Buying') or {})
|
||||
kwargs = dict(doctype='Order Assignment', order_by = 'modified desc')
|
||||
context = frappe._dict(frappe.get_attr(webform_list_contexts[0])("Buying") or {})
|
||||
kwargs = dict(doctype="Order Assignment", order_by="modified desc")
|
||||
return context.get_list(**kwargs)
|
||||
|
||||
|
||||
def create_user(name, email):
|
||||
frappe.get_doc({
|
||||
'doctype': 'User',
|
||||
'send_welcome_email': 0,
|
||||
'user_type': 'Website User',
|
||||
'first_name': name,
|
||||
'email': email,
|
||||
'roles': [{"doctype": "Has Role", "role": "Supplier"}]
|
||||
}).insert(ignore_if_duplicate = True)
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "User",
|
||||
"send_welcome_email": 0,
|
||||
"user_type": "Website User",
|
||||
"first_name": name,
|
||||
"email": email,
|
||||
"roles": [{"doctype": "Has Role", "role": "Supplier"}],
|
||||
}
|
||||
).insert(ignore_if_duplicate=True)
|
||||
|
||||
|
||||
def create_supplier_with_contact(name, group, contact_name, contact_email):
|
||||
supplier = frappe.get_doc({
|
||||
'doctype': 'Supplier',
|
||||
'supplier_name': name,
|
||||
'supplier_group': group
|
||||
}).insert(ignore_if_duplicate = True)
|
||||
supplier = frappe.get_doc(
|
||||
{"doctype": "Supplier", "supplier_name": name, "supplier_group": group}
|
||||
).insert(ignore_if_duplicate=True)
|
||||
|
||||
if not frappe.db.exists('Contact', contact_name+'-1-'+name):
|
||||
if not frappe.db.exists("Contact", contact_name + "-1-" + name):
|
||||
new_contact = frappe.new_doc("Contact")
|
||||
new_contact.first_name = contact_name
|
||||
new_contact.is_primary_contact = True,
|
||||
new_contact.append('links', {
|
||||
"link_doctype": "Supplier",
|
||||
"link_name": supplier.name
|
||||
})
|
||||
new_contact.append('email_ids', {
|
||||
"email_id": contact_email,
|
||||
"is_primary": 1
|
||||
})
|
||||
new_contact.is_primary_contact = (True,)
|
||||
new_contact.append("links", {"link_doctype": "Supplier", "link_name": supplier.name})
|
||||
new_contact.append("email_ids", {"email_id": contact_email, "is_primary": 1})
|
||||
|
||||
new_contact.insert(ignore_mandatory=True)
|
||||
|
||||
|
||||
def create_custom_doctype():
|
||||
frappe.get_doc({
|
||||
'doctype': 'DocType',
|
||||
'name': 'Order Assignment',
|
||||
'module': 'Buying',
|
||||
'custom': 1,
|
||||
'autoname': 'field:po',
|
||||
'fields': [
|
||||
{'label': 'PO', 'fieldname': 'po', 'fieldtype': 'Link', 'options': 'Purchase Order'},
|
||||
{'label': 'Supplier', 'fieldname': 'supplier', 'fieldtype': 'Data', "fetch_from": "po.supplier"}
|
||||
],
|
||||
'permissions': [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"read": 1,
|
||||
"role": "Supplier"
|
||||
}
|
||||
]
|
||||
}).insert(ignore_if_duplicate = True)
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Order Assignment",
|
||||
"module": "Buying",
|
||||
"custom": 1,
|
||||
"autoname": "field:po",
|
||||
"fields": [
|
||||
{"label": "PO", "fieldname": "po", "fieldtype": "Link", "options": "Purchase Order"},
|
||||
{
|
||||
"label": "Supplier",
|
||||
"fieldname": "supplier",
|
||||
"fieldtype": "Data",
|
||||
"fetch_from": "po.supplier",
|
||||
},
|
||||
],
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1,
|
||||
},
|
||||
{"read": 1, "role": "Supplier"},
|
||||
],
|
||||
}
|
||||
).insert(ignore_if_duplicate=True)
|
||||
|
||||
|
||||
def create_webform():
|
||||
frappe.get_doc({
|
||||
'doctype': 'Web Form',
|
||||
'module': 'Buying',
|
||||
'title': 'SO Schedule',
|
||||
'route': 'so-schedule',
|
||||
'doc_type': 'Order Assignment',
|
||||
'web_form_fields': [
|
||||
{
|
||||
'doctype': 'Web Form Field',
|
||||
'fieldname': 'po',
|
||||
'fieldtype': 'Link',
|
||||
'options': 'Purchase Order',
|
||||
'label': 'PO'
|
||||
},
|
||||
{
|
||||
'doctype': 'Web Form Field',
|
||||
'fieldname': 'supplier',
|
||||
'fieldtype': 'Data',
|
||||
'label': 'Supplier'
|
||||
}
|
||||
]
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Web Form",
|
||||
"module": "Buying",
|
||||
"title": "SO Schedule",
|
||||
"route": "so-schedule",
|
||||
"doc_type": "Order Assignment",
|
||||
"web_form_fields": [
|
||||
{
|
||||
"doctype": "Web Form Field",
|
||||
"fieldname": "po",
|
||||
"fieldtype": "Link",
|
||||
"options": "Purchase Order",
|
||||
"label": "PO",
|
||||
},
|
||||
{
|
||||
"doctype": "Web Form Field",
|
||||
"fieldname": "supplier",
|
||||
"fieldtype": "Data",
|
||||
"label": "Supplier",
|
||||
},
|
||||
],
|
||||
}
|
||||
).insert(ignore_if_duplicate=True)
|
||||
|
||||
}).insert(ignore_if_duplicate = True)
|
||||
|
||||
def create_order_assignment(supplier, po):
|
||||
frappe.get_doc({
|
||||
'doctype': 'Order Assignment',
|
||||
'po': po,
|
||||
'supplier': supplier,
|
||||
}).insert(ignore_if_duplicate = True)
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Order Assignment",
|
||||
"po": po,
|
||||
"supplier": supplier,
|
||||
}
|
||||
).insert(ignore_if_duplicate=True)
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
import os
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
import requests
|
||||
|
||||
from erpnext.erpnext_integrations.connectors.woocommerce_connection import order
|
||||
|
||||
|
||||
class TestWoocommerce(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
||||
woo_settings = frappe.get_doc("Woocommerce Settings")
|
||||
if not woo_settings.secret:
|
||||
woo_settings.secret = "ec434676aa1de0e502389f515c38f89f653119ab35e9117c7a79e576"
|
||||
woo_settings.woocommerce_server_url = "https://woocommerce.mntechnique.com/"
|
||||
woo_settings.api_consumer_key = "ck_fd43ff5756a6abafd95fadb6677100ce95a758a1"
|
||||
woo_settings.api_consumer_secret = "cs_94360a1ad7bef7fa420a40cf284f7b3e0788454e"
|
||||
woo_settings.enable_sync = 1
|
||||
woo_settings.company = "_Test Company"
|
||||
woo_settings.tax_account = "Sales Expenses - _TC"
|
||||
woo_settings.f_n_f_account = "Expenses - _TC"
|
||||
woo_settings.creation_user = "Administrator"
|
||||
woo_settings.save(ignore_permissions=True)
|
||||
|
||||
def test_sales_order_for_woocommerce(self):
|
||||
frappe.flags.woocomm_test_order_data = {"id":75,"parent_id":0,"number":"74","order_key":"wc_order_5aa1281c2dacb","created_via":"checkout","version":"3.3.3","status":"processing","currency":"INR","date_created":"2018-03-08T12:10:04","date_created_gmt":"2018-03-08T12:10:04","date_modified":"2018-03-08T12:10:04","date_modified_gmt":"2018-03-08T12:10:04","discount_total":"0.00","discount_tax":"0.00","shipping_total":"150.00","shipping_tax":"0.00","cart_tax":"0.00","total":"649.00","total_tax":"0.00","prices_include_tax":False,"customer_id":12,"customer_ip_address":"103.54.99.5","customer_user_agent":"mozilla\\/5.0 (x11; linux x86_64) applewebkit\\/537.36 (khtml, like gecko) chrome\\/64.0.3282.186 safari\\/537.36","customer_note":"","billing":{"first_name":"Tony","last_name":"Stark","company":"_Test Company","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN","email":"tony@gmail.com","phone":"123457890"},"shipping":{"first_name":"Tony","last_name":"Stark","company":"","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN"},"payment_method":"cod","payment_method_title":"Cash on delivery","transaction_id":"","date_paid":"","date_paid_gmt":"","date_completed":"","date_completed_gmt":"","cart_hash":"8e76b020d5790066496f244860c4703f","meta_data":[],"line_items":[{"id":80,"name":"Marvel","product_id":56,"variation_id":0,"quantity":1,"tax_class":"","subtotal":"499.00","subtotal_tax":"0.00","total":"499.00","total_tax":"0.00","taxes":[],"meta_data":[],"sku":"","price":499}],"tax_lines":[],"shipping_lines":[{"id":81,"method_title":"Flat rate","method_id":"flat_rate:1","total":"150.00","total_tax":"0.00","taxes":[],"meta_data":[{"id":623,"key":"Items","value":"Marvel × 1"}]}],"fee_lines":[],"coupon_lines":[],"refunds":[]}
|
||||
order()
|
||||
|
||||
self.assertTrue(frappe.get_value("Customer",{"woocommerce_email":"tony@gmail.com"}))
|
||||
self.assertTrue(frappe.get_value("Item",{"woocommerce_id": 56}))
|
||||
self.assertTrue(frappe.get_value("Sales Order",{"woocommerce_id":75}))
|
||||
frappe.flags.woocomm_test_order_data = {}
|
||||
|
||||
def emulate_request():
|
||||
# Emulate Woocommerce Request
|
||||
headers = {
|
||||
"X-Wc-Webhook-Event":"created",
|
||||
"X-Wc-Webhook-Signature":"h1SjzQMPwd68MF5bficeFq20/RkQeRLsb9AVCUz/rLs="
|
||||
}
|
||||
# Emulate Request Data
|
||||
data = """{"id":74,"parent_id":0,"number":"74","order_key":"wc_order_5aa1281c2dacb","created_via":"checkout","version":"3.3.3","status":"processing","currency":"INR","date_created":"2018-03-08T12:10:04","date_created_gmt":"2018-03-08T12:10:04","date_modified":"2018-03-08T12:10:04","date_modified_gmt":"2018-03-08T12:10:04","discount_total":"0.00","discount_tax":"0.00","shipping_total":"150.00","shipping_tax":"0.00","cart_tax":"0.00","total":"649.00","total_tax":"0.00","prices_include_tax":false,"customer_id":12,"customer_ip_address":"103.54.99.5","customer_user_agent":"mozilla\\/5.0 (x11; linux x86_64) applewebkit\\/537.36 (khtml, like gecko) chrome\\/64.0.3282.186 safari\\/537.36","customer_note":"","billing":{"first_name":"Tony","last_name":"Stark","company":"Woocommerce","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN","email":"tony@gmail.com","phone":"123457890"},"shipping":{"first_name":"Tony","last_name":"Stark","company":"","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN"},"payment_method":"cod","payment_method_title":"Cash on delivery","transaction_id":"","date_paid":null,"date_paid_gmt":null,"date_completed":null,"date_completed_gmt":null,"cart_hash":"8e76b020d5790066496f244860c4703f","meta_data":[],"line_items":[{"id":80,"name":"Marvel","product_id":56,"variation_id":0,"quantity":1,"tax_class":"","subtotal":"499.00","subtotal_tax":"0.00","total":"499.00","total_tax":"0.00","taxes":[],"meta_data":[],"sku":"","price":499}],"tax_lines":[],"shipping_lines":[{"id":81,"method_title":"Flat rate","method_id":"flat_rate:1","total":"150.00","total_tax":"0.00","taxes":[],"meta_data":[{"id":623,"key":"Items","value":"Marvel × 1"}]}],"fee_lines":[],"coupon_lines":[],"refunds":[]}"""
|
||||
|
||||
# Build URL
|
||||
port = frappe.get_site_config().webserver_port or '8000'
|
||||
|
||||
if os.environ.get('CI'):
|
||||
host = 'localhost'
|
||||
else:
|
||||
host = frappe.local.site
|
||||
|
||||
url = "http://{site}:{port}/api/method/erpnext.erpnext_integrations.connectors.woocommerce_connection.order".format(site=host, port=port)
|
||||
|
||||
r = requests.post(url=url, headers=headers, data=data)
|
||||
|
||||
time.sleep(5)
|
||||
return r
|
||||
@@ -1,30 +1,58 @@
|
||||
""" dumb test to check all function calls on known form loads """
|
||||
|
||||
import unittest
|
||||
""" smoak tests to check basic functionality calls on known form loads."""
|
||||
|
||||
import frappe
|
||||
from frappe.desk.form.load import getdoc
|
||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
||||
from frappe.www.printview import get_html_and_style
|
||||
|
||||
|
||||
class TestFormLoads(unittest.TestCase):
|
||||
|
||||
class TestFormLoads(FrappeTestCase):
|
||||
@change_settings("Print Settings", {"allow_print_for_cancelled": 1})
|
||||
def test_load(self):
|
||||
erpnext_modules = frappe.get_all("Module Def", filters={"app_name": "erpnext"}, pluck="name")
|
||||
doctypes = frappe.get_all("DocType", {"istable": 0, "issingle": 0, "is_virtual": 0, "module": ("in", erpnext_modules)}, pluck="name")
|
||||
doctypes = frappe.get_all(
|
||||
"DocType",
|
||||
{"istable": 0, "issingle": 0, "is_virtual": 0, "module": ("in", erpnext_modules)},
|
||||
pluck="name",
|
||||
)
|
||||
|
||||
for doctype in doctypes:
|
||||
last_doc = frappe.db.get_value(doctype, {}, "name", order_by="modified desc")
|
||||
if not last_doc:
|
||||
continue
|
||||
with self.subTest(msg=f"Loading {doctype} - {last_doc}", doctype=doctype, last_doc=last_doc):
|
||||
try:
|
||||
# reset previous response
|
||||
frappe.response = frappe._dict({"docs":[]})
|
||||
frappe.response.docinfo = None
|
||||
self.assertFormLoad(doctype, last_doc)
|
||||
self.assertDocPrint(doctype, last_doc)
|
||||
|
||||
getdoc(doctype, last_doc)
|
||||
except Exception as e:
|
||||
self.fail(f"Failed to load {doctype} - {last_doc}: {e}")
|
||||
def assertFormLoad(self, doctype, docname):
|
||||
# reset previous response
|
||||
frappe.response = frappe._dict({"docs": []})
|
||||
frappe.response.docinfo = None
|
||||
|
||||
self.assertTrue(frappe.response.docs, msg=f"expected document in reponse, found: {frappe.response.docs}")
|
||||
self.assertTrue(frappe.response.docinfo, msg=f"expected docinfo in reponse, found: {frappe.response.docinfo}")
|
||||
try:
|
||||
getdoc(doctype, docname)
|
||||
except Exception as e:
|
||||
self.fail(f"Failed to load {doctype}-{docname}: {e}")
|
||||
|
||||
self.assertTrue(
|
||||
frappe.response.docs, msg=f"expected document in reponse, found: {frappe.response.docs}"
|
||||
)
|
||||
self.assertTrue(
|
||||
frappe.response.docinfo, msg=f"expected docinfo in reponse, found: {frappe.response.docinfo}"
|
||||
)
|
||||
|
||||
def assertDocPrint(self, doctype, docname):
|
||||
doc = frappe.get_doc(doctype, docname)
|
||||
doc.set("__onload", frappe._dict())
|
||||
doc.run_method("onload")
|
||||
|
||||
messages_before = frappe.get_message_log()
|
||||
ret = get_html_and_style(doc=doc.as_json(), print_format="Standard", no_letterhead=1)
|
||||
messages_after = frappe.get_message_log()
|
||||
|
||||
if len(messages_after) > len(messages_before):
|
||||
new_messages = messages_after[len(messages_before) :]
|
||||
self.fail("Print view showing error/warnings: \n" + "\n".join(str(msg) for msg in new_messages))
|
||||
|
||||
# html should exist
|
||||
self.assertTrue(bool(ret["html"]))
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
erpnext/agriculture/doctype/land_unit/test_land_unit.js
|
||||
erpnext/agriculture/doctype/fertilizer/test_fertilizer.js
|
||||
erpnext/agriculture/doctype/water_analysis/test_water_analysis.js
|
||||
erpnext/agriculture/doctype/disease/test_disease.js
|
||||
erpnext/agriculture/doctype/soil_texture/test_soil_texture.js
|
||||
erpnext/agriculture/doctype/crop/test_crop.js
|
||||
erpnext/agriculture/doctype/crop_cycle/test_crop_cycle.js
|
||||
@@ -1,258 +0,0 @@
|
||||
$.extend(frappe.test_data, {
|
||||
// "Fiscal Year": {
|
||||
// "2017-18": [
|
||||
// {"year": "2017-18"},
|
||||
// {"year_start_date": "2017-04-01"},
|
||||
// {"year_end_date": "2018-03-31"},
|
||||
// ]
|
||||
// },
|
||||
"Customer": {
|
||||
"Test Customer 1": [
|
||||
{customer_name: "Test Customer 1"}
|
||||
],
|
||||
"Test Customer 2": [
|
||||
{customer_name: "Test Customer 2"}
|
||||
],
|
||||
"Test Customer 3": [
|
||||
{customer_name: "Test Customer 3"}
|
||||
],
|
||||
},
|
||||
"Item": {
|
||||
"Test Product 1": [
|
||||
{item_code: "Test Product 1"},
|
||||
{item_group: "Products"},
|
||||
{is_stock_item: 1},
|
||||
{standard_rate: 100},
|
||||
{opening_stock: 100},
|
||||
],
|
||||
"Test Product 2": [
|
||||
{item_code: "Test Product 2"},
|
||||
{item_group: "Products"},
|
||||
{is_stock_item: 1},
|
||||
{standard_rate: 150},
|
||||
{opening_stock: 200},
|
||||
],
|
||||
"Test Product 3": [
|
||||
{item_code: "Test Product 3"},
|
||||
{item_group: "Products"},
|
||||
{is_stock_item: 1},
|
||||
{standard_rate: 250},
|
||||
{opening_stock: 100},
|
||||
{stock_uom:'Kg'}
|
||||
],
|
||||
"Test Service 1": [
|
||||
{item_code: "Test Service 1"},
|
||||
{item_group: "Services"},
|
||||
{is_stock_item: 0},
|
||||
{standard_rate: 200}
|
||||
],
|
||||
"Test Service 2": [
|
||||
{item_code: "Test Service 2"},
|
||||
{item_group: "Services"},
|
||||
{is_stock_item: 0},
|
||||
{standard_rate: 300}
|
||||
]
|
||||
},
|
||||
"Lead": {
|
||||
"LEAD-00001": [
|
||||
{lead_name: "Test Lead 1"}
|
||||
],
|
||||
"LEAD-00002": [
|
||||
{lead_name: "Test Lead 2"}
|
||||
],
|
||||
"LEAD-00003": [
|
||||
{lead_name: "Test Lead 3"}
|
||||
]
|
||||
},
|
||||
"Address": {
|
||||
"Test1-Billing": [
|
||||
{address_title:"Test1"},
|
||||
{address_type: "Billing"},
|
||||
{address_line1: "Billing Street 1"},
|
||||
{city: "Billing City 1"},
|
||||
{links: [
|
||||
[
|
||||
{link_doctype: "Customer"},
|
||||
{link_name: "Test Customer 1"}
|
||||
]
|
||||
]}
|
||||
],
|
||||
"Test1-Shipping": [
|
||||
{address_title:"Test1"},
|
||||
{address_type: "Shipping"},
|
||||
{address_line1: "Shipping Street 1"},
|
||||
{city: "Shipping City 1"},
|
||||
{links: [
|
||||
[
|
||||
{link_doctype: "Customer"},
|
||||
{link_name: "Test Customer 1"}
|
||||
]
|
||||
]}
|
||||
],
|
||||
"Test1-Warehouse": [
|
||||
{address_title:"Test1"},
|
||||
{address_type: "Warehouse"},
|
||||
{address_line1: "Warehouse Street 1"},
|
||||
{city: "Warehouse City 1"},
|
||||
{links: [
|
||||
[
|
||||
{link_doctype: "Customer"},
|
||||
{link_name: "Test Customer 1"}
|
||||
]
|
||||
]}
|
||||
],
|
||||
"Test2-Billing": [
|
||||
{address_title:"Test2"},
|
||||
{address_type: "Billing"},
|
||||
{address_line1: "Billing Street 2"},
|
||||
{city: "Billing City 2"},
|
||||
{links: [
|
||||
[
|
||||
{link_doctype: "Customer"},
|
||||
{link_name: "Test Customer 2"}
|
||||
]
|
||||
]}
|
||||
],
|
||||
"Test2-Shipping": [
|
||||
{address_title:"Test2"},
|
||||
{address_type: "Shipping"},
|
||||
{address_line1: "Shipping Street 2"},
|
||||
{city: "Shipping City 2"},
|
||||
{links: [
|
||||
[
|
||||
{link_doctype: "Customer"},
|
||||
{link_name: "Test Customer 2"}
|
||||
]
|
||||
]}
|
||||
],
|
||||
"Test2-Warehouse": [
|
||||
{address_title:"Test2"},
|
||||
{address_type: "Warehouse"},
|
||||
{address_line1: "Warehouse Street 2"},
|
||||
{city: "Warehouse City 2"},
|
||||
{links: [
|
||||
[
|
||||
{link_doctype: "Customer"},
|
||||
{link_name: "Test Customer 2"}
|
||||
]
|
||||
]}
|
||||
]
|
||||
},
|
||||
"Contact": {
|
||||
"Contact 1-Test Customer 1": [
|
||||
{first_name: "Contact 1"},
|
||||
{links: [
|
||||
[
|
||||
{link_doctype: "Customer"},
|
||||
{link_name: "Test Customer 1"}
|
||||
]
|
||||
]}
|
||||
],
|
||||
"Contact 2-Test Customer 1": [
|
||||
{first_name: "Contact 2"},
|
||||
{links: [
|
||||
[
|
||||
{link_doctype: "Customer"},
|
||||
{link_name: "Test Customer 1"}
|
||||
]
|
||||
]}
|
||||
],
|
||||
"Contact 1-Test Customer 2": [
|
||||
{first_name: "Contact 1"},
|
||||
{links: [
|
||||
[
|
||||
{link_doctype: "Customer"},
|
||||
{link_name: "Test Customer 2"}
|
||||
]
|
||||
]}
|
||||
],
|
||||
"Contact 2-Test Customer 2": [
|
||||
{first_name: "Contact 2"},
|
||||
{links: [
|
||||
[
|
||||
{link_doctype: "Customer"},
|
||||
{link_name: "Test Customer 2"}
|
||||
]
|
||||
]}
|
||||
],
|
||||
},
|
||||
"Price List": {
|
||||
"Test-Buying-USD": [
|
||||
{price_list_name: "Test-Buying-USD"},
|
||||
{currency: "USD"},
|
||||
{buying: "1"}
|
||||
],
|
||||
"Test-Buying-EUR": [
|
||||
{price_list_name: "Test-Buying-EUR"},
|
||||
{currency: "EUR"},
|
||||
{buying: "1"}
|
||||
],
|
||||
"Test-Selling-USD": [
|
||||
{price_list_name: "Test-Selling-USD"},
|
||||
{currency: "USD"},
|
||||
{selling: "1"}
|
||||
],
|
||||
"Test-Selling-EUR": [
|
||||
{price_list_name: "Test-Selling-EUR"},
|
||||
{currency: "EUR"},
|
||||
{selling: "1"}
|
||||
],
|
||||
},
|
||||
"Terms and Conditions": {
|
||||
"Test Term 1": [
|
||||
{title: "Test Term 1"}
|
||||
],
|
||||
"Test Term 2": [
|
||||
{title: "Test Term 2"}
|
||||
]
|
||||
},
|
||||
"Item Price": {
|
||||
"ITEM-PRICE-00001": [
|
||||
{item_code: 'Test Product 1'},
|
||||
{price_list: '_Test Price List'},
|
||||
{price_list_rate: 100}
|
||||
],
|
||||
"ITEM-PRICE-00002": [
|
||||
{item_code: 'Test Product 2'},
|
||||
{price_list: '_Test Price List'},
|
||||
{price_list_rate: 200}
|
||||
]
|
||||
},
|
||||
"Payment Term": {
|
||||
"_Test Payment Term": [
|
||||
{payment_term_name: '_Test Payment Term'},
|
||||
{due_date_based_on: 'Day(s) after invoice date'},
|
||||
{invoice_portion: 100},
|
||||
{credit_days: 0}
|
||||
]
|
||||
},
|
||||
"Payment Terms Template": {
|
||||
"_Test Payment Term Template UI": [
|
||||
{template_name: "_Test Payment Term Template UI"},
|
||||
{terms: [
|
||||
[
|
||||
{payment_term: '_Test Payment Term'},
|
||||
{invoice_portion: 100}
|
||||
]
|
||||
]}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// this is a script that creates all fixtures
|
||||
// called as a test
|
||||
QUnit.module('fixture');
|
||||
|
||||
QUnit.test('Make fixtures', assert => {
|
||||
// create all fixtures first
|
||||
assert.expect(0);
|
||||
let done = assert.async();
|
||||
let tasks = [];
|
||||
Object.keys(frappe.test_data).forEach(function(doctype) {
|
||||
tasks.push(function() {
|
||||
return frappe.tests.setup_doctype(doctype, frappe.test_data[doctype]);
|
||||
});
|
||||
});
|
||||
frappe.run_serially(tasks).then(() => done());
|
||||
});
|
||||
@@ -1,47 +0,0 @@
|
||||
const path = require('path');
|
||||
const path_join = path.resolve;
|
||||
const apps_path = path_join(__dirname, '..', '..', '..', '..');
|
||||
const frappe_ui_tests_path = path_join(apps_path, 'frappe', 'frappe', 'tests', 'ui');
|
||||
|
||||
const login = require(frappe_ui_tests_path + "/login.js")['Login'];
|
||||
const welcome = require(frappe_ui_tests_path + "/setup_wizard.js")['Welcome'];
|
||||
const region = require(frappe_ui_tests_path + "/setup_wizard.js")['Region'];
|
||||
const user = require(frappe_ui_tests_path + "/setup_wizard.js")['User'];
|
||||
|
||||
module.exports = {
|
||||
before: browser => {
|
||||
browser
|
||||
.url(browser.launch_url + '/login')
|
||||
.waitForElementVisible('body', 5000);
|
||||
},
|
||||
'Login': login,
|
||||
'Welcome': welcome,
|
||||
'Region': region,
|
||||
'User': user,
|
||||
'Domain': browser => {
|
||||
let slide_selector = '[data-slide-name="domain"]';
|
||||
browser
|
||||
.waitForElementVisible(slide_selector, 2000)
|
||||
.setValue('select[data-fieldname="domain"]', "Manufacturing")
|
||||
.click(slide_selector + ' .next-btn');
|
||||
},
|
||||
'Brand': browser => {
|
||||
let slide_selector = '[data-slide-name="brand"]';
|
||||
browser
|
||||
.waitForElementVisible(slide_selector, 2000)
|
||||
.setValue('input[data-fieldname="company_name"]', "Acme")
|
||||
.click(slide_selector + " .next-btn");
|
||||
},
|
||||
'Organisation': browser => {
|
||||
let slide_selector = '[data-slide-name="organisation"]';
|
||||
browser
|
||||
.waitForElementVisible(slide_selector, 2000)
|
||||
.setValue('input[data-fieldname="company_tagline"]', "Build tools for Builders")
|
||||
.setValue('input[data-fieldname="bank_account"]', "YNG")
|
||||
.click(slide_selector + " .next-btn");
|
||||
},
|
||||
|
||||
after: browser => {
|
||||
browser.end();
|
||||
},
|
||||
};
|
||||
@@ -1,110 +0,0 @@
|
||||
erpnext/tests/ui/make_fixtures.js #long
|
||||
erpnext/accounts/doctype/account/tests/test_account.js
|
||||
erpnext/accounts/doctype/account/tests/test_make_tax_account.js
|
||||
erpnext/accounts/doctype/account/tests/test_account_with_number.js
|
||||
erpnext/accounts/doctype/pricing_rule/tests/test_pricing_rule.js
|
||||
erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.js
|
||||
erpnext/accounts/doctype/purchase_taxes_and_charges_template/test_purchase_taxes_and_charges_template.js
|
||||
erpnext/accounts/doctype/shipping_rule/test_shipping_rule.js
|
||||
erpnext/crm/doctype/opportunity/test_opportunity.js
|
||||
erpnext/stock/doctype/item/tests/test_item.js
|
||||
erpnext/selling/doctype/quotation/tests/test_quotation_with_discount_on_grand_total.js
|
||||
erpnext/selling/doctype/quotation/tests/test_quotation_with_item_wise_discount.js
|
||||
erpnext/selling/doctype/quotation/tests/test_quotation_with_multi_uom.js
|
||||
erpnext/selling/doctype/quotation/tests/test_quotation_with_taxes_and_charges.js
|
||||
erpnext/selling/doctype/quotation/tests/test_quotation_with_shipping_rule.js
|
||||
erpnext/selling/doctype/quotation/tests/test_quotation.js
|
||||
erpnext/selling/doctype/sales_order/tests/test_sales_order.js
|
||||
erpnext/selling/doctype/sales_order/tests/test_sales_order_with_multiple_delivery_date.js
|
||||
erpnext/selling/doctype/sales_order/tests/test_sales_order_with_item_wise_discount.js
|
||||
erpnext/selling/doctype/sales_order/tests/test_sales_order_with_multi_uom.js
|
||||
erpnext/selling/doctype/sales_order/tests/test_sales_order_with_discount_on_grand_total.js
|
||||
erpnext/selling/doctype/sales_order/tests/test_sales_order_with_taxes_and_charges.js
|
||||
erpnext/selling/doctype/sales_order/tests/test_sales_order_with_shipping_rule.js
|
||||
erpnext/selling/doctype/sales_order/tests/test_sales_order_with_pricing_rule.js
|
||||
erpnext/manufacturing/doctype/workstation/test_workstation.js
|
||||
erpnext/manufacturing/doctype/operation/test_operation.js
|
||||
erpnext/manufacturing/doctype/bom/test_bom.js
|
||||
erpnext/projects/doctype/project/project_timesheet.js
|
||||
erpnext/hr/doctype/holiday_list/test_holiday_list.js
|
||||
erpnext/hr/doctype/branch/test_branch.js
|
||||
erpnext/hr/doctype/leave_block_list/test_leave_block_list.js
|
||||
erpnext/hr/doctype/department/test_department.js
|
||||
erpnext/hr/doctype/designation/test_designation.js
|
||||
erpnext/hr/doctype/employment_type/test_employment_type.js
|
||||
erpnext/hr/doctype/employee/test_employee.js
|
||||
erpnext/hr/doctype/employee_attendance_tool/test_employee_attendance_tool.js
|
||||
erpnext/hr/doctype/attendance/test_attendance.js
|
||||
erpnext/hr/doctype/leave_type/test_leave_type.js
|
||||
erpnext/hr/doctype/leave_control_panel/test_leave_control_panel.js
|
||||
erpnext/hr/doctype/leave_allocation/test_leave_allocation.js
|
||||
erpnext/hr/doctype/leave_application/test_leave_application.js
|
||||
erpnext/stock/doctype/warehouse/test_warehouse.js
|
||||
erpnext/manufacturing/doctype/work_order/test_work_order.js #long
|
||||
erpnext/accounts/page/pos/test_pos.js
|
||||
erpnext/selling/page/point_of_sale/tests/test_point_of_sale.js
|
||||
erpnext/selling/doctype/product_bundle/test_product_bundle.js
|
||||
erpnext/stock/doctype/delivery_note/test_delivery_note.js
|
||||
erpnext/stock/doctype/material_request/tests/test_material_request.js
|
||||
erpnext/stock/doctype/material_request/tests/test_material_request_type_material_issue.js
|
||||
erpnext/stock/doctype/material_request/tests/test_material_request_type_material_transfer.js
|
||||
erpnext/stock/doctype/material_request/tests/test_material_request_type_manufacture.js
|
||||
erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_material_issue.js
|
||||
erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_material_receipt.js
|
||||
erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_material_transfer.js
|
||||
erpnext/hr/doctype/salary_structure/test_salary_structure.js
|
||||
erpnext/hr/doctype/salary_slip/test_salary_slip.js
|
||||
erpnext/hr/doctype/job_opening/test_job_opening.js
|
||||
erpnext/hr/doctype/job_applicant/test_job_applicant.js
|
||||
erpnext/hr/doctype/job_offer/test_job_offer.js
|
||||
erpnext/hr/doctype/appraisal_template/test_appraisal_template.js
|
||||
erpnext/hr/doctype/appraisal/test_appraisal.js
|
||||
erpnext/hr/doctype/expense_claim_type/test_expense_claim_type.js
|
||||
erpnext/hr/doctype/expense_claim/test_expense_claim.js
|
||||
erpnext/hr/doctype/training_event/tests/test_training_event.js
|
||||
erpnext/hr/doctype/training_result_employee/test_training_result.js
|
||||
erpnext/hr/doctype/training_feedback/test_training_feedback.js
|
||||
erpnext/hr/doctype/loan_type/test_loan_type.js
|
||||
erpnext/hr/doctype/loan_application/test_loan_application.js
|
||||
erpnext/hr/doctype/loan/test_loan.js
|
||||
erpnext/buying/doctype/supplier/test_supplier.js
|
||||
erpnext/buying/doctype/request_for_quotation/tests/test_request_for_quotation.js
|
||||
erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation.js
|
||||
erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_taxes_and_charges.js
|
||||
erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice.js
|
||||
erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_payment.js
|
||||
erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_payment_request.js
|
||||
erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.js
|
||||
erpnext/accounts/doctype/payment_entry/tests/test_payment_against_purchase_invoice.js
|
||||
erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_item_wise_discount.js
|
||||
erpnext/buying/doctype/purchase_order/tests/test_purchase_order.js
|
||||
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_multi_uom.js
|
||||
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_get_items.js
|
||||
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_discount_on_grand_total.js
|
||||
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_item_wise_discount.js
|
||||
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_taxes_and_charges.js
|
||||
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_receipt.js
|
||||
erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.js
|
||||
erpnext/accounts/doctype/journal_entry/test_journal_entry.js
|
||||
erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.js
|
||||
erpnext/accounts/doctype/payment_entry/tests/test_payment_entry.js
|
||||
erpnext/selling/doctype/quotation/tests/test_quotation_submit_cancel_amend.js
|
||||
erpnext/stock/doctype/batch/test_batch.js
|
||||
erpnext/accounts/doctype/bank_reconciliation/test_bank_reconciliation.js
|
||||
erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_material_receipt_for_serialize_item.js
|
||||
erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_material_transfer_for_manufacture.js
|
||||
erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_subcontract.js
|
||||
erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_material_issue_with_serialize_item.js
|
||||
erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_repack.js
|
||||
erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_serialize_item.js
|
||||
erpnext/accounts/doctype/payment_entry/tests/test_payment_against_invoice.js
|
||||
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_last_purchase_rate.js
|
||||
erpnext/stock/doctype/item_price/test_item_price.js
|
||||
erpnext/stock/doctype/delivery_note/test_delivery_note_with_margin.js
|
||||
erpnext/selling/doctype/sales_order/tests/test_sales_order_with_margin.js
|
||||
erpnext/selling/doctype/quotation/tests/test_quotation_with_margin.js
|
||||
erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_margin.js
|
||||
erpnext/hr/doctype/payroll_entry/test_set_salary_components.js
|
||||
erpnext/hr/doctype/payroll_entry/test_payroll_entry.js
|
||||
erpnext/accounts/doctype/pricing_rule/tests/test_pricing_rule_with_same_currency.js
|
||||
erpnext/accounts/doctype/pricing_rule/tests/test_pricing_rule_with_different_currency.js
|
||||
@@ -1,46 +0,0 @@
|
||||
erpnext/setup/doctype/company/tests/test_company.js
|
||||
erpnext/crm/doctype/lead/tests/test_lead_individual.js
|
||||
erpnext/crm/doctype/lead/tests/test_lead_organization.js
|
||||
erpnext/setup/doctype/company/tests/test_company_production.js
|
||||
erpnext/hr/doctype/leave_block_list/test_leave_block_list.js
|
||||
erpnext/hr/doctype/department/test_department.js
|
||||
erpnext/hr/doctype/designation/test_designation.js
|
||||
erpnext/education/doctype/academic_year/test_academic_year.js
|
||||
erpnext/education/doctype/academic_term/test_academic_term.js
|
||||
erpnext/education/doctype/education_settings/test_education_settings.js
|
||||
erpnext/education/doctype/student_batch_name/test_student_batch_name.js
|
||||
erpnext/education/doctype/student_category/test_student_category.js
|
||||
erpnext/education/doctype/room/test_room.js
|
||||
erpnext/education/doctype/instructor/test_instructor.js
|
||||
erpnext/education/doctype/grading_scale/test_grading_scale.js
|
||||
erpnext/education/doctype/assessment_criteria_group/test_assessment_criteria_group.js
|
||||
erpnext/education/doctype/assessment_criteria/test_assessment_criteria.js
|
||||
erpnext/education/doctype/course/test_course.js
|
||||
erpnext/education/doctype/program/test_program.js
|
||||
erpnext/education/doctype/guardian/test_guardian.js
|
||||
erpnext/education/doctype/student_admission/test_student_admission.js
|
||||
erpnext/education/doctype/student_applicant/tests/test_student_applicant_dummy_data.js
|
||||
erpnext/education/doctype/student_applicant/tests/test_student_applicant.js
|
||||
erpnext/education/doctype/student_applicant/tests/test_student_applicant_options.js
|
||||
erpnext/education/doctype/student_log/test_student_log.js
|
||||
erpnext/education/doctype/student_group/test_student_group.js
|
||||
erpnext/education/doctype/student_group_creation_tool/test_student_group_creation_tool.js
|
||||
erpnext/education/doctype/student_leave_application/test_student_leave_application.js
|
||||
erpnext/education/doctype/student_attendance_tool/test_student_attendance_tool.js
|
||||
erpnext/education/doctype/student_attendance/test_student_attendance.js
|
||||
erpnext/education/doctype/assessment_group/test_assessment_group.js
|
||||
erpnext/education/doctype/assessment_plan/test_assessment_plan.js
|
||||
erpnext/education/doctype/assessment_result/test_assessment_result.js
|
||||
erpnext/education/doctype/assessment_result_tool/test_assessment_result_tool.js
|
||||
erpnext/projects/doctype/task/tests/test_task_tree.js
|
||||
erpnext/restaurant/doctype/restaurant/test_restaurant.js
|
||||
erpnext/restaurant/doctype/restaurant_table/test_restaurant_table.js
|
||||
erpnext/restaurant/doctype/restaurant_menu/test_restaurant_menu.js
|
||||
erpnext/restaurant/doctype/restaurant_order_entry/restaurant_order_entry.js
|
||||
erpnext/non_profit/doctype/membership_type/test_membership_type.js
|
||||
erpnext/non_profit/doctype/member/test_member.js
|
||||
erpnext/non_profit/doctype/volunteer_type/test_volunteer_type.js
|
||||
erpnext/non_profit/doctype/volunteer/test_volunteer.js
|
||||
erpnext/non_profit/doctype/donor_type/test_donor_type.js
|
||||
erpnext/non_profit/doctype/donor/test_donor.js
|
||||
erpnext/non_profit/doctype/grant_application/test_grant_application.js
|
||||
@@ -1,21 +0,0 @@
|
||||
import frappe
|
||||
|
||||
from erpnext.bulk_transaction.doctype.bulk_transaction_logger.test_bulk_transaction_logger import (
|
||||
create_company,
|
||||
create_customer,
|
||||
create_item,
|
||||
create_so,
|
||||
)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_records():
|
||||
create_company()
|
||||
create_customer()
|
||||
create_item()
|
||||
|
||||
gd = frappe.get_doc("Global Defaults")
|
||||
gd.set("default_company", "Test Bulk")
|
||||
gd.save()
|
||||
frappe.clear_cache()
|
||||
create_so()
|
||||
@@ -1,62 +0,0 @@
|
||||
import frappe
|
||||
from frappe.utils import getdate
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_employee_records():
|
||||
create_company()
|
||||
create_missing_designation()
|
||||
|
||||
frappe.db.sql("DELETE FROM tabEmployee WHERE company='Test Org Chart'")
|
||||
|
||||
emp1 = create_employee('Test Employee 1', 'CEO')
|
||||
emp2 = create_employee('Test Employee 2', 'CTO')
|
||||
emp3 = create_employee('Test Employee 3', 'Head of Marketing and Sales', emp1)
|
||||
emp4 = create_employee('Test Employee 4', 'Project Manager', emp2)
|
||||
emp5 = create_employee('Test Employee 5', 'Engineer', emp2)
|
||||
emp6 = create_employee('Test Employee 6', 'Analyst', emp3)
|
||||
emp7 = create_employee('Test Employee 7', 'Software Developer', emp4)
|
||||
|
||||
employees = [emp1, emp2, emp3, emp4, emp5, emp6, emp7]
|
||||
return employees
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_employee_records():
|
||||
return frappe.db.get_list('Employee', filters={
|
||||
'company': 'Test Org Chart'
|
||||
}, pluck='name', order_by='name')
|
||||
|
||||
def create_company():
|
||||
company = frappe.db.exists('Company', 'Test Org Chart')
|
||||
if not company:
|
||||
company = frappe.get_doc({
|
||||
'doctype': 'Company',
|
||||
'company_name': 'Test Org Chart',
|
||||
'country': 'India',
|
||||
'default_currency': 'INR'
|
||||
}).insert().name
|
||||
|
||||
return company
|
||||
|
||||
def create_employee(first_name, designation, reports_to=None):
|
||||
employee = frappe.db.exists('Employee', {'first_name': first_name, 'designation': designation})
|
||||
if not employee:
|
||||
employee = frappe.get_doc({
|
||||
'doctype': 'Employee',
|
||||
'first_name': first_name,
|
||||
'company': 'Test Org Chart',
|
||||
'gender': 'Female',
|
||||
'date_of_birth': getdate('08-12-1998'),
|
||||
'date_of_joining': getdate('01-01-2021'),
|
||||
'designation': designation,
|
||||
'reports_to': reports_to
|
||||
}).insert().name
|
||||
|
||||
return employee
|
||||
|
||||
def create_missing_designation():
|
||||
if not frappe.db.exists('Designation', 'CTO'):
|
||||
frappe.get_doc({
|
||||
'doctype': 'Designation',
|
||||
'designation_name': 'CTO'
|
||||
}).insert()
|
||||
@@ -9,83 +9,77 @@ from frappe.core.doctype.report.report import get_report_module_dotted_path
|
||||
ReportFilters = Dict[str, Any]
|
||||
ReportName = NewType("ReportName", str)
|
||||
|
||||
|
||||
def create_test_contact_and_address():
|
||||
frappe.db.sql('delete from tabContact')
|
||||
frappe.db.sql('delete from `tabContact Email`')
|
||||
frappe.db.sql('delete from `tabContact Phone`')
|
||||
frappe.db.sql('delete from tabAddress')
|
||||
frappe.db.sql('delete from `tabDynamic Link`')
|
||||
frappe.db.sql("delete from tabContact")
|
||||
frappe.db.sql("delete from `tabContact Email`")
|
||||
frappe.db.sql("delete from `tabContact Phone`")
|
||||
frappe.db.sql("delete from tabAddress")
|
||||
frappe.db.sql("delete from `tabDynamic Link`")
|
||||
|
||||
frappe.get_doc({
|
||||
"doctype": "Address",
|
||||
"address_title": "_Test Address for Customer",
|
||||
"address_type": "Office",
|
||||
"address_line1": "Station Road",
|
||||
"city": "_Test City",
|
||||
"state": "Test State",
|
||||
"country": "India",
|
||||
"links": [
|
||||
{
|
||||
"link_doctype": "Customer",
|
||||
"link_name": "_Test Customer"
|
||||
}
|
||||
]
|
||||
}).insert()
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Address",
|
||||
"address_title": "_Test Address for Customer",
|
||||
"address_type": "Office",
|
||||
"address_line1": "Station Road",
|
||||
"city": "_Test City",
|
||||
"state": "Test State",
|
||||
"country": "India",
|
||||
"links": [{"link_doctype": "Customer", "link_name": "_Test Customer"}],
|
||||
}
|
||||
).insert()
|
||||
|
||||
contact = frappe.get_doc({
|
||||
"doctype": 'Contact',
|
||||
"first_name": "_Test Contact for _Test Customer",
|
||||
"links": [
|
||||
{
|
||||
"link_doctype": "Customer",
|
||||
"link_name": "_Test Customer"
|
||||
}
|
||||
]
|
||||
})
|
||||
contact = frappe.get_doc(
|
||||
{
|
||||
"doctype": "Contact",
|
||||
"first_name": "_Test Contact for _Test Customer",
|
||||
"links": [{"link_doctype": "Customer", "link_name": "_Test Customer"}],
|
||||
}
|
||||
)
|
||||
contact.add_email("test_contact_customer@example.com", is_primary=True)
|
||||
contact.add_phone("+91 0000000000", is_primary_phone=True)
|
||||
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 = 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()
|
||||
|
||||
|
||||
def execute_script_report(
|
||||
report_name: ReportName,
|
||||
module: str,
|
||||
filters: ReportFilters,
|
||||
default_filters: Optional[ReportFilters] = None,
|
||||
optional_filters: Optional[ReportFilters] = None
|
||||
):
|
||||
report_name: ReportName,
|
||||
module: str,
|
||||
filters: ReportFilters,
|
||||
default_filters: Optional[ReportFilters] = None,
|
||||
optional_filters: Optional[ReportFilters] = None,
|
||||
):
|
||||
"""Util for testing execution of a report with specified filters.
|
||||
|
||||
Tests the execution of report with default_filters + filters.
|
||||
Tests the execution using optional_filters one at a time.
|
||||
|
||||
Args:
|
||||
report_name: Human readable name of report (unscrubbed)
|
||||
module: module to which report belongs to
|
||||
filters: specific values for filters
|
||||
default_filters: default values for filters such as company name.
|
||||
optional_filters: filters which should be tested one at a time in addition to default filters.
|
||||
report_name: Human readable name of report (unscrubbed)
|
||||
module: module to which report belongs to
|
||||
filters: specific values for filters
|
||||
default_filters: default values for filters such as company name.
|
||||
optional_filters: filters which should be tested one at a time in addition to default filters.
|
||||
"""
|
||||
|
||||
if default_filters is None:
|
||||
default_filters = {}
|
||||
|
||||
test_filters = []
|
||||
report_execute_fn = frappe.get_attr(get_report_module_dotted_path(module, report_name) + ".execute")
|
||||
report_execute_fn = frappe.get_attr(
|
||||
get_report_module_dotted_path(module, report_name) + ".execute"
|
||||
)
|
||||
report_filters = frappe._dict(default_filters).copy().update(filters)
|
||||
|
||||
test_filters.append(report_filters)
|
||||
|
||||
Reference in New Issue
Block a user