Skip to content

Commit cf50a01

Browse files
committed
test(services): Add tests for PausableSubscription service compliance with WSDL
1 parent 292a484 commit cf50a01

1 file changed

Lines changed: 108 additions & 0 deletions

File tree

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
from onvif.services import PausableSubscription
2+
from base_service_test import ONVIFServiceTestBase
3+
4+
5+
class TestPausableSubscriptionWSDLCompliance(ONVIFServiceTestBase):
6+
"""Test that PausableSubscription service implementation matches WSDL specification."""
7+
8+
# Service-specific configuration
9+
SERVICE_CLASS = PausableSubscription
10+
SERVICE_NAME = "events.pausable_subscription"
11+
WSDL_PATH_COMPONENTS = ["ver10", "events", "wsdl", "event-vs.wsdl"]
12+
BINDING_NAME = "PausableSubscriptionManagerBinding"
13+
NAMESPACE_PREFIX = "wsnt"
14+
SERVICE_NAMESPACE = "http://docs.oasis-open.org/wsn/bw-2"
15+
XADDR_PATH = "/onvif/Events"
16+
17+
def test_specific_methods_implementation(self):
18+
"""Test specific important methods are correctly implemented."""
19+
test_cases = [
20+
{
21+
"method": "Renew",
22+
"params": {"TerminationTime": "PT2H"},
23+
},
24+
{
25+
"method": "Renew",
26+
"params": {"TerminationTime": None},
27+
},
28+
{
29+
"method": "Unsubscribe",
30+
"params": {},
31+
},
32+
{
33+
"method": "PauseSubscription",
34+
"params": {},
35+
},
36+
{
37+
"method": "ResumeSubscription",
38+
"params": {},
39+
},
40+
]
41+
self.run_specific_methods_tests(test_cases)
42+
43+
def test_parameter_forwarding(self):
44+
"""Test that parameters are correctly forwarded to operator.call()."""
45+
test_cases = [
46+
{
47+
"method": "Renew",
48+
"params": {"TerminationTime": "PT3H"},
49+
},
50+
{
51+
"method": "Renew",
52+
"params": {"TerminationTime": None},
53+
},
54+
{
55+
"method": "Unsubscribe",
56+
"params": {},
57+
},
58+
{
59+
"method": "PauseSubscription",
60+
"params": {},
61+
},
62+
{
63+
"method": "ResumeSubscription",
64+
"params": {},
65+
},
66+
]
67+
self.run_parameter_forwarding_tests(test_cases)
68+
69+
def test_pausable_subscription_methods(self):
70+
"""Test that PausableSubscription has the correct methods."""
71+
# Check that all required methods exist
72+
assert hasattr(PausableSubscription, "Renew")
73+
assert hasattr(PausableSubscription, "Unsubscribe")
74+
assert hasattr(PausableSubscription, "PauseSubscription")
75+
assert hasattr(PausableSubscription, "ResumeSubscription")
76+
77+
# Check that methods are callable
78+
assert callable(getattr(PausableSubscription, "Renew"))
79+
assert callable(getattr(PausableSubscription, "Unsubscribe"))
80+
assert callable(getattr(PausableSubscription, "PauseSubscription"))
81+
assert callable(getattr(PausableSubscription, "ResumeSubscription"))
82+
83+
def test_inheritance(self):
84+
"""Test that PausableSubscription inherits from ONVIFService."""
85+
from onvif.utils import ONVIFService
86+
87+
assert issubclass(PausableSubscription, ONVIFService)
88+
89+
def test_pause_resume_operations(self):
90+
"""Test pause and resume operations specific to PausableSubscription."""
91+
# These are the unique operations that differentiate PausableSubscription
92+
# from regular Subscription
93+
implemented_methods = self.get_implemented_methods()
94+
95+
# Ensure pause/resume methods are implemented
96+
assert (
97+
"PauseSubscription" in implemented_methods
98+
), "PauseSubscription method should be implemented"
99+
assert (
100+
"ResumeSubscription" in implemented_methods
101+
), "ResumeSubscription method should be implemented"
102+
103+
# Ensure they have no parameters (according to WSDL)
104+
pause_params = implemented_methods["PauseSubscription"]["params"]
105+
resume_params = implemented_methods["ResumeSubscription"]["params"]
106+
107+
assert len(pause_params) == 0, "PauseSubscription should have no parameters"
108+
assert len(resume_params) == 0, "ResumeSubscription should have no parameters"

0 commit comments

Comments
 (0)