44
55import json
66from pathlib import Path
7- from typing import Any , Dict , List
7+ from typing import Any
88from unittest .mock import AsyncMock , MagicMock
99
1010import pytest
1717FIXTURES_DIR = Path (__file__ ).parent / "fixtures"
1818
1919
20- def load_fixture (filename : str ) -> Dict [str , Any ]:
21- """
22- Load a JSON fixture file.
20+ def load_fixture (filename : str ) -> dict [str , Any ]:
21+ """Load a JSON fixture file.
2322
2423 :param filename: Name of the fixture file (e.g., 'login_success.json')
2524 :return: Parsed JSON data as dict
@@ -30,45 +29,44 @@ def load_fixture(filename: str) -> Dict[str, Any]:
3029
3130
3231@pytest .fixture
33- def login_success_response () -> Dict [str , Any ]:
32+ def login_success_response () -> dict [str , Any ]:
3433 """Mock response for successful login."""
3534 return load_fixture ("login_success.json" )
3635
3736
3837@pytest .fixture
39- def login_auth_error_response () -> Dict [str , Any ]:
38+ def login_auth_error_response () -> dict [str , Any ]:
4039 """Mock response for authentication error."""
4140 return load_fixture ("login_auth_error.json" )
4241
4342
4443@pytest .fixture
45- def login_invalid_session_response () -> Dict [str , Any ]:
44+ def login_invalid_session_response () -> dict [str , Any ]:
4645 """Mock response for invalid session error."""
4746 return load_fixture ("login_invalid_session.json" )
4847
4948
5049@pytest .fixture
51- def device_info_response () -> Dict [str , Any ]:
50+ def device_info_response () -> dict [str , Any ]:
5251 """Mock response for device info query."""
5352 return load_fixture ("device_info.json" )
5453
5554
5655@pytest .fixture
57- def hosts_response () -> Dict [str , Any ]:
56+ def hosts_response () -> dict [str , Any ]:
5857 """Mock response for hosts query."""
5958 return load_fixture ("hosts.json" )
6059
6160
6261@pytest .fixture
63- def xpath_value_response () -> Dict [str , Any ]:
62+ def xpath_value_response () -> dict [str , Any ]:
6463 """Mock response for generic XPath getValue."""
6564 return load_fixture ("xpath_value.json" )
6665
6766
6867@pytest .fixture
6968def mock_session_factory ():
70- """
71- Factory fixture for creating mock aiohttp ClientSession.
69+ """Factory fixture for creating mock aiohttp ClientSession.
7270
7371 Returns a factory function that creates a mock session with configurable responses.
7472 Mock responses are consumed in sequence (first call gets first response, etc.).
@@ -80,9 +78,8 @@ def mock_session_factory():
8078 :return: Factory function that takes list of response dicts
8179 """
8280
83- def _create_mock_session (responses : List [Dict [str , Any ]]) -> ClientSession :
84- """
85- Create a mock ClientSession with specified responses.
81+ def _create_mock_session (responses : list [dict [str , Any ]]) -> ClientSession :
82+ """Create a mock ClientSession with specified responses.
8683
8784 :param responses: List of response dictionaries to return in sequence
8885 :return: Mock ClientSession
@@ -120,8 +117,7 @@ def _create_mock_session(responses: List[Dict[str, Any]]) -> ClientSession:
120117
121118@pytest .fixture
122119def mock_client_md5 (mock_session_factory , login_success_response ):
123- """
124- Create a SagemcomClient with MD5 encryption and mocked session.
120+ """Create a SagemcomClient with MD5 encryption and mocked session.
125121
126122 Pre-configured with successful login response.
127123
@@ -139,8 +135,7 @@ def mock_client_md5(mock_session_factory, login_success_response):
139135
140136@pytest .fixture
141137def mock_client_sha512 (mock_session_factory , login_success_response ):
142- """
143- Create a SagemcomClient with SHA512 encryption and mocked session.
138+ """Create a SagemcomClient with SHA512 encryption and mocked session.
144139
145140 Pre-configured with successful login response.
146141
@@ -158,8 +153,7 @@ def mock_client_sha512(mock_session_factory, login_success_response):
158153
159154@pytest .fixture
160155def mock_client_md5_nonce (mock_session_factory , login_success_response ):
161- """
162- Create a SagemcomClient with MD5_NONCE encryption and mocked session.
156+ """Create a SagemcomClient with MD5_NONCE encryption and mocked session.
163157
164158 Pre-configured with successful login response.
165159
0 commit comments