Skip to content

Commit 3fc8eb3

Browse files
committed
feat: add status predicate helpers to VoiceOutTrunk
Expose is_active / is_blocked properties so callers can stop doing string equality against VoiceOutTrunkStatus enum constants.
1 parent 756e92d commit 3fc8eb3

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/didww/resources/voice_out_trunk.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ class VoiceOutTrunk(DidwwApiModel):
4444
class Meta:
4545
type = "voice_out_trunks"
4646

47+
@property
48+
def is_active(self):
49+
return self.status == VoiceOutTrunkStatus.ACTIVE
50+
51+
@property
52+
def is_blocked(self):
53+
return self.status == VoiceOutTrunkStatus.BLOCKED
54+
4755
@property
4856
def authentication_method(self):
4957
data = self.attributes.get("authentication_method")

tests/resources/test_voice_out_trunk.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ def test_delete_voice_out_trunk(self, client):
8989
assert result is None
9090

9191

92+
class TestVoiceOutTrunkStatusHelpers:
93+
def test_is_active(self):
94+
trunk = VoiceOutTrunk()
95+
trunk.status = VoiceOutTrunkStatus.ACTIVE
96+
assert trunk.is_active is True
97+
assert trunk.is_blocked is False
98+
99+
def test_is_blocked(self):
100+
trunk = VoiceOutTrunk()
101+
trunk.status = VoiceOutTrunkStatus.BLOCKED
102+
assert trunk.is_blocked is True
103+
assert trunk.is_active is False
104+
105+
92106
class TestVoiceOutTrunkRelationships:
93107
def test_emergency_dids_relationship(self):
94108
trunk = VoiceOutTrunk()

0 commit comments

Comments
 (0)