|
1 | 1 | import pytest
|
| 2 | +import zeep |
| 3 | +import zeep.wsdl |
2 | 4 |
|
3 | 5 | import aonvif
|
4 | 6 | import aonvif.client
|
@@ -205,3 +207,42 @@ async def test_client_update_xaddrs_with_custom_capabilities(
|
205 | 207 | 'http://www.onvif.org/ver20/imaging/wsdl': 'http://testhost/onvif/imaging_service',
|
206 | 208 | }
|
207 | 209 | mocked_device_mgmt_service.GetCapabilities.assert_not_awaited()
|
| 210 | + |
| 211 | + |
| 212 | +def test_onvif_service_with_invalid_url_type(): |
| 213 | + with pytest.raises( |
| 214 | + aonvif.exceptions.ONVIFError, |
| 215 | + match='ONVIFService url must be valid path', |
| 216 | + ): |
| 217 | + aonvif.client.ONVIFService( |
| 218 | + xaddr='http://testhost/onvif', |
| 219 | + username='test', |
| 220 | + password='password', |
| 221 | + url=object(), |
| 222 | + binding_name='ptz', |
| 223 | + ) |
| 224 | + |
| 225 | + |
| 226 | +def test_onvif_service_with_nonexistent_path(): |
| 227 | + with pytest.raises( |
| 228 | + aonvif.exceptions.ONVIFError, |
| 229 | + match='ONVIFService url must be valid path', |
| 230 | + ): |
| 231 | + aonvif.client.ONVIFService( |
| 232 | + xaddr='http://testhost/onvif', |
| 233 | + username='test', |
| 234 | + password='password', |
| 235 | + url='/tmp/nonexistent/path', |
| 236 | + binding_name='ptz', |
| 237 | + ) |
| 238 | + |
| 239 | + |
| 240 | +def test_onvif_service_ensure_wsdl_documents_cached(): |
| 241 | + client1 = aonvif.client.ONVIFCamera('testhost1', 80, 'testuser1', 'password') |
| 242 | + service1 = client1.create_devicemgmt_service() |
| 243 | + |
| 244 | + client2 = aonvif.client.ONVIFCamera('testhost2', 80, 'testuser2', 'password') |
| 245 | + service2 = client2.create_devicemgmt_service() |
| 246 | + |
| 247 | + assert isinstance(service1._client.wsdl, zeep.wsdl.Document) |
| 248 | + assert service1._client.wsdl is service2._client.wsdl |
0 commit comments