-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fully handle NULL and empty lists
- Loading branch information
Showing
3 changed files
with
137 additions
and
26 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
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 |
---|---|---|
|
@@ -425,7 +425,6 @@ def test_nested_elements(): | |
user_id="[email protected]", | ||
phone_number="123456789", | ||
extension="1219", | ||
# sip_alias_list=api.get_type_object("ReplacementSIPAliasList",sip_alias=[]), | ||
sip_alias_list=Null, | ||
endpoint=dict( | ||
trunk_addressing=api.get_type_object( | ||
|
@@ -462,4 +461,44 @@ def test_nested_elements(): | |
) | ||
|
||
|
||
def test_nested_elements2(): | ||
cmd = api.get_command_object( | ||
"UserModifyRequest22", | ||
user_id="[email protected]", | ||
phone_number="123456789", | ||
extension="1219", | ||
sip_alias_list=api.get_type_object("ReplacementSIPAliasList", sip_alias=[]), | ||
endpoint=dict( | ||
trunk_addressing=api.get_type_object( | ||
"TrunkAddressingMultipleContactModify", | ||
trunk_group_device_endpoint=Null, | ||
enterprise_trunk_name="ET02", | ||
alternate_trunk_identity=Null, | ||
), | ||
), | ||
) | ||
check_command_xml( | ||
( | ||
b'<?xml version="1.0" encoding="ISO-8859-1"?>' | ||
b'<BroadsoftDocument protocol="OCI" xmlns="C" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' | ||
b'<sessionId xmlns="">00000000-1111-2222-3333-444444444444</sessionId>' | ||
b'<command xsi:type="UserModifyRequest22" xmlns="">' | ||
b"<userId>[email protected]</userId>" | ||
b"<phoneNumber>123456789</phoneNumber>" | ||
b"<extension>1219</extension>" | ||
b'<sipAliasList xsi:nil="true"/>' | ||
b"<endpoint>" | ||
b"<trunkAddressing>" | ||
b'<trunkGroupDeviceEndpoint xsi:nil="true"/>' | ||
b"<enterpriseTrunkName>ET02</enterpriseTrunkName>" | ||
b'<alternateTrunkIdentity xsi:nil="true"/>' | ||
b"</trunkAddressing>" | ||
b"</endpoint>" | ||
b"</command>" | ||
b"</BroadsoftDocument>" | ||
), | ||
cmd, | ||
) | ||
|
||
|
||
# end |
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
from collections import namedtuple | ||
|
||
import pytest # noqa: F401 | ||
from null_object import Null | ||
|
||
from broadworks_ocip import BroadworksAPI | ||
|
||
|
@@ -319,4 +320,45 @@ def test_group_department_add_xml(): | |
) | ||
|
||
|
||
def test_nested_elements(): | ||
xml = ( | ||
b'<?xml version="1.0" encoding="ISO-8859-1"?>' | ||
b'<BroadsoftDocument protocol="OCI" xmlns="C" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' | ||
b'<sessionId xmlns="">00000000-1111-2222-3333-444444444444</sessionId>' | ||
b'<command xsi:type="UserModifyRequest22" xmlns="">' | ||
b"<userId>[email protected]</userId>" | ||
b"<phoneNumber>123456789</phoneNumber>" | ||
b"<extension>1219</extension>" | ||
b'<sipAliasList xsi:nil="true"/>' | ||
b"<endpoint>" | ||
b"<trunkAddressing>" | ||
b'<trunkGroupDeviceEndpoint xsi:nil="true"/>' | ||
b"<enterpriseTrunkName>ET02</enterpriseTrunkName>" | ||
b'<alternateTrunkIdentity xsi:nil="true"/>' | ||
b"</trunkAddressing>" | ||
b"</endpoint>" | ||
b"</command>" | ||
b"</BroadsoftDocument>" | ||
) | ||
api = BroadworksAPI(**BASIC_API_PARAMS) | ||
generated = api.decode_xml(xml) | ||
assert generated.type_ == "UserModifyRequest22" | ||
assert generated.user_id == "[email protected]" | ||
assert generated.phone_number == "123456789" | ||
assert generated.sip_alias_list is Null | ||
|
||
# assert generated.sip_alias_list is Null | ||
print(generated.endpoint["trunk_addressing"]) | ||
assert ( | ||
generated.endpoint["trunk_addressing"].to_dict() | ||
== api.get_type_object( # noqa: W503 | ||
"TrunkAddressingMultipleContactModify", | ||
trunk_group_device_endpoint=Null, | ||
enterprise_trunk_name="ET02", | ||
alternate_trunk_identity=Null, | ||
# physical_location=None, | ||
).to_dict() | ||
) | ||
|
||
|
||
# end |