mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
version bump and add route -6 tests
This commit is contained in:
@ -1,5 +1,8 @@
|
|||||||
jc changelog
|
jc changelog
|
||||||
|
|
||||||
|
20200727 v1.13.1
|
||||||
|
- Add route -6 tests
|
||||||
|
|
||||||
20200727 v1.13.0
|
20200727 v1.13.0
|
||||||
- Add ping and ping6 command parser tested on linux, macos, and freebsd
|
- Add ping and ping6 command parser tested on linux, macos, and freebsd
|
||||||
- Add traceroute and traceroute6 command parser tested on linux, macos, and freebsd
|
- Add traceroute and traceroute6 command parser tested on linux, macos, and freebsd
|
||||||
|
@ -21,7 +21,7 @@ import jc.appdirs as appdirs
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.13.0'
|
version = '1.13.1'
|
||||||
description = 'JSON CLI output utility'
|
description = 'JSON CLI output utility'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ with open('README.md', 'r') as f:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='jc',
|
name='jc',
|
||||||
version='1.13.0',
|
version='1.13.1',
|
||||||
author='Kelly Brazil',
|
author='Kelly Brazil',
|
||||||
author_email='kellyjonbrazil@gmail.com',
|
author_email='kellyjonbrazil@gmail.com',
|
||||||
description='Converts the output of popular command-line tools and file-types to JSON.',
|
description='Converts the output of popular command-line tools and file-types to JSON.',
|
||||||
|
1
tests/fixtures/centos-7.7/route-6-n.json
vendored
Normal file
1
tests/fixtures/centos-7.7/route-6-n.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"destination": "::/96", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "0.0.0.0/96", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:a00::/24", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:7f00::/24", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:a9fe::/32", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:ac10::/28", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:c0a8::/32", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:e000::/19", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2600:1700:bab0:d40::16/128", "next_hop": "::", "flags": "U", "metric": 100, "ref": 0, "use": 0, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "2600:1700:bab0:d40::/64", "next_hop": "::", "flags": "U", "metric": 100, "ref": 1, "use": 45, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "2600:1700:bab0:d40::/60", "next_hop": "fe80::feae:34ff:fea1:3a80", "flags": "UG", "metric": 100, "ref": 0, "use": 0, "iface": "ens33", "flags_pretty": ["UP", "GATEWAY"]}, {"destination": "3ffe:ffff::/32", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "fe80::/64", "next_hop": "::", "flags": "U", "metric": 100, "ref": 0, "use": 4, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "::/0", "next_hop": "fe80::feae:34ff:fea1:3a80", "flags": "UG", "metric": 100, "ref": 1, "use": 4, "iface": "ens33", "flags_pretty": ["UP", "GATEWAY"]}, {"destination": "::/0", "next_hop": "::", "flags": "!n", "metric": -1, "ref": 1, "use": 86, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "::1/128", "next_hop": "::", "flags": "Un", "metric": 0, "ref": 2, "use": 30, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "2600:1700:bab0:d40::16/128", "next_hop": "::", "flags": "Un", "metric": 0, "ref": 2, "use": 4, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "2600:1700:bab0:d40:884b:cf32:dbd6:f640/128", "next_hop": "::", "flags": "Un", "metric": 0, "ref": 1, "use": 0, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "fe80::c1cb:715d:bc3e:b8a0/128", "next_hop": "::", "flags": "Un", "metric": 0, "ref": 2, "use": 8, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "ff00::/8", "next_hop": "::", "flags": "U", "metric": 256, "ref": 1, "use": 4, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "::/0", "next_hop": "::", "flags": "!n", "metric": -1, "ref": 1, "use": 86, "iface": "lo", "flags_pretty": ["REJECT"]}, {}]
|
24
tests/fixtures/centos-7.7/route-6-n.out
vendored
Normal file
24
tests/fixtures/centos-7.7/route-6-n.out
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
Kernel IPv6 routing table
|
||||||
|
Destination Next Hop Flag Met Ref Use If
|
||||||
|
::/96 :: !n 1024 0 0 lo
|
||||||
|
0.0.0.0/96 :: !n 1024 0 0 lo
|
||||||
|
2002:a00::/24 :: !n 1024 0 0 lo
|
||||||
|
2002:7f00::/24 :: !n 1024 0 0 lo
|
||||||
|
2002:a9fe::/32 :: !n 1024 0 0 lo
|
||||||
|
2002:ac10::/28 :: !n 1024 0 0 lo
|
||||||
|
2002:c0a8::/32 :: !n 1024 0 0 lo
|
||||||
|
2002:e000::/19 :: !n 1024 0 0 lo
|
||||||
|
2600:1700:bab0:d40::16/128 :: U 100 0 0 ens33
|
||||||
|
2600:1700:bab0:d40::/64 :: U 100 1 45 ens33
|
||||||
|
2600:1700:bab0:d40::/60 fe80::feae:34ff:fea1:3a80 UG 100 0 0 ens33
|
||||||
|
3ffe:ffff::/32 :: !n 1024 0 0 lo
|
||||||
|
fe80::/64 :: U 100 0 4 ens33
|
||||||
|
::/0 fe80::feae:34ff:fea1:3a80 UG 100 1 4 ens33
|
||||||
|
::/0 :: !n -1 1 86 lo
|
||||||
|
::1/128 :: Un 0 2 30 lo
|
||||||
|
2600:1700:bab0:d40::16/128 :: Un 0 2 4 lo
|
||||||
|
2600:1700:bab0:d40:884b:cf32:dbd6:f640/128 :: Un 0 1 0 lo
|
||||||
|
fe80::c1cb:715d:bc3e:b8a0/128 :: Un 0 2 8 lo
|
||||||
|
ff00::/8 :: U 256 1 4 ens33
|
||||||
|
::/0 :: !n -1 1 86 lo
|
||||||
|
|
1
tests/fixtures/centos-7.7/route-6.json
vendored
Normal file
1
tests/fixtures/centos-7.7/route-6.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"destination": "[::]/96", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "0.0.0.0/96", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:a00::/24", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:7f00::/24", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:a9fe::/32", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:ac10::/28", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:c0a8::/32", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:e000::/19", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "unknown000c293b580e.attlocal.net/128", "next_hop": "[::]", "flags": "U", "metric": 100, "ref": 0, "use": 0, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "2600:1700:bab0:d40::/64", "next_hop": "[::]", "flags": "U", "metric": 100, "ref": 1, "use": 43, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "2600:1700:bab0:d40::/60", "next_hop": "gateway", "flags": "UG", "metric": 100, "ref": 0, "use": 0, "iface": "ens33", "flags_pretty": ["UP", "GATEWAY"]}, {"destination": "3ffe:ffff::/32", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "fe80::/64", "next_hop": "[::]", "flags": "U", "metric": 100, "ref": 0, "use": 4, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "[::]/0", "next_hop": "gateway", "flags": "UG", "metric": 100, "ref": 1, "use": 4, "iface": "ens33", "flags_pretty": ["UP", "GATEWAY"]}, {"destination": "[::]/0", "next_hop": "[::]", "flags": "!n", "metric": -1, "ref": 1, "use": 86, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "localhost/128", "next_hop": "[::]", "flags": "Un", "metric": 0, "ref": 2, "use": 30, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "unknown000c293b580e.attlocal.net/128", "next_hop": "[::]", "flags": "Un", "metric": 0, "ref": 2, "use": 4, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "unknown000c293b580e.attlocal.net/128", "next_hop": "[::]", "flags": "Un", "metric": 0, "ref": 1, "use": 0, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "unknown000c293b580e.attlocal.net/128", "next_hop": "[::]", "flags": "Un", "metric": 0, "ref": 2, "use": 8, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "ff00::/8", "next_hop": "[::]", "flags": "U", "metric": 256, "ref": 1, "use": 4, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "[::]/0", "next_hop": "[::]", "flags": "!n", "metric": -1, "ref": 1, "use": 86, "iface": "lo", "flags_pretty": ["REJECT"]}, {}]
|
24
tests/fixtures/centos-7.7/route-6.out
vendored
Normal file
24
tests/fixtures/centos-7.7/route-6.out
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
Kernel IPv6 routing table
|
||||||
|
Destination Next Hop Flag Met Ref Use If
|
||||||
|
[::]/96 [::] !n 1024 0 0 lo
|
||||||
|
0.0.0.0/96 [::] !n 1024 0 0 lo
|
||||||
|
2002:a00::/24 [::] !n 1024 0 0 lo
|
||||||
|
2002:7f00::/24 [::] !n 1024 0 0 lo
|
||||||
|
2002:a9fe::/32 [::] !n 1024 0 0 lo
|
||||||
|
2002:ac10::/28 [::] !n 1024 0 0 lo
|
||||||
|
2002:c0a8::/32 [::] !n 1024 0 0 lo
|
||||||
|
2002:e000::/19 [::] !n 1024 0 0 lo
|
||||||
|
unknown000c293b580e.attlocal.net/128 [::] U 100 0 0 ens33
|
||||||
|
2600:1700:bab0:d40::/64 [::] U 100 1 43 ens33
|
||||||
|
2600:1700:bab0:d40::/60 gateway UG 100 0 0 ens33
|
||||||
|
3ffe:ffff::/32 [::] !n 1024 0 0 lo
|
||||||
|
fe80::/64 [::] U 100 0 4 ens33
|
||||||
|
[::]/0 gateway UG 100 1 4 ens33
|
||||||
|
[::]/0 [::] !n -1 1 86 lo
|
||||||
|
localhost/128 [::] Un 0 2 30 lo
|
||||||
|
unknown000c293b580e.attlocal.net/128 [::] Un 0 2 4 lo
|
||||||
|
unknown000c293b580e.attlocal.net/128 [::] Un 0 1 0 lo
|
||||||
|
unknown000c293b580e.attlocal.net/128 [::] Un 0 2 8 lo
|
||||||
|
ff00::/8 [::] U 256 1 4 ens33
|
||||||
|
[::]/0 [::] !n -1 1 86 lo
|
||||||
|
|
@ -25,6 +25,12 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/nixos/route-ee.out'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/nixos/route-ee.out'), 'r', encoding='utf-8') as f:
|
||||||
self.nixos_route_ee = f.read()
|
self.nixos_route_ee = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/route-6.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.centos_7_7_route_6 = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/route-6-n.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.centos_7_7_route_6_n = f.read()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/route.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/route.json'), 'r', encoding='utf-8') as f:
|
||||||
self.centos_7_7_route_json = json.loads(f.read())
|
self.centos_7_7_route_json = json.loads(f.read())
|
||||||
@ -41,6 +47,12 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/nixos/route-ee.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/nixos/route-ee.json'), 'r', encoding='utf-8') as f:
|
||||||
self.nixos_route_ee_json = json.loads(f.read())
|
self.nixos_route_ee_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/route-6.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.centos_7_7_route_6_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/route-6-n.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.centos_7_7_route_6_n_json = json.loads(f.read())
|
||||||
|
|
||||||
def test_route_nodata(self):
|
def test_route_nodata(self):
|
||||||
"""
|
"""
|
||||||
Test 'route' with no data
|
Test 'route' with no data
|
||||||
@ -77,6 +89,18 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.route.parse(self.nixos_route_ee, quiet=True), self.nixos_route_ee_json)
|
self.assertEqual(jc.parsers.route.parse(self.nixos_route_ee, quiet=True), self.nixos_route_ee_json)
|
||||||
|
|
||||||
|
def test_route_6_centos_7_7(self):
|
||||||
|
"""
|
||||||
|
Test 'route -6' on Centos 7.7
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.route.parse(self.centos_7_7_route_6, quiet=True), self.centos_7_7_route_6_json)
|
||||||
|
|
||||||
|
def test_route_6_n_centos_7_7(self):
|
||||||
|
"""
|
||||||
|
Test 'route -6 -n' on Centos 7.7
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.route.parse(self.centos_7_7_route_6_n, quiet=True), self.centos_7_7_route_6_n_json)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user