Skip to content

Commit 8fa977c

Browse files
Update for Attribute Refactoring
1 parent d9f33dc commit 8fa977c

File tree

4 files changed

+42
-27
lines changed

4 files changed

+42
-27
lines changed

bandwidth/model/bxml/verbs/gather.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,31 @@ def __init__(
6363
self.first_digit_timeout = first_digit_timeout
6464
self.repeat_count = repeat_count
6565
self.audio_verbs = audio_verbs
66+
super().__init__(
67+
tag="Gather",
68+
content=None,
69+
nested_verbs=self.audio_verbs)
70+
71+
@property
72+
def _attributes(self):
73+
return {
74+
"gather_url": self.gather_url,
75+
"gather_method": self.gather_method,
76+
"gather_fallback_url": self.gather_fallback_url,
77+
"gather_fallback_method": self.gather_fallback_method,
78+
"username": self.username,
79+
"password": self.password,
80+
"fallback_username": self.fallback_username,
81+
"fallback_password": self.fallback_password,
82+
"tag": self.tag,
83+
"terminating_digits": self.terminating_digits,
84+
"max_digits": self.max_digits,
85+
"inter_digit_timeout": self.inter_digit_timeout,
86+
"first_digit_timeout": self.first_digit_timeout,
87+
"repeat_count": self.repeat_count,
88+
}
6689
self.attributes = {
67-
"gather_url": gather_url,
68-
"gather_method": gather_method,
69-
"gather_fallback_url": gather_fallback_url,
70-
"gather_fallback_method": gather_fallback_method,
71-
"username": username,
72-
"password": password,
73-
"fallback_username": fallback_username,
74-
"fallback_password": fallback_password,
75-
"tag": tag,
76-
"terminating_digits": terminating_digits,
77-
"max_digits": max_digits,
78-
"inter_digit_timeout": inter_digit_timeout,
79-
"first_digit_timeout": first_digit_timeout,
80-
"repeat_count": repeat_count,
90+
8191
}
8292

8393
super().__init__(tag="Gather", content=None, attributes=self.attributes, nested_verbs=self.audio_verbs)

bandwidth/model/bxml/verbs/play_audio.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ def __init__(
2424
self.audio_uri = audio_uri
2525
self.username = username
2626
self.password = password
27-
self.attributes = {
28-
"username": self.username,
29-
"password": self.password,
30-
}
3127
super().__init__(
3228
tag="PlayAudio",
3329
content=self.audio_uri,
34-
attributes=self.attributes
3530
)
31+
32+
@property
33+
def _attributes(self):
34+
return {
35+
"username": self.username,
36+
"password": self.password,
37+
}

bandwidth/model/bxml/verbs/speak_sentence.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ def __init__(
2828
self.voice = voice
2929
self.gender = gender
3030
self.locale = locale
31-
self.attributes = {
32-
"voice": self.voice,
33-
"gender": self.gender,
34-
"locale": self.locale,
35-
}
3631
super().__init__(
3732
tag="SpeakSentence",
3833
content=self.text,
39-
attributes=self.attributes
4034
)
35+
36+
@property
37+
def _attributes(self):
38+
return {
39+
"voice": self.voice,
40+
"gender": self.gender,
41+
"locale": self.locale,
42+
}

test/unit/bxml/test_speak_sentence.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ class TestSpeakSentence(unittest.TestCase):
1616

1717
def setUp(self):
1818
self.speak_sentence = SpeakSentence(
19-
text='Hello. Your number is <say-as interpret-as="telephone">asdf</say-as>, lets play a game. What is 10 + 3. Press the pound key when finished.'
19+
text='Hello. Your number is <say-as interpret-as="telephone">asdf</say-as>, lets play a game. What is 10 + 3. Press the pound key when finished.',
20+
voice="julie"
2021
)
2122

2223
self.test_verb = Verb(tag="test")
2324

2425
def test_to_bxml(self):
25-
expected = '<SpeakSentence>Hello. Your number is &lt;say-as interpret-as="telephone"&gt;asdf&lt;/say-as&gt;, lets play a game. What is 10 + 3. Press the pound key when finished.</SpeakSentence>'
26+
expected = '<SpeakSentence voice="julie">Hello. Your number is &lt;say-as interpret-as="telephone"&gt;asdf&lt;/say-as&gt;, lets play a game. What is 10 + 3. Press the pound key when finished.</SpeakSentence>'
2627
assert(expected == self.speak_sentence.to_bxml())
2728

2829
def test_add_verb(self):

0 commit comments

Comments
 (0)