switest 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/lib/switest/esl/client.rb +15 -7
- data/lib/switest/esl/connection.rb +5 -2
- data/lib/switest/scenario.rb +2 -3
- data/lib/switest/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 056e2a1dd0271f490fdfb77978cdb272b8ac79f592aa18818642956d12f7c1a8
|
|
4
|
+
data.tar.gz: 28ec935b623017b29b5bd2f6899d82b85a84b6ac7a452977f4f9cb25f6445b9d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7dcffb0b3476237f826d7480251f00e70046197737d9886ea48a16dc886b463d1dfc83223858008fce51d14ab791e7d374252c43adf931a06ee95d114300d204
|
|
7
|
+
data.tar.gz: bded19bd55e5f76a7e2b93fa67f757e924f5f1bfe3b4089ab7c0c31ee8f74a4c97db7f9ce8437f2f6daf6da7790440ca941529a548f6e9905fc9699c668c3da4
|
data/README.md
CHANGED
|
@@ -171,13 +171,21 @@ agent.end_reason # e.g. "NORMAL_CLEARING"
|
|
|
171
171
|
assert_call(agent, timeout: 5) # Agent receives a call
|
|
172
172
|
assert_no_call(agent, timeout: 2) # Agent does NOT receive a call
|
|
173
173
|
assert_answered(agent, timeout: 5) # Call has been answered
|
|
174
|
-
assert_bridged(agent, timeout: 5) # Call has been bridged
|
|
174
|
+
assert_bridged(agent, timeout: 5) # Call has been bridged (see note below)
|
|
175
175
|
assert_hungup(agent, timeout: 5) # Call has ended
|
|
176
176
|
assert_not_hungup(agent, timeout: 2) # Call is still active
|
|
177
177
|
assert_dtmf(agent, "123", timeout: 5) # Agent receives expected DTMF digits
|
|
178
178
|
assert_dtmf(agent, "123") { other.send_dtmf("123") } # With block: flushes stale DTMF first
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
+
**Note on `assert_bridged`:** This assertion only works when a CHANNEL_BRIDGE
|
|
182
|
+
event fires on a channel Switest tracks. It works when the FreeSWITCH dialplan
|
|
183
|
+
runs the `bridge` application on an inbound channel picked up via
|
|
184
|
+
`listen_for_call`. It does **not** work for agent-to-agent calls routed through
|
|
185
|
+
SIP gateways — the bridge happens on internal gateway legs whose UUIDs Switest
|
|
186
|
+
doesn't track. For gateway scenarios, use `assert_answered` on both agents
|
|
187
|
+
instead to confirm the call is connected.
|
|
188
|
+
|
|
181
189
|
The `hangup_all` helper ends all active calls (useful before CDR assertions):
|
|
182
190
|
|
|
183
191
|
```ruby
|
data/lib/switest/esl/client.rb
CHANGED
|
@@ -39,16 +39,24 @@ module Switest
|
|
|
39
39
|
|
|
40
40
|
# Hangup all active calls individually and wait for them to end.
|
|
41
41
|
# This ensures proper hangup_cause is set for each call (important for CDRs).
|
|
42
|
+
# Sends all hangups first, then waits with a shared deadline to avoid
|
|
43
|
+
# O(n * timeout) delays with many calls.
|
|
42
44
|
def hangup_all(cause: "NORMAL_CLEARING", timeout: 5)
|
|
43
45
|
return unless @connection&.connected?
|
|
44
46
|
|
|
45
|
-
@calls.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
rescue
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
active = @calls.values.reject(&:ended?)
|
|
48
|
+
|
|
49
|
+
# Send all hangups without waiting
|
|
50
|
+
active.each do |call|
|
|
51
|
+
call.hangup(cause, wait: false) rescue nil
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Wait for all to end with a single shared deadline
|
|
55
|
+
deadline = Time.now + timeout
|
|
56
|
+
active.each do |call|
|
|
57
|
+
remaining = deadline - Time.now
|
|
58
|
+
break if remaining <= 0
|
|
59
|
+
call.wait_for_end(timeout: remaining) unless call.ended?
|
|
52
60
|
end
|
|
53
61
|
end
|
|
54
62
|
|
|
@@ -110,8 +110,11 @@ module Switest
|
|
|
110
110
|
|
|
111
111
|
def subscribe_events
|
|
112
112
|
events = %w[
|
|
113
|
-
CHANNEL_CREATE
|
|
114
|
-
|
|
113
|
+
CHANNEL_CREATE # Detect new inbound calls
|
|
114
|
+
CHANNEL_ANSWER # Track when calls are answered
|
|
115
|
+
CHANNEL_BRIDGE # Track when calls are bridged
|
|
116
|
+
CHANNEL_HANGUP_COMPLETE # Track call end with final headers
|
|
117
|
+
DTMF # Receive DTMF digits per call
|
|
115
118
|
].join(" ")
|
|
116
119
|
|
|
117
120
|
@socket.write("event plain #{events}\n\n")
|
data/lib/switest/scenario.rb
CHANGED
|
@@ -78,9 +78,8 @@ module Switest
|
|
|
78
78
|
|
|
79
79
|
if block
|
|
80
80
|
agent.flush_dtmf
|
|
81
|
-
|
|
82
|
-
received = agent.receive_dtmf(count: expected_dtmf.length, timeout: timeout)
|
|
83
|
-
task.wait
|
|
81
|
+
Concurrent::ScheduledTask.execute(after) { block.call }
|
|
82
|
+
received = agent.receive_dtmf(count: expected_dtmf.length, timeout: timeout + after)
|
|
84
83
|
else
|
|
85
84
|
received = agent.receive_dtmf(count: expected_dtmf.length, timeout: timeout)
|
|
86
85
|
end
|
data/lib/switest/version.rb
CHANGED