Skip to content

Commit 6fdab7d

Browse files
Merge pull request #117 from Bandwidth/DX-2899
DX-2899 Pause Verb Refactor
2 parents 55a000b + fda5777 commit 6fdab7d

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

bandwidth/model/bxml/verbs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .bridge import Bridge
2+
from .pause import Pause
23
from .hangup import Hangup
34
from .gather import Gather
45
from .phone_number import PhoneNumber
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""
2+
pause.py
3+
Bandwidth's Pause BXML verb
4+
@copyright Bandwidth INC
5+
"""
6+
from ..terminal_verb import TerminalVerb
7+
class Pause(TerminalVerb):
8+
def __init__(self, duration:str=None):
9+
"""Initialize a <Pause> verb
10+
Args:
11+
duration (str, optional): The time in seconds to pause. Default value is 1.
12+
"""
13+
self.duration = duration
14+
15+
super().__init__(tag="Pause", content=None)
16+
@property
17+
def _attributes(self):
18+
return {
19+
"duration": self.duration
20+
}

test/unit/bxml/test_pause.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
test_Pause.py
3+
4+
Unit tests for the <Pause> BXML verb
5+
6+
@copyright Bandwidth Inc.
7+
"""
8+
import pytest
9+
import unittest
10+
from bandwidth.model.bxml.verb import Verb
11+
from bandwidth.model.bxml.verbs.pause import Pause
12+
13+
class TestPause(unittest.TestCase):
14+
15+
def setUp(self):
16+
self.pause = Pause(duration="30")
17+
self.test_verb = Verb(tag="test")
18+
19+
def test_to_bxml(self):
20+
expected = '<Pause duration="30" />'
21+
assert(expected == self.pause.to_bxml())
22+
23+
def test_add_verb(self):
24+
with pytest.raises(AttributeError):
25+
self.pause.add_verb(self.test_verb)

0 commit comments

Comments
 (0)