mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 19:59:12 +00:00
test: Fix erroneous code
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
call_initiation_data = frappe._dict({
|
call_initiation_data = frappe._dict(
|
||||||
|
{
|
||||||
"CallSid": "23c162077629863c1a2d7f29263a162m",
|
"CallSid": "23c162077629863c1a2d7f29263a162m",
|
||||||
"CallFrom": "09999999991",
|
"CallFrom": "09999999991",
|
||||||
"CallTo": "09999999980",
|
"CallTo": "09999999980",
|
||||||
@@ -13,9 +14,11 @@ call_initiation_data = frappe._dict({
|
|||||||
"Status": "busy",
|
"Status": "busy",
|
||||||
"EventType": "Dial",
|
"EventType": "Dial",
|
||||||
"AgentEmail": "test_employee_exotel@company.com",
|
"AgentEmail": "test_employee_exotel@company.com",
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
call_end_data = frappe._dict({
|
call_end_data = frappe._dict(
|
||||||
|
{
|
||||||
"CallSid": "23c162077629863c1a2d7f29263a162m",
|
"CallSid": "23c162077629863c1a2d7f29263a162m",
|
||||||
"CallFrom": "09999999991",
|
"CallFrom": "09999999991",
|
||||||
"CallTo": "09999999980",
|
"CallTo": "09999999980",
|
||||||
@@ -47,9 +50,11 @@ call_end_data = frappe._dict({
|
|||||||
"Cause": "16",
|
"Cause": "16",
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
call_disconnected_data = frappe._dict({
|
call_disconnected_data = frappe._dict(
|
||||||
|
{
|
||||||
"CallSid": "d96421addce69e24bdc7ce5880d1162l",
|
"CallSid": "d96421addce69e24bdc7ce5880d1162l",
|
||||||
"CallFrom": "09999999991",
|
"CallFrom": "09999999991",
|
||||||
"CallTo": "09999999980",
|
"CallTo": "09999999980",
|
||||||
@@ -79,9 +84,11 @@ call_disconnected_data = frappe._dict({
|
|||||||
"Cause": "1003",
|
"Cause": "1003",
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
call_not_answered_data = frappe._dict({
|
call_not_answered_data = frappe._dict(
|
||||||
|
{
|
||||||
"CallSid": "fdb67a2b4b2d057b610a52ef43f81622",
|
"CallSid": "fdb67a2b4b2d057b610a52ef43f81622",
|
||||||
"CallFrom": "09999999991",
|
"CallFrom": "09999999991",
|
||||||
"CallTo": "09999999980",
|
"CallTo": "09999999980",
|
||||||
@@ -111,4 +118,5 @@ call_not_answered_data = frappe._dict({
|
|||||||
"Cause": "1003",
|
"Cause": "1003",
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|||||||
@@ -16,15 +16,14 @@ class TestExotel(unittest.TestCase):
|
|||||||
create_contact("Test Contact", "Mr", phones=phones)
|
create_contact("Test Contact", "Mr", phones=phones)
|
||||||
|
|
||||||
def test_for_successful_call(self):
|
def test_for_successful_call(self):
|
||||||
from .exotel_test_data import call_initiation_data, call_end_data
|
from .exotel_test_data import call_end_data, call_initiation_data
|
||||||
|
|
||||||
api_method = "handle_incoming_call"
|
api_method = "handle_incoming_call"
|
||||||
end_call_api_method = "handle_end_call"
|
end_call_api_method = "handle_end_call"
|
||||||
|
|
||||||
|
|
||||||
emulate_api_call(call_initiation_data, api_method)
|
emulate_api_call(call_initiation_data, api_method)
|
||||||
emulate_api_call(call_end_data, end_call_api_method)
|
emulate_api_call(call_end_data, end_call_api_method)
|
||||||
self.assertEqual(call_log.get("from"), "09999999991")
|
|
||||||
self.assertEqual(call_log.get("to"), "09999999999")
|
|
||||||
call_log = frappe.get_doc("Call Log", call_initiation_data.CallSid)
|
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("from"), call_initiation_data.CallFrom)
|
||||||
@@ -34,6 +33,7 @@ class TestExotel(unittest.TestCase):
|
|||||||
|
|
||||||
def test_for_disconnected_call(self):
|
def test_for_disconnected_call(self):
|
||||||
from .exotel_test_data import call_disconnected_data
|
from .exotel_test_data import call_disconnected_data
|
||||||
|
|
||||||
api_method = "handle_missed_call"
|
api_method = "handle_missed_call"
|
||||||
emulate_api_call(call_disconnected_data, api_method)
|
emulate_api_call(call_disconnected_data, api_method)
|
||||||
call_log = frappe.get_doc("Call Log", call_disconnected_data.CallSid)
|
call_log = frappe.get_doc("Call Log", call_disconnected_data.CallSid)
|
||||||
@@ -45,6 +45,7 @@ class TestExotel(unittest.TestCase):
|
|||||||
|
|
||||||
def test_for_call_not_answered(self):
|
def test_for_call_not_answered(self):
|
||||||
from .exotel_test_data import call_not_answered_data
|
from .exotel_test_data import call_not_answered_data
|
||||||
|
|
||||||
api_method = "handle_missed_call"
|
api_method = "handle_missed_call"
|
||||||
emulate_api_call(call_not_answered_data, api_method)
|
emulate_api_call(call_not_answered_data, api_method)
|
||||||
|
|
||||||
@@ -66,6 +67,7 @@ def emulate_api_call(data, api_method):
|
|||||||
res.raise_for_status()
|
res.raise_for_status()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
def get_exotel_handler_endpoint(method):
|
def get_exotel_handler_endpoint(method):
|
||||||
site = "localhost" if os.environ.get("CI") else frappe.local.site
|
site = "localhost" if os.environ.get("CI") else frappe.local.site
|
||||||
port = frappe.get_site_config().webserver_port or "8000"
|
port = frappe.get_site_config().webserver_port or "8000"
|
||||||
|
|||||||
Reference in New Issue
Block a user