1
0
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:
Kelly Brazil
2020-05-22 15:12:10 -07:00
parent 04f92cd133
commit 8dd9a9f9cb
5 changed files with 45 additions and 0 deletions

View File

@ -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()