Skip to content

Commit 7112944

Browse files
authored
Merge branch 'develop' into dependabot/pip/pytest-8.3.2
2 parents d931367 + 4890994 commit 7112944

File tree

68 files changed

+2424
-2695
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2424
-2695
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ docs/_static/
5959
.venv
6060
.vscode
6161
.devcontainer
62+
.python-version
6263

6364
env
6465
*.swp

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
urllib3==2.2.1 # https://github.com/readthedocs/readthedocs.org/issues/10290
1+
urllib3==2.2.2 # https://github.com/readthedocs/readthedocs.org/issues/10290
22
sphinx==7.3.7
33
sphinx-rtd-theme==2.0.0
44
invoke==2.2.0
55
jinja2==3.1.4
66
MarkupSafe==2.1.5
77
pytest==8.3.2
8-
ansible==9.6.0
8+
ansible==9.6.1

napalm/base/base.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,12 +921,23 @@ def get_ntp_servers(self) -> Dict[str, models.NTPServerDict]:
921921
"""
922922
Returns the NTP servers configuration as dictionary.
923923
The keys of the dictionary represent the IP Addresses of the servers.
924-
Inner dictionaries do not have yet any available keys.
924+
Inner dictionaries MAY contain information regarding per-server configuration.
925925
926926
Example::
927927
928928
{
929-
'192.168.0.1': {},
929+
'192.168.0.1':
930+
{
931+
'address': '192.168.0.1',
932+
'port': 123,
933+
'version': 4,
934+
'association_type': 'SERVER',
935+
'iburst': False,
936+
'prefer': False,
937+
'network_instance': 'default',
938+
'source_address': '192.0.2.1',
939+
'key_id': -1,
940+
},
930941
'17.72.148.53': {},
931942
'37.187.56.220': {},
932943
'162.158.20.18': {}

napalm/base/models.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@
188188
},
189189
)
190190

191-
BGPStateAdressFamilyDict = TypedDict(
192-
"BGPStateAdressFamilyDict",
191+
BGPStateAddressFamilyDict = TypedDict(
192+
"BGPStateAddressFamilyDict",
193193
{"received_prefixes": int, "accepted_prefixes": int, "sent_prefixes": int},
194194
)
195195

@@ -203,7 +203,7 @@
203203
"is_enabled": bool,
204204
"description": str,
205205
"uptime": int,
206-
"address_family": Dict[str, BGPStateAdressFamilyDict],
206+
"address_family": Dict[str, BGPStateAddressFamilyDict],
207207
},
208208
)
209209

@@ -223,16 +223,22 @@
223223

224224
NTPPeerDict = TypedDict(
225225
"NTPPeerDict",
226-
{
227-
# will populate it in the future wit potential keys
228-
},
226+
{},
229227
total=False,
230228
)
231229

232230
NTPServerDict = TypedDict(
233231
"NTPServerDict",
234232
{
235-
# will populate it in the future wit potential keys
233+
"address": str,
234+
"port": int,
235+
"version": int,
236+
"association_type": str,
237+
"iburst": bool,
238+
"prefer": bool,
239+
"network_instance": str,
240+
"source_address": str,
241+
"key_id": int,
236242
},
237243
total=False,
238244
)

napalm/base/test/getters.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,9 @@ def test_get_ntp_peers(self, test_case):
311311

312312
for peer, peer_details in get_ntp_peers.items():
313313
assert isinstance(peer, str)
314-
assert helpers.test_model(models.NTPPeerDict, peer_details)
314+
assert helpers.test_model(
315+
models.NTPPeerDict, peer_details, allow_subset=True
316+
)
315317

316318
return get_ntp_peers
317319

@@ -323,7 +325,9 @@ def test_get_ntp_servers(self, test_case):
323325

324326
for server, server_details in get_ntp_servers.items():
325327
assert isinstance(server, str)
326-
assert helpers.test_model(models.NTPServerDict, server_details)
328+
assert helpers.test_model(
329+
models.NTPServerDict, server_details, allow_subset=True
330+
)
327331

328332
return get_ntp_servers
329333

napalm/base/test/helpers.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
"""Several methods to help with the tests."""
22

33

4-
def test_model(model, data):
4+
def test_model(model, data, allow_subset=False):
55
"""Return if the dictionary `data` complies with the `model`."""
66
# Access the underlying schema for a TypedDict directly
7-
model = model.__annotations__
8-
same_keys = set(model.keys()) == set(data.keys())
7+
annotations = model.__annotations__
8+
if allow_subset:
9+
same_keys = set(data.keys()) <= set(annotations.keys())
10+
source = data
11+
else:
12+
same_keys = set(annotations.keys()) == set(data.keys())
13+
source = annotations
914

1015
if not same_keys:
1116
print(
1217
"model_keys: {}\ndata_keys: {}".format(
13-
sorted(model.keys()), sorted(data.keys())
18+
sorted(annotations.keys()), sorted(data.keys())
1419
)
1520
)
1621

1722
correct_class = True
18-
for key, instance_class in model.items():
19-
correct_class = isinstance(data[key], instance_class) and correct_class
23+
for key in source.keys():
24+
correct_class = isinstance(data[key], annotations[key]) and correct_class
2025
if not correct_class:
2126
print(
2227
"key: {}\nmodel_class: {}\ndata_class: {}".format(
23-
key, instance_class, data[key].__class__
28+
key, annotations[key], data[key].__class__
2429
)
2530
)
2631

0 commit comments

Comments
 (0)