Skip to content

Commit 3eb59a4

Browse files
author
Anthony House
committed
Update data path
Signed-off-by: Anthony House <[email protected]>
1 parent 259168f commit 3eb59a4

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

tests/unit/poller/controller/sources/nautobot/test_nautobot.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33
import requests_mock
44
import urllib.parse
5+
import os
56

67
from suzieq.poller.controller.source.nautobot import Nautobot
78

@@ -24,6 +25,8 @@ def default_config() -> Dict:
2425
"""
2526
yield get_src_sample_config("nautobot")
2627

28+
_RESPONSE_DATA_DIR = "tests/unit/poller/controller/sources/nautobot/responses/"
29+
2730
_TEST_CONFIGS = [
2831
{
2932
"server_config": {
@@ -33,16 +36,16 @@ def default_config() -> Dict:
3336
},
3437
"test_params": {
3538
"test_urls": {
36-
"https://127.0.0.1:8080/api/": get_json("responses/base_response.json"),
37-
"https://127.0.0.1:8080/api/dcim/devices/": get_json("responses/all-devices.json"),
39+
"https://127.0.0.1:8080/api/": get_json(_RESPONSE_DATA_DIR + "base_response.json"),
40+
"https://127.0.0.1:8080/api/dcim/devices/": get_json(_RESPONSE_DATA_DIR + "all-devices.json"),
3841
# ang01-edge-01
39-
"https://127.0.0.1:8080/api/ipam/ip-addresses/fe06d6c1-b233-4499-b5e9-f36af5a72dc3/": get_json("responses/ang01-edge-01_ip.json"),
40-
"https://127.0.0.1:8080/api/dcim/locations/279b30b2-7aee-45be-8086-9d151ce22799/": get_json("responses/ang01-edge-01_location.json"),
42+
"https://127.0.0.1:8080/api/ipam/ip-addresses/fe06d6c1-b233-4499-b5e9-f36af5a72dc3/": get_json(_RESPONSE_DATA_DIR + "ang01-edge-01_ip.json"),
43+
"https://127.0.0.1:8080/api/dcim/locations/279b30b2-7aee-45be-8086-9d151ce22799/": get_json(_RESPONSE_DATA_DIR + "ang01-edge-01_location.json"),
4144
# azd01-leaf-07
42-
"https://127.0.0.1:8080/api/ipam/ip-addresses/94f6cbb7-2897-4b9e-91ef-573f9c0b44d8/": get_json("responses/azd01-leaf-07_ip.json"),
43-
"https://127.0.0.1:8080/api/dcim/locations/f6aa82a1-c61a-4b3e-8f4d-03e09e32feb6/": get_json("responses/azd01-leaf-07_location.json")
45+
"https://127.0.0.1:8080/api/ipam/ip-addresses/94f6cbb7-2897-4b9e-91ef-573f9c0b44d8/": get_json(_RESPONSE_DATA_DIR + "azd01-leaf-07_ip.json"),
46+
"https://127.0.0.1:8080/api/dcim/locations/f6aa82a1-c61a-4b3e-8f4d-03e09e32feb6/": get_json(_RESPONSE_DATA_DIR + "azd01-leaf-07_location.json")
4447
},
45-
"expected_result": get_json("responses/all-devices_expected.json"),
48+
"expected_result": get_json(_RESPONSE_DATA_DIR + "all-devices_expected.json"),
4649
}
4750
},
4851
{
@@ -53,16 +56,16 @@ def default_config() -> Dict:
5356
},
5457
"test_params": {
5558
"test_urls": {
56-
"https://127.0.0.1:8080/api/": get_json("responses/base_response.json"),
57-
"https://127.0.0.1:8080/api/dcim/devices/": get_json("responses/all-devices.json"),
59+
"https://127.0.0.1:8080/api/": get_json(_RESPONSE_DATA_DIR + "base_response.json"),
60+
"https://127.0.0.1:8080/api/dcim/devices/": get_json(_RESPONSE_DATA_DIR + "all-devices.json"),
5861
# ang01-edge-01
59-
"https://127.0.0.1:8080/api/ipam/ip-addresses/fe06d6c1-b233-4499-b5e9-f36af5a72dc3/": get_json("responses/ang01-edge-01_ip.json"),
60-
"https://127.0.0.1:8080/api/dcim/locations/279b30b2-7aee-45be-8086-9d151ce22799/": get_json("responses/ang01-edge-01_location.json"),
62+
"https://127.0.0.1:8080/api/ipam/ip-addresses/fe06d6c1-b233-4499-b5e9-f36af5a72dc3/": get_json(_RESPONSE_DATA_DIR + "ang01-edge-01_ip.json"),
63+
"https://127.0.0.1:8080/api/dcim/locations/279b30b2-7aee-45be-8086-9d151ce22799/": get_json(_RESPONSE_DATA_DIR + "ang01-edge-01_location.json"),
6164
# azd01-leaf-07
62-
"https://127.0.0.1:8080/api/ipam/ip-addresses/94f6cbb7-2897-4b9e-91ef-573f9c0b44d8/": get_json("responses/azd01-leaf-07_ip.json"),
63-
"https://127.0.0.1:8080/api/dcim/locations/f6aa82a1-c61a-4b3e-8f4d-03e09e32feb6/": get_json("responses/azd01-leaf-07_location.json")
65+
"https://127.0.0.1:8080/api/ipam/ip-addresses/94f6cbb7-2897-4b9e-91ef-573f9c0b44d8/": get_json(_RESPONSE_DATA_DIR + "azd01-leaf-07_ip.json"),
66+
"https://127.0.0.1:8080/api/dcim/locations/f6aa82a1-c61a-4b3e-8f4d-03e09e32feb6/": get_json(_RESPONSE_DATA_DIR + "azd01-leaf-07_location.json")
6467
},
65-
"expected_result": get_json("responses/all-devices_by_location_expected.json"),
68+
"expected_result": get_json(_RESPONSE_DATA_DIR + "all-devices_by_location_expected.json"),
6669
}
6770
},
6871
{
@@ -74,12 +77,12 @@ def default_config() -> Dict:
7477
},
7578
"test_params": {
7679
"test_urls": {
77-
"https://127.0.0.1:8080/api/": get_json("responses/base_response.json"),
78-
"https://127.0.0.1:8080/api/dcim/devices/?" + urllib.parse.urlencode({"name": "ang01-edge-01"}): get_json("responses/ang01-edge-01_device.json"),
79-
"https://127.0.0.1:8080/api/ipam/ip-addresses/fe06d6c1-b233-4499-b5e9-f36af5a72dc3/": get_json("responses/ang01-edge-01_ip.json"),
80-
"https://127.0.0.1:8080/api/dcim/locations/279b30b2-7aee-45be-8086-9d151ce22799/": get_json("responses/ang01-edge-01_location.json")
80+
"https://127.0.0.1:8080/api/": get_json(_RESPONSE_DATA_DIR + "base_response.json"),
81+
"https://127.0.0.1:8080/api/dcim/devices/?" + urllib.parse.urlencode({"name": "ang01-edge-01"}): get_json(_RESPONSE_DATA_DIR + "ang01-edge-01_device.json"),
82+
"https://127.0.0.1:8080/api/ipam/ip-addresses/fe06d6c1-b233-4499-b5e9-f36af5a72dc3/": get_json(_RESPONSE_DATA_DIR + "ang01-edge-01_ip.json"),
83+
"https://127.0.0.1:8080/api/dcim/locations/279b30b2-7aee-45be-8086-9d151ce22799/": get_json(_RESPONSE_DATA_DIR + "ang01-edge-01_location.json")
8184
},
82-
"expected_result": get_json("responses/ang01-edge-01_expected.json"),
85+
"expected_result": get_json(_RESPONSE_DATA_DIR + "ang01-edge-01_expected.json"),
8386
}
8487
},
8588
{
@@ -91,12 +94,12 @@ def default_config() -> Dict:
9194
},
9295
"test_params": {
9396
"test_urls": {
94-
"https://127.0.0.1:8080/api/": get_json("responses/base_response.json"),
95-
"https://127.0.0.1:8080/api/dcim/devices/?" + urllib.parse.urlencode({"location": "AZD01"}): get_json("responses/azd01-leaf-07_device.json"),
96-
"https://127.0.0.1:8080/api/ipam/ip-addresses/94f6cbb7-2897-4b9e-91ef-573f9c0b44d8/": get_json("responses/azd01-leaf-07_ip.json"),
97-
"https://127.0.0.1:8080/api/dcim/locations/f6aa82a1-c61a-4b3e-8f4d-03e09e32feb6/": get_json("responses/azd01-leaf-07_location.json")
97+
"https://127.0.0.1:8080/api/": get_json(_RESPONSE_DATA_DIR + "base_response.json"),
98+
"https://127.0.0.1:8080/api/dcim/devices/?" + urllib.parse.urlencode({"location": "AZD01"}): get_json(_RESPONSE_DATA_DIR + "azd01-leaf-07_device.json"),
99+
"https://127.0.0.1:8080/api/ipam/ip-addresses/94f6cbb7-2897-4b9e-91ef-573f9c0b44d8/": get_json(_RESPONSE_DATA_DIR + "azd01-leaf-07_ip.json"),
100+
"https://127.0.0.1:8080/api/dcim/locations/f6aa82a1-c61a-4b3e-8f4d-03e09e32feb6/": get_json(_RESPONSE_DATA_DIR + "azd01-leaf-07_location.json")
98101
},
99-
"expected_result": get_json("responses/azd01-leaf-07_expected.json"),
102+
"expected_result": get_json(_RESPONSE_DATA_DIR + "azd01-leaf-07_expected.json"),
100103
}
101104
},
102105
]

0 commit comments

Comments
 (0)