8000 Only lower camel twiml kwargs if they contain _ (#401) · BioComputing/twilio-python@46e0d46 · GitHub
[go: up one dir, main page]

Skip to content

Commit 46e0d46

Browse files
codejudasjmctwilio
authored andcommitted
Only lower camel twiml kwargs if they contain _ (twilio#401)
1 parent 119fe50 commit 46e0d46

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

tests/unit/twiml/__init__.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
from nose.tools import raises
44
from six import text_type
55

6-
from twilio.twiml import format_language, TwiMLException, TwiML
6+
from twilio.twiml import (
7+
format_language,
8+
lower_camel,
9+
TwiMLException,
10+
TwiML
11+
)
712

813

914
class TwilioTest(unittest.TestCase):
@@ -30,3 +35,24 @@ def test_format_language_coerced(self):
3035
@raises(TwiMLException)
3136
def test_format_language_fail(self):
3237
format_language('this is invalid')
38+
39+
def test_lower_camel_empty_string(self):
40+
self.assertEqual('', lower_camel(''))
41+
42+
def test_lower_camel_none(self):
43+
self.assertEqual(None, lower_camel(None))
44+
45+
def test_lower_camel_single_word(self):
46+
self.assertEqual('foo', lower_camel('foo'))
47+
48+
def test_lower_camel_double_word(self):
49+
self.assertEqual('fooBar', lower_camel('foo_bar'))
50+
51+
def test_lower_camel_multi_word(self):
52+
self.assertEqual('fooBarBaz', lower_camel('foo_bar_baz'))
53+
54+
def test_lower_camel_multi_word_mixed_case(self):
55+
self.assertEqual('fooBarBaz', lower_camel('foO_Bar_baz'))
56+
57+
def test_lower_camel_camel_cased(self):
58+
self.assertEqual('fooBar', lower_camel('fooBar'))

tests/unit/twiml/test_voice_response.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def test_task_string(self):
419419

420420
assert_equal(
421421
self.strip(r),
422-
'<?xml version="1.0" encoding="UTF-8"?><Response><Enqueue workflowsid="123123123"><Task>{"account_sid": "AC123123123"}</Task></Enqueue></Response>'
422+
'<?xml version="1.0" encoding="UTF-8"?><Response><Enqueue workflowSid="123123123"><Task>{"account_sid": "AC123123123"}</Task></Enqueue></Response>'
423423
)
424424

425425
def test_task_dict(self):
@@ -430,8 +430,8 @@ def test_task_dict(self):
430430
r.append(e)
431431

432432
assert_equal(
433-
self.strip(r),
434-
'<?xml version="1.0" encoding="UTF-8"?><Response><Enqueue workflowsid="123123123"><Task>{"account_sid": "AC123123123"}</Task></Enqueue></Response>'
433+
'<?xml version="1.0" encoding="UTF-8"?><Response><Enqueue workflowSid="123123123"><Task>{"account_sid": "AC123123123"}</Task></Enqueue></Response>',
434+
self.strip(r)
435435
)
436436

437437

twilio/twiml/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313

1414
def lower_camel(string):
15-
result = "".join([x.title() for x in string.split('_')])
16-
if not result:
17-
return result
15+
if not string or '_' not in string:
16+
return string
1817

18+
result = "".join([x.title() for x in string.split('_')])
1919
return result[0].lower() + result[1:]
2020

2121

0 commit comments

Comments
 (0)
0