@@ -34,6 +34,10 @@ def default_config() -> Dict:
3434
3535
3636_RESPONSE_DATA_DIR = "tests/unit/poller/controller/sources/nautobot/responses/"
37+ _BASE_URL = "https://127.0.0.1:8080/api/"
38+ _DEVICES_URL = "https://127.0.0.1:8080/api/dcim/devices/"
39+ _IP_ADDRESSES_URL = "https://127.0.0.1:8080/api/ipam/ip-addresses/"
40+ _LOCATIONS_URL = "https://127.0.0.1:8080/api/dcim/locations/"
3741
3842_TEST_CONFIGS = [
3943 {
@@ -44,24 +48,26 @@ def default_config() -> Dict:
4448 },
4549 "test_params" : {
4650 "test_urls" : {
47- "https://127.0.0.1:8080/api/" : get_json (
48- _RESPONSE_DATA_DIR + "base_response.json"
49- ),
50- "https://127.0.0.1:8080/api/dcim/devices/" : get_json (
51+ _BASE_URL : get_json (_RESPONSE_DATA_DIR + "base_response.json" ),
52+ _DEVICES_URL : get_json (
5153 _RESPONSE_DATA_DIR + "all-devices.json"
5254 ),
5355 # ang01-edge-01
54- "https://127.0.0.1:8080/api/ipam/ip-addresses/fe06d6c1-b233-4499-b5e9-f36af5a72dc3/" : get_json (
56+ _IP_ADDRESSES_URL
57+ + "fe06d6c1-b233-4499-b5e9-f36af5a72dc3/" : get_json (
5558 _RESPONSE_DATA_DIR + "ang01-edge-01_ip.json"
5659 ),
57- "https://127.0.0.1:8080/api/dcim/locations/279b30b2-7aee-45be-8086-9d151ce22799/" : get_json (
60+ _LOCATIONS_URL
61+ + "279b30b2-7aee-45be-8086-9d151ce22799/" : get_json (
5862 _RESPONSE_DATA_DIR + "ang01-edge-01_location.json"
5963 ),
6064 # azd01-leaf-07
61- "https://127.0.0.1:8080/api/ipam/ip-addresses/94f6cbb7-2897-4b9e-91ef-573f9c0b44d8/" : get_json (
65+ _IP_ADDRESSES_URL
66+ + "94f6cbb7-2897-4b9e-91ef-573f9c0b44d8/" : get_json (
6267 _RESPONSE_DATA_DIR + "azd01-leaf-07_ip.json"
6368 ),
64- "https://127.0.0.1:8080/api/dcim/locations/f6aa82a1-c61a-4b3e-8f4d-03e09e32feb6/" : get_json (
69+ _LOCATIONS_URL
70+ + "f6aa82a1-c61a-4b3e-8f4d-03e09e32feb6/" : get_json (
6571 _RESPONSE_DATA_DIR + "azd01-leaf-07_location.json"
6672 ),
6773 },
@@ -78,24 +84,26 @@ def default_config() -> Dict:
7884 },
7985 "test_params" : {
8086 "test_urls" : {
81- "https://127.0.0.1:8080/api/" : get_json (
82- _RESPONSE_DATA_DIR + "base_response.json"
83- ),
84- "https://127.0.0.1:8080/api/dcim/devices/" : get_json (
87+ _BASE_URL : get_json (_RESPONSE_DATA_DIR + "base_response.json" ),
88+ _DEVICES_URL : get_json (
8589 _RESPONSE_DATA_DIR + "all-devices.json"
8690 ),
8791 # ang01-edge-01
88- "https://127.0.0.1:8080/api/ipam/ip-addresses/fe06d6c1-b233-4499-b5e9-f36af5a72dc3/" : get_json (
92+ _IP_ADDRESSES_URL
93+ + "fe06d6c1-b233-4499-b5e9-f36af5a72dc3/" : get_json (
8994 _RESPONSE_DATA_DIR + "ang01-edge-01_ip.json"
9095 ),
91- "https://127.0.0.1:8080/api/dcim/locations/279b30b2-7aee-45be-8086-9d151ce22799/" : get_json (
96+ _LOCATIONS_URL
97+ + "279b30b2-7aee-45be-8086-9d151ce22799/" : get_json (
9298 _RESPONSE_DATA_DIR + "ang01-edge-01_location.json"
9399 ),
94100 # azd01-leaf-07
95- "https://127.0.0.1:8080/api/ipam/ip-addresses/94f6cbb7-2897-4b9e-91ef-573f9c0b44d8/" : get_json (
101+ _IP_ADDRESSES_URL
102+ + "94f6cbb7-2897-4b9e-91ef-573f9c0b44d8/" : get_json (
96103 _RESPONSE_DATA_DIR + "azd01-leaf-07_ip.json"
97104 ),
98- "https://127.0.0.1:8080/api/dcim/locations/f6aa82a1-c61a-4b3e-8f4d-03e09e32feb6/" : get_json (
105+ _LOCATIONS_URL
106+ + "f6aa82a1-c61a-4b3e-8f4d-03e09e32feb6/" : get_json (
99107 _RESPONSE_DATA_DIR + "azd01-leaf-07_location.json"
100108 ),
101109 },
@@ -113,17 +121,18 @@ def default_config() -> Dict:
113121 },
114122 "test_params" : {
115123 "test_urls" : {
116- "https://127.0.0.1:8080/api/" : get_json (
117- _RESPONSE_DATA_DIR + "base_response.json"
118- ),
119- "https://127.0.0.1:8080/api/dcim/devices/?"
124+ _BASE_URL : get_json (_RESPONSE_DATA_DIR + "base_response.json" ),
125+ _DEVICES_URL
126+ + "?"
120127 + urllib .parse .urlencode ({"name" : "ang01-edge-01" }): get_json (
121128 _RESPONSE_DATA_DIR + "ang01-edge-01_device.json"
122129 ),
123- "https://127.0.0.1:8080/api/ipam/ip-addresses/fe06d6c1-b233-4499-b5e9-f36af5a72dc3/" : get_json (
130+ _IP_ADDRESSES_URL
131+ + "fe06d6c1-b233-4499-b5e9-f36af5a72dc3/" : get_json (
124132 _RESPONSE_DATA_DIR + "ang01-edge-01_ip.json"
125133 ),
126- "https://127.0.0.1:8080/api/dcim/locations/279b30b2-7aee-45be-8086-9d151ce22799/" : get_json (
134+ _LOCATIONS_URL
135+ + "279b30b2-7aee-45be-8086-9d151ce22799/" : get_json (
127136 _RESPONSE_DATA_DIR + "ang01-edge-01_location.json"
128137 ),
129138 },
@@ -141,17 +150,18 @@ def default_config() -> Dict:
141150 },
142151 "test_params" : {
143152 "test_urls" : {
144- "https://127.0.0.1:8080/api/" : get_json (
145- _RESPONSE_DATA_DIR + "base_response.json"
146- ),
147- "https://127.0.0.1:8080/api/dcim/devices/?"
153+ _BASE_URL : get_json (_RESPONSE_DATA_DIR + "base_response.json" ),
154+ _DEVICES_URL
155+ + "?"
148156 + urllib .parse .urlencode ({"location" : "AZD01" }): get_json (
149157 _RESPONSE_DATA_DIR + "azd01-leaf-07_device.json"
150158 ),
151- "https://127.0.0.1:8080/api/ipam/ip-addresses/94f6cbb7-2897-4b9e-91ef-573f9c0b44d8/" : get_json (
159+ _IP_ADDRESSES_URL
160+ + "94f6cbb7-2897-4b9e-91ef-573f9c0b44d8/" : get_json (
152161 _RESPONSE_DATA_DIR + "azd01-leaf-07_ip.json"
153162 ),
154- "https://127.0.0.1:8080/api/dcim/locations/f6aa82a1-c61a-4b3e-8f4d-03e09e32feb6/" : get_json (
163+ _LOCATIONS_URL
164+ + "f6aa82a1-c61a-4b3e-8f4d-03e09e32feb6/" : get_json (
155165 _RESPONSE_DATA_DIR + "azd01-leaf-07_location.json"
156166 ),
157167 },
@@ -193,7 +203,9 @@ def update_config(server_conf: Dict, config: Dict) -> Dict:
193203@pytest .mark .controller_source_nautobot
194204@pytest .mark .asyncio
195205@pytest .mark .parametrize ("test_conf" , _TEST_CONFIGS )
196- async def test_valid_config (test_conf , default_config ):
206+ async def test_valid_config (
207+ test_conf , default_config
208+ ): # pylint: disable=redefined-outer-name
197209 """Tests if the pulled inventory is valid
198210
199211 Args:
@@ -219,7 +231,9 @@ async def test_valid_config(test_conf, default_config):
219231@pytest .mark .controller_unit_tests
220232@pytest .mark .controller_source_nautobot
221233@pytest .mark .asyncio
222- async def test_invalid_filters (default_config ):
234+ async def test_invalid_filters (
235+ default_config ,
236+ ): # pylint: disable=redefined-outer-name
223237 """Tests for invalid filter parameters.
224238
225239 Args:
@@ -245,7 +259,8 @@ async def test_invalid_filters(default_config):
245259 with pytest .raises (InventorySourceError ) as exc_info :
246260 src = Nautobot (config .copy ())
247261 await asyncio .wait_for (src .run (), 10 )
248- assert (
249- exc_info .value .args [0 ]
250- == "nautobot0: error while getting devices: The request failed with code 400 Bad Request: {'foo': ['Unknown filter field']}"
262+ assert exc_info .value .args [0 ] == (
263+ "nautobot0: error while getting devices: "
264+ "The request failed with code 400 Bad Request: "
265+ "{'foo': ['Unknown filter field']}"
251266 )
0 commit comments