-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from romkazor/master
Improvements and tests
- Loading branch information
Showing
4 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,9 +109,10 @@ def getdict(self, key): | |
sip:[email protected]:4242 | ||
""" | ||
values = self.get(key, None) | ||
if not isinstance(values, list): | ||
raise TypeError("{0} must be a list. got {1}".format(key, values)) | ||
result = utils.CaseInsensitiveDict() | ||
if not isinstance(values, list): | ||
result[key] = values | ||
return result | ||
for item in values: | ||
k, v = item.split('=', 1) | ||
result[k] = v | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Asterisk Call Manager/7.0.3 | ||
Action: Challenge | ||
AuthType: MD5 | ||
ActionID: action/transaction_uid/1/1 | ||
|
||
Response: Success | ||
Challenge: 145769581 | ||
ActionID: action/transaction_uid/1/1 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,25 @@ def test_content(message): | |
--- blah --- | ||
''') | ||
assert m.content == '--- blah ---' | ||
|
||
|
||
@pytest.mark.parametrize('msg', [ | ||
Message( | ||
{ | ||
'Response': 'Success', | ||
'ChanVariable': ['FROM_DID=', 'SIPURI=sip:[email protected]:4242'], | ||
} | ||
), | ||
Message( | ||
{ | ||
'Response': 'Success', | ||
'ChanVariable': 'var', | ||
} | ||
) | ||
] | ||
) | ||
def test_getdict(msg): | ||
assert isinstance(msg.getdict('chanvariable'), utils.CaseInsensitiveDict) | ||
for k, v in msg.getdict('chanvariable').items(): | ||
assert isinstance(k, str) | ||
assert isinstance(v, str) |