Skip to content

Commit e76dc6b

Browse files
committed
Address review feedback: optional sip_uri, set_sip_uri setter
Make sip_uri optional (default None) to match how other verbs handle their nested verbs, guard nested_verbs construction against None, and add a set_sip_uri() setter so callers can attach the SipUri after construction (mirrors the ruby/node Refer pattern). Replaced test_minimal/test_shares_sip_uri_with_transfer with a test covering the new setter.
1 parent e0d827a commit e76dc6b

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

‎bandwidth/models/bxml/verbs/refer.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class Refer(NestableVerb):
1313

1414
def __init__(
15-
self, sip_uri: SipUri,
15+
self, sip_uri: SipUri=None,
1616
refer_complete_url: str=None, refer_complete_method: str=None,
1717
tag: str=None
1818
):
@@ -47,7 +47,7 @@ def __init__(
4747
self.tag = tag
4848
super().__init__(
4949
tag="Refer",
50-
nested_verbs=[self.sip_uri]
50+
nested_verbs=[sip_uri] if sip_uri is not None else []
5151
)
5252

5353
@property
@@ -57,3 +57,12 @@ def _attributes(self):
5757
"referCompleteMethod": self.refer_complete_method,
5858
"tag": self.tag
5959
}
60+
61+
def set_sip_uri(self, sip_uri: SipUri) -> None:
62+
"""Set the SIP URI destination for this <Refer> verb.
63+
64+
Args:
65+
sip_uri (SipUri): The SIP URI to refer the call to.
66+
"""
67+
self.sip_uri = sip_uri
68+
self._nested_verbs = [sip_uri]

‎test/unit/models/bxml/test_refer.py‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,8 @@ def test_to_bxml(self):
3030
expected = '<Refer referCompleteUrl="https://example.com/handleRefer" referCompleteMethod="POST" tag="test"><SipUri>sip:alice@atlanta.example.com</SipUri></Refer>'
3131
assert expected == self.refer.to_bxml()
3232

33-
def test_minimal(self):
34-
minimal_refer = Refer(sip_uri=SipUri(uri="sip:bob@example.com"))
33+
def test_set_sip_uri(self):
34+
refer = Refer()
35+
refer.set_sip_uri(SipUri(uri="sip:bob@example.com"))
3536
expected = '<Refer><SipUri>sip:bob@example.com</SipUri></Refer>'
36-
assert expected == minimal_refer.to_bxml()
37-
38-
def test_shares_sip_uri_with_transfer(self):
39-
"""Refer uses the same SipUri model as Transfer, including its
40-
transfer-flavored attributes if the caller sets them."""
41-
sip_uri = SipUri(uri="sip:alice@atlanta.example.com", uui="test")
42-
refer = Refer(sip_uri=sip_uri)
43-
expected = '<Refer><SipUri uui="test">sip:alice@atlanta.example.com</SipUri></Refer>'
4437
assert expected == refer.to_bxml()

0 commit comments

Comments
 (0)