mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
add netstat -i tests
This commit is contained in:
1
tests/fixtures/centos-7.7/netstat-i.json
vendored
Normal file
1
tests/fixtures/centos-7.7/netstat-i.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"iface": "docker0", "mtu": 1500, "rx_ok": 0, "rx_err": 0, "rx_drp": 0, "rx_ovr": 0, "tx_ok": 0, "tx_err": 0, "tx_drp": 0, "tx_ovr": 0, "flg": "BMU", "kind": "interface"}, {"iface": "ens33", "mtu": 1500, "rx_ok": 476, "rx_err": 0, "rx_drp": 0, "rx_ovr": 0, "tx_ok": 312, "tx_err": 0, "tx_drp": 0, "tx_ovr": 0, "flg": "BMRU", "kind": "interface"}, {"iface": "lo", "mtu": 65536, "rx_ok": 0, "rx_err": 0, "rx_drp": 0, "rx_ovr": 0, "tx_ok": 0, "tx_err": 0, "tx_drp": 0, "tx_ovr": 0, "flg": "LRU", "kind": "interface"}]
|
1
tests/fixtures/osx-10.14.6/netstat-i.json
vendored
Normal file
1
tests/fixtures/osx-10.14.6/netstat-i.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
tests/fixtures/ubuntu-18.04/netstat-i.json
vendored
Normal file
1
tests/fixtures/ubuntu-18.04/netstat-i.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"iface": "ens33", "mtu": 1500, "rx_ok": 245, "rx_err": 0, "rx_drp": 0, "rx_ovr": 0, "tx_ok": 197, "tx_err": 0, "tx_drp": 0, "tx_ovr": 0, "flg": "BMRU", "kind": "interface"}, {"iface": "lo", "mtu": 65536, "rx_ok": 94, "rx_err": 0, "rx_drp": 0, "rx_ovr": 0, "tx_ok": 94, "tx_err": 0, "tx_drp": 0, "tx_ovr": 0, "flg": "LRU", "kind": "interface"}]
|
4
tests/fixtures/ubuntu-18.04/netstat-i.out
vendored
Normal file
4
tests/fixtures/ubuntu-18.04/netstat-i.out
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
Kernel Interface table
|
||||
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
|
||||
ens33 1500 245 0 0 0 197 0 0 0 BMRU
|
||||
lo 65536 94 0 0 0 94 0 0 0 LRU
|
@ -81,6 +81,16 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/netstat-rnl.out'), 'r', encoding='utf-8') as f:
|
||||
self.osx_14_6_netstat_rnl = f.read()
|
||||
|
||||
# netstat -i
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/netstat-i.out'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_netstat_i = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/netstat-i.out'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_netstat_i = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/netstat-i.out'), 'r', encoding='utf-8') as f:
|
||||
self.osx_14_6_netstat_i = f.read()
|
||||
|
||||
#
|
||||
# output
|
||||
#
|
||||
@ -153,6 +163,16 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/netstat-rnl.json'), 'r', encoding='utf-8') as f:
|
||||
self.osx_14_6_netstat_rnl_json = json.loads(f.read())
|
||||
|
||||
# netstat -i
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/netstat-i.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_netstat_i_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/netstat-i.json'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_netstat_i_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/netstat-i.json'), 'r', encoding='utf-8') as f:
|
||||
self.osx_14_6_netstat_i_json = json.loads(f.read())
|
||||
|
||||
def test_netstat_centos_7_7(self):
|
||||
"""
|
||||
Test 'netstat' on Centos 7.7
|
||||
@ -285,6 +305,24 @@ class MyTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(jc.parsers.netstat.parse(self.osx_14_6_netstat_rnl, quiet=True), self.osx_14_6_netstat_rnl_json)
|
||||
|
||||
def test_netstat_i_centos_7_7(self):
|
||||
"""
|
||||
Test 'netstat -i' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.netstat.parse(self.centos_7_7_netstat_i, quiet=True), self.centos_7_7_netstat_i_json)
|
||||
|
||||
def test_netstat_i_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'netstat -i' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.netstat.parse(self.ubuntu_18_4_netstat_i, quiet=True), self.ubuntu_18_4_netstat_i_json)
|
||||
|
||||
def test_netstat_i_osx_16_4(self):
|
||||
"""
|
||||
Test 'netstat -i' on OSX 16.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.netstat.parse(self.osx_14_6_netstat_i, quiet=True), self.osx_14_6_netstat_i_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user