2
2
import pytest
3
3
import requests_mock
4
4
import urllib .parse
5
+ import os
5
6
6
7
from suzieq .poller .controller .source .nautobot import Nautobot
7
8
@@ -24,6 +25,8 @@ def default_config() -> Dict:
24
25
"""
25
26
yield get_src_sample_config ("nautobot" )
26
27
28
+ _RESPONSE_DATA_DIR = "tests/unit/poller/controller/sources/nautobot/responses/"
29
+
27
30
_TEST_CONFIGS = [
28
31
{
29
32
"server_config" : {
@@ -33,16 +36,16 @@ def default_config() -> Dict:
33
36
},
34
37
"test_params" : {
35
38
"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" ),
38
41
# 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" ),
41
44
# 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" )
44
47
},
45
- "expected_result" : get_json ("responses/ all-devices_expected.json" ),
48
+ "expected_result" : get_json (_RESPONSE_DATA_DIR + " all-devices_expected.json" ),
46
49
}
47
50
},
48
51
{
@@ -53,16 +56,16 @@ def default_config() -> Dict:
53
56
},
54
57
"test_params" : {
55
58
"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" ),
58
61
# 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" ),
61
64
# 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" )
64
67
},
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" ),
66
69
}
67
70
},
68
71
{
@@ -74,12 +77,12 @@ def default_config() -> Dict:
74
77
},
75
78
"test_params" : {
76
79
"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" )
81
84
},
82
- "expected_result" : get_json ("responses/ ang01-edge-01_expected.json" ),
85
+ "expected_result" : get_json (_RESPONSE_DATA_DIR + " ang01-edge-01_expected.json" ),
83
86
}
84
87
},
85
88
{
@@ -91,12 +94,12 @@ def default_config() -> Dict:
91
94
},
92
95
"test_params" : {
93
96
"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" )
98
101
},
99
- "expected_result" : get_json ("responses/ azd01-leaf-07_expected.json" ),
102
+ "expected_result" : get_json (_RESPONSE_DATA_DIR + " azd01-leaf-07_expected.json" ),
100
103
}
101
104
},
102
105
]
0 commit comments