Skip to content

Commit 1bed7bc

Browse files
authored
Fix for ASN functions (#339)
* Fixing int to asdot notation * Fixing int to asdot notation * Documentation updates for int_to_asdot * Rever table formatting in include_jinja_list.md
1 parent 565e2ba commit 1bed7bc

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

docs/user/include_jinja_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
| Filter name | Function |
22
| ---------- | ------ |
33
| asn_to_int | netutils.asn.asn_to_int |
4-
| int_to_asn | netutils.asn.int_to_asn |
4+
| int_to_asdot | netutils.asn.int_to_asdot |
55
| bits_to_name | netutils.bandwidth.bits_to_name |
66
| bytes_to_name | netutils.bandwidth.bytes_to_name |
77
| name_to_bits | netutils.bandwidth.name_to_bits |

netutils/asn.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ def asn_to_int(asplain: str) -> int:
2626
return int(asplain)
2727

2828

29-
def int_to_asn(asn_int: int) -> str:
30-
"""Convert integer to standardized asplain notation for BGP ASN.
29+
def int_to_asdot(asn_int: int) -> str:
30+
"""Convert integer to standardized asdot notation for BGP ASN.
3131
3232
Args:
3333
asn_int: Integer value of the BGP ASN.
3434
3535
Returns:
36-
`asplain` notated BGP ASN as a string.
36+
`asdot` notated BGP ASN as a string.
3737
3838
Examples:
39-
>>> from netutils.asn import int_to_asn
40-
>>> int_to_asn(65000)
39+
>>> from netutils.asn import int_to_asdot
40+
>>> int_to_asdot(65000)
4141
'65000'
42-
>>> int_to_asn(4259840111)
42+
>>> int_to_asdot(4259840111)
4343
'65000.111'
4444
>>>
4545
"""

netutils/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
_JINJA2_FUNCTION_MAPPINGS = {
77
"asn_to_int": "asn.asn_to_int",
8-
"int_to_asn": "asn.int_to_asn",
8+
"int_to_asdot": "asn.int_to_asdot",
99
"name_to_bits": "bandwidth.name_to_bits",
1010
"name_to_bytes": "bandwidth.name_to_bytes",
1111
"bits_to_name": "bandwidth.bits_to_name",

tests/unit/test_asn.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{"sent": {"asplain": "0.65526"}, "received": 65526},
1313
]
1414

15-
int_to_asn = [
15+
int_to_asdot = [
1616
{"sent": {"asn_int": 6500}, "received": "6500"},
1717
{"sent": {"asn_int": 425985111}, "received": "6500.1111"},
1818
{"sent": {"asn_int": 425984001}, "received": "6500.1"},
@@ -25,7 +25,7 @@
2525
{"sent": {"asn_int": 4294967295}, "received": "65535.65535"},
2626
]
2727

28-
int_to_asn_exceptions = [
28+
int_to_asdot_exceptions = [
2929
{"asn_int": "one22"},
3030
{"asn_int": "not_an_int"},
3131
{"asn_int": "4294967296"},
@@ -39,12 +39,12 @@ def test_asn_to_int(data):
3939
assert asn.asn_to_int(**data["sent"]) == data["received"]
4040

4141

42-
@pytest.mark.parametrize("data", int_to_asn)
43-
def test_int_to_asn(data):
44-
assert asn.int_to_asn(**data["sent"]) == data["received"]
42+
@pytest.mark.parametrize("data", int_to_asdot)
43+
def test_int_to_asdot(data):
44+
assert asn.int_to_asdot(**data["sent"]) == data["received"]
4545

4646

47-
@pytest.mark.parametrize("data", int_to_asn_exceptions)
48-
def test_int_to_asn_exceptions(data):
47+
@pytest.mark.parametrize("data", int_to_asdot_exceptions)
48+
def test_int_to_asdot_exceptions(data):
4949
with pytest.raises(ValueError):
50-
assert asn.int_to_asn(**data)
50+
assert asn.int_to_asdot(**data)

0 commit comments

Comments
 (0)