Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion genesis/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ async def handle_any_dtmf(dtmf: str):
"""

def decorator(
func: Callable[[str], Awaitable[None]]
func: Callable[[str], Awaitable[None]],
) -> Callable[[str], Awaitable[None]]:
async def dtmf_handler(event: ESLEvent) -> None:
dtmf_digit = event.get("DTMF-Digit")
Expand Down
1 change: 0 additions & 1 deletion genesis/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from genesis.cli.outbound import outbound
from genesis.observability import reconfigure_logger, logger


app = typer.Typer(rich_markup_mode="rich")
app.add_typer(consumer, name="consumer", short_help="Run you ESL events consumer.")
app.add_typer(outbound, name="outbound", short_help="Run you outbound services.")
Expand Down
1 change: 0 additions & 1 deletion genesis/cli/outbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from genesis.types import WatcherProtocol
from genesis.observability import observability, AppType


outbound = typer.Typer(rich_markup_mode="rich")


Expand Down
129 changes: 98 additions & 31 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ redis = ["redis"]

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.4"
black = ">=22.1,<25.0"
black = ">=22.1,<27.0"
pytest-asyncio = "^0.18.2"
pytest-cov = "^7.0.0"
tox = "^3.24.5"
Expand Down
61 changes: 20 additions & 41 deletions tests/payloads.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from textwrap import dedent


mod_audio_stream_play = dedent(
"""\
Event-Subclass: mod_audio_stream::play
Expand Down Expand Up @@ -195,8 +194,7 @@
)


heartbeat = dedent(
"""\
heartbeat = dedent("""\
Event-Name: HEARTBEAT
Core-UUID: cb2d5146-9a99-11e4-9291-092b1a87b375
FreeSWITCH-Hostname: evoluxdev
Expand All @@ -222,12 +220,10 @@
Session-Since-Startup: 34
Session-Peak-Max: 4
Session-Peak-FiveMin: 0
Idle-CPU: 98.700000"""
)
Idle-CPU: 98.700000""")


channel_create = dedent(
"""\
channel_create = dedent("""\
Event-Name: CHANNEL_CREATE
Core-UUID: ed56dab6-a6fc-11e4-960f-6f83a2e5e50a
FreeSWITCH-Hostname: evoluxdev
Expand Down Expand Up @@ -378,12 +374,10 @@
a=fmtp:101 0-15
a=rtcp:4017 IN IP4 192.0.2.2

variable_endpoint_disposition: DELAYED NEGOTIATION"""
)
variable_endpoint_disposition: DELAYED NEGOTIATION""")


background_job = dedent(
"""\
background_job = dedent("""\
Content-Length: 579
Content-Type: text/event-plain

Expand All @@ -403,12 +397,10 @@
Event-Calling-Line-Number: 609
Content-Length: 40

+OK 7f4de4bc-17d7-11dd-b7a0-db4edd065621"""
)
+OK 7f4de4bc-17d7-11dd-b7a0-db4edd065621""")


custom = dedent(
"""\
custom = dedent("""\
Event-Name: RELOADXML
Core-UUID: 6c6def18-9562-de11-a8e0-001fc6ab49e2
FreeSWITCH-Hostname: localhost.localdomain
Expand All @@ -423,12 +415,10 @@
Content-Length: 41
Content-Length: 42
Content-Length: 43
"""
)
""")


register = dedent(
"""\
register = dedent("""\
Event-Subclass: sofia::register
Event-Name: CUSTOM
Core-UUID: 662db344-5ecc-4eaa-9002-9992b7ab7c4d
Expand Down Expand Up @@ -456,12 +446,10 @@
network-port: 5060
username: 1000
realm: dev-cs2.fusedsolutions.com
user-agent: SIPPER%20for%20PhonerLite"""
)
user-agent: SIPPER%20for%20PhonerLite""")


connect = dedent(
"""\
connect = dedent("""\
Channel-Username: 1001
Channel-Dialplan: XML
Channel-Caller-ID-Name: 1001
Expand Down Expand Up @@ -562,42 +550,33 @@
variable_endpoint_disposition: EARLY%20MEDIA
Content-Type: command/reply
Socket-Mode: async
Control: full"""
)
Control: full""")


generic = dedent(
"""\
generic = dedent("""\
Content-Type: command/reply
Reply-Text: Reply generic command
"""
)
""")


channel_state = dedent(
"""\
channel_state = dedent("""\
Event-Name: CHANNEL_STATE
Unique-ID: {unique_id}
Channel-State: {state}
variable_test_key: {variable_test_key}
Content-Type: text/event-plain
Content-Length: 0
"""
)
""")


dtmf = dedent(
"""\
dtmf = dedent("""\
Event-Name: DTMF
DTMF-Digit: {digit}
Unique-ID: {unique_id}
"""
)
""")


channel_answer = dedent(
"""\
channel_answer = dedent("""\
Event-Name: CHANNEL_ANSWER
Unique-ID: {unique_id}
"""
)
""")
6 changes: 2 additions & 4 deletions tests/test_inbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,15 @@ async def test_inbound_client_send_command(freeswitch):


async def test_send_api_command_with_large_reponse(freeswitch):
status = dedent(
"""\
status = dedent("""\
UP 0 years, 80 days, 8 hours, 25 minutes, 5 seconds, 869 milliseconds, 87 microseconds
FreeSWITCH (Version 1.10.3-release git e52b1a8 2020-09-09 12:16:24Z 64bit) is ready
"7653 session(s) since startup
0 session(s) - peak 2, last 5min 0
0 session(s) per Sec out of max 30, peak 14, last 5min 0
1000 session(s) max
min idle cpu 0.00/99.00
Current Stack Size/Max 240K/8192K"""
)
Current Stack Size/Max 240K/8192K""")
async with freeswitch as server:
server.oncommand("api status", status)
async with Inbound(*freeswitch.address) as client:
Expand Down
1 change: 0 additions & 1 deletion tests/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
TRACE_LEVEL_NUM,
)


log_level_cases = [
{"env_value": None, "expected": logging.INFO, "description": "default"},
{"env_value": "TRACE", "expected": TRACE_LEVEL_NUM, "description": "trace"},
Expand Down
6 changes: 2 additions & 4 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def test_parse_heartbeat_event(heartbeat):
def test_parse_channel_create_event_with_multiline_field(channel):
headers = parse_headers(channel["create"])
got = headers["variable_switch_r_sdp"]
expected = dedent(
"""\
expected = dedent("""\
v=0
o=- 3631463817 3631463817 IN IP4 192.0.2.2
s=pjmedia
Expand All @@ -60,8 +59,7 @@ def test_parse_channel_create_event_with_multiline_field(channel):
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=rtcp:4017 IN IP4 192.0.2.2"""
)
a=rtcp:4017 IN IP4 192.0.2.2""")

assert got == expected, "Event parsing did not happen as expected"

Expand Down
Loading