test: Fix erroneous code
diff --git a/erpnext/tests/exotel_test_data.py b/erpnext/tests/exotel_test_data.py
index e2ae7f7..3ad2575 100644
--- a/erpnext/tests/exotel_test_data.py
+++ b/erpnext/tests/exotel_test_data.py
@@ -1,114 +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_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_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_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",
- }
- ],
-})
\ No newline at end of file
+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",
+ }
+ ],
+ }
+)
diff --git a/erpnext/tests/test_exotel.py b/erpnext/tests/test_exotel.py
index d2e317a..a5dc7dd 100644
--- a/erpnext/tests/test_exotel.py
+++ b/erpnext/tests/test_exotel.py
@@ -16,15 +16,14 @@
create_contact("Test Contact", "Mr", phones=phones)
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"
end_call_api_method = "handle_end_call"
-
emulate_api_call(call_initiation_data, 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)
self.assertEqual(call_log.get("from"), call_initiation_data.CallFrom)
@@ -34,6 +33,7 @@
def test_for_disconnected_call(self):
from .exotel_test_data import call_disconnected_data
+
api_method = "handle_missed_call"
emulate_api_call(call_disconnected_data, api_method)
call_log = frappe.get_doc("Call Log", call_disconnected_data.CallSid)
@@ -45,6 +45,7 @@
def test_for_call_not_answered(self):
from .exotel_test_data import call_not_answered_data
+
api_method = "handle_missed_call"
emulate_api_call(call_not_answered_data, api_method)
@@ -66,7 +67,8 @@
res.raise_for_status()
time.sleep(1)
+
def get_exotel_handler_endpoint(method):
site = "localhost" if os.environ.get("CI") else frappe.local.site
port = frappe.get_site_config().webserver_port or "8000"
- return f"http://{site}:{port}/api/method/erpnext.erpnext_integrations.exotel_integration.{method}"
\ No newline at end of file
+ return f"http://{site}:{port}/api/method/erpnext.erpnext_integrations.exotel_integration.{method}"