Skip to content

Commit 4b44c49

Browse files
Merge pull request #127 from Bandwidth/DX-2906
DX-2906 `<Ring>` Verb Refactor
2 parents ddc9b34 + ce95633 commit 4b44c49

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

bandwidth/model/bxml/verbs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .phone_number import PhoneNumber
77
from .play_audio import PlayAudio
88
from .record import Record
9+
from .ring import Ring
910
from .send_dtmf import SendDtmf
1011
from .sip_uri import SipUri
1112
from .speak_sentence import SpeakSentence

bandwidth/model/bxml/verbs/ring.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
ring.py
3+
4+
Bandwidth's Ring BXML verb
5+
6+
@copyright Bandwidth INC
7+
"""
8+
from ..terminal_verb import TerminalVerb
9+
10+
11+
class Ring(TerminalVerb):
12+
13+
def __init__(
14+
self, duration: str = None,
15+
answer_call: str = None,
16+
):
17+
"""Initialize a <Ring> verb
18+
19+
Args:
20+
duration (str, optional): How many seconds to play ringing on the call. Default value is 5. Range: decimal values between 0.1 - 86400.
21+
answer_call (str, optional): A boolean indicating whether or not to answer the call when Ring is executed on an unanswered incoming call. Default value is 'true'.
22+
"""
23+
self.duration = duration
24+
self.answer_call = answer_call
25+
super().__init__(tag="Ring")
26+
27+
@property
28+
def _attributes(self):
29+
return {
30+
"duration": self.duration,
31+
"answerCall": self.answer_call,
32+
}

test/unit/bxml/test_ring.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
test_ring.py
3+
4+
Unit tests for the <Ring> BXML verb
5+
6+
@copyright Bandwidth Inc.
7+
"""
8+
import os
9+
import pytest
10+
import unittest
11+
12+
from bandwidth.model.bxml.verb import Verb
13+
from bandwidth.model.bxml.verbs.ring import Ring
14+
15+
16+
class TestRing(unittest.TestCase):
17+
18+
def setUp(self):
19+
self.ring = Ring(
20+
duration="30",
21+
answer_call="true",
22+
)
23+
self.test_verb = Verb(tag="test")
24+
25+
def test_to_bxml(self):
26+
if os.environ['PYTHON_VERSION'] == '3.7':
27+
expected = '<Ring answerCall="true" duration="30" />'
28+
else:
29+
expected = '<Ring duration="30" answerCall="true" />'
30+
31+
assert(expected == self.ring.to_bxml())
32+
33+
def test_add_verb(self):
34+
with pytest.raises(AttributeError):
35+
self.ring.add_verb(self.test_verb)

0 commit comments

Comments
 (0)