mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
update tests
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import json
|
||||
import unittest
|
||||
import jc.parsers.df
|
||||
|
||||
@ -8,6 +9,7 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
class MyTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
# input
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/df.out'), 'r') as f:
|
||||
self.centos_7_7_df = f.read()
|
||||
|
||||
@ -20,49 +22,42 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/df-h.out'), 'r') as f:
|
||||
self.ubuntu_18_4_df_h = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/df.json'), 'r') as f:
|
||||
self.centos_7_7_df_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/df.json'), 'r') as f:
|
||||
self.ubuntu_18_4_df_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/df-h.json'), 'r') as f:
|
||||
self.centos_7_7_df_h_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/df-h.json'), 'r') as f:
|
||||
self.ubuntu_18_4_df_h_json = json.loads(f.read())
|
||||
|
||||
def test_df_centos_7_7(self):
|
||||
"""
|
||||
Test plain 'df' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.df.parse(self.centos_7_7_df)[2], {'filesystem': 'tmpfs',
|
||||
'1k-blocks': '1930664',
|
||||
'used': '11832',
|
||||
'available': '1918832',
|
||||
'use_percent': '1%',
|
||||
'mounted': '/run'})
|
||||
self.assertEqual(jc.parsers.df.parse(self.centos_7_7_df, quiet=True), self.centos_7_7_df_json)
|
||||
|
||||
def test_df_ubuntu_18_4(self):
|
||||
"""
|
||||
Test plain 'df' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.df.parse(self.ubuntu_18_4_df)[6], {'filesystem': '/dev/loop0',
|
||||
'1k-blocks': '55936',
|
||||
'used': '55936',
|
||||
'available': '0',
|
||||
'use_percent': '100%',
|
||||
'mounted': '/snap/core18/1223'})
|
||||
self.assertEqual(jc.parsers.df.parse(self.ubuntu_18_4_df, quiet=True), self.ubuntu_18_4_df_json)
|
||||
|
||||
def test_df_h_centos_7_7(self):
|
||||
"""
|
||||
Test plain 'df -h' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.df.parse(self.centos_7_7_df_h)[4], {'filesystem': '/dev/mapper/centos-root',
|
||||
'size': '17G',
|
||||
'used': '1.8G',
|
||||
'avail': '16G',
|
||||
'use_percent': '11%',
|
||||
'mounted': '/'})
|
||||
self.assertEqual(jc.parsers.df.parse(self.centos_7_7_df_h, quiet=True), self.centos_7_7_df_h_json)
|
||||
|
||||
def test_df_h_ubuntu_18_4(self):
|
||||
"""
|
||||
Test plain 'df -h' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.df.parse(self.ubuntu_18_4_df_h)[3], {'filesystem': 'tmpfs',
|
||||
'size': '986M',
|
||||
'used': '0',
|
||||
'avail': '986M',
|
||||
'use_percent': '0%',
|
||||
'mounted': '/dev/shm'})
|
||||
self.assertEqual(jc.parsers.df.parse(self.ubuntu_18_4_df_h, quiet=True), self.ubuntu_18_4_df_h_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import json
|
||||
import unittest
|
||||
import jc.parsers.dig
|
||||
|
||||
@ -8,6 +9,7 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
class MyTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
# input
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/dig.out'), 'r') as f:
|
||||
self.centos_7_7_dig = f.read()
|
||||
|
||||
@ -26,204 +28,60 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dig-aaaa.out'), 'r') as f:
|
||||
self.ubuntu_18_4_dig_aaaa = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/dig.json'), 'r') as f:
|
||||
self.centos_7_7_dig_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dig.json'), 'r') as f:
|
||||
self.ubuntu_18_4_dig_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/dig-x.json'), 'r') as f:
|
||||
self.centos_7_7_dig_x_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dig-x.json'), 'r') as f:
|
||||
self.ubuntu_18_4_dig_x_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/dig-aaaa.json'), 'r') as f:
|
||||
self.centos_7_7_dig_aaaa_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dig-aaaa.json'), 'r') as f:
|
||||
self.ubuntu_18_4_dig_aaaa_json = json.loads(f.read())
|
||||
|
||||
def test_dig_centos_7_7(self):
|
||||
"""
|
||||
Test 'dig' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.centos_7_7_dig), [{'additional_num': '1',
|
||||
'answer': [{'class': 'IN',
|
||||
'data': 'turner-tls.map.fastly.net.',
|
||||
'name': 'www.cnn.com.',
|
||||
'ttl': '5',
|
||||
'type': 'CNAME'},
|
||||
{'class': 'IN',
|
||||
'data': '151.101.189.67',
|
||||
'name': 'turner-tls.map.fastly.net.',
|
||||
'ttl': '5',
|
||||
'type': 'A'}],
|
||||
'answer_num': '2',
|
||||
'authority_num': '0',
|
||||
'flags': 'qr rd ra',
|
||||
'id': '44295',
|
||||
'opcode': 'QUERY',
|
||||
'query_num': '1',
|
||||
'query_time': '25 msec',
|
||||
'question': {'class': 'IN', 'name': 'www.cnn.com.', 'type': 'A'},
|
||||
'rcvd': '95',
|
||||
'server': '192.168.71.2#53(192.168.71.2)',
|
||||
'status': 'NOERROR',
|
||||
'when': 'Wed Oct 30 05:13:22 PDT 2019'},
|
||||
{'additional_num': '1',
|
||||
'answer': [{'class': 'IN',
|
||||
'data': '216.58.194.100',
|
||||
'name': 'www.google.com.',
|
||||
'ttl': '5',
|
||||
'type': 'A'}],
|
||||
'answer_num': '1',
|
||||
'authority_num': '0',
|
||||
'flags': 'qr rd ra',
|
||||
'id': '34074',
|
||||
'opcode': 'QUERY',
|
||||
'query_num': '1',
|
||||
'query_time': '25 msec',
|
||||
'question': {'class': 'IN', 'name': 'www.google.com.', 'type': 'A'},
|
||||
'rcvd': '59',
|
||||
'server': '192.168.71.2#53(192.168.71.2)',
|
||||
'status': 'NOERROR',
|
||||
'when': 'Wed Oct 30 05:13:22 PDT 2019'}])
|
||||
self.assertEqual(jc.parsers.dig.parse(self.centos_7_7_dig, quiet=True), self.centos_7_7_dig_json)
|
||||
|
||||
def test_dig_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'dig' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.ubuntu_18_4_dig), [{'additional_num': '1',
|
||||
'answer': [{'class': 'IN',
|
||||
'data': 'turner-tls.map.fastly.net.',
|
||||
'name': 'www.cnn.com.',
|
||||
'ttl': '5',
|
||||
'type': 'CNAME'},
|
||||
{'class': 'IN',
|
||||
'data': '151.101.65.67',
|
||||
'name': 'turner-tls.map.fastly.net.',
|
||||
'ttl': '4',
|
||||
'type': 'A'},
|
||||
{'class': 'IN',
|
||||
'data': '151.101.1.67',
|
||||
'name': 'turner-tls.map.fastly.net.',
|
||||
'ttl': '4',
|
||||
'type': 'A'},
|
||||
{'class': 'IN',
|
||||
'data': '151.101.193.67',
|
||||
'name': 'turner-tls.map.fastly.net.',
|
||||
'ttl': '4',
|
||||
'type': 'A'},
|
||||
{'class': 'IN',
|
||||
'data': '151.101.129.67',
|
||||
'name': 'turner-tls.map.fastly.net.',
|
||||
'ttl': '4',
|
||||
'type': 'A'}],
|
||||
'answer_num': '5',
|
||||
'authority_num': '0',
|
||||
'flags': 'qr rd ra',
|
||||
'id': '52284',
|
||||
'opcode': 'QUERY',
|
||||
'query_num': '1',
|
||||
'query_time': '31 msec',
|
||||
'question': {'class': 'IN', 'name': 'www.cnn.com.', 'type': 'A'},
|
||||
'rcvd': '143',
|
||||
'server': '127.0.0.53#53(127.0.0.53)',
|
||||
'status': 'NOERROR',
|
||||
'when': 'Thu Oct 31 14:21:04 UTC 2019'},
|
||||
{'additional_num': '1',
|
||||
'answer': [{'class': 'IN',
|
||||
'data': '172.217.1.228',
|
||||
'name': 'www.google.com.',
|
||||
'ttl': '5',
|
||||
'type': 'A'}],
|
||||
'answer_num': '1',
|
||||
'authority_num': '0',
|
||||
'flags': 'qr rd ra',
|
||||
'id': '47686',
|
||||
'opcode': 'QUERY',
|
||||
'query_num': '1',
|
||||
'query_time': '32 msec',
|
||||
'question': {'class': 'IN', 'name': 'www.google.com.', 'type': 'A'},
|
||||
'rcvd': '59',
|
||||
'server': '127.0.0.53#53(127.0.0.53)',
|
||||
'status': 'NOERROR',
|
||||
'when': 'Thu Oct 31 14:21:04 UTC 2019'}])
|
||||
self.assertEqual(jc.parsers.dig.parse(self.ubuntu_18_4_dig, quiet=True), self.ubuntu_18_4_dig_json)
|
||||
|
||||
def test_dig_x_centos_7_7(self):
|
||||
"""
|
||||
Test 'dig -x' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.centos_7_7_dig_x), [{'additional_num': '1',
|
||||
'answer': [{'class': 'IN',
|
||||
'data': 'one.one.one.one.',
|
||||
'name': '1.1.1.1.in-addr.arpa.',
|
||||
'ttl': '5',
|
||||
'type': 'PTR'}],
|
||||
'answer_num': '1',
|
||||
'authority_num': '0',
|
||||
'flags': 'qr rd ra',
|
||||
'id': '36298',
|
||||
'opcode': 'QUERY',
|
||||
'query_num': '1',
|
||||
'query_time': '32 msec',
|
||||
'question': {'class': 'IN', 'name': '1.1.1.1.in-addr.arpa.', 'type': 'PTR'},
|
||||
'rcvd': '78',
|
||||
'server': '192.168.71.2#53(192.168.71.2)',
|
||||
'status': 'NOERROR',
|
||||
'when': 'Wed Oct 30 05:13:36 PDT 2019'}])
|
||||
self.assertEqual(jc.parsers.dig.parse(self.centos_7_7_dig_x, quiet=True), self.centos_7_7_dig_x_json)
|
||||
|
||||
def test_dig_x_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'dig -x' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.ubuntu_18_4_dig_x), [{'additional_num': '1',
|
||||
'answer': [{'class': 'IN',
|
||||
'data': 'one.one.one.one.',
|
||||
'name': '1.1.1.1.in-addr.arpa.',
|
||||
'ttl': '5',
|
||||
'type': 'PTR'}],
|
||||
'answer_num': '1',
|
||||
'authority_num': '0',
|
||||
'flags': 'qr rd ra',
|
||||
'id': '28514',
|
||||
'opcode': 'QUERY',
|
||||
'query_num': '1',
|
||||
'query_time': '37 msec',
|
||||
'question': {'class': 'IN', 'name': '1.1.1.1.in-addr.arpa.', 'type': 'PTR'},
|
||||
'rcvd': '78',
|
||||
'server': '127.0.0.53#53(127.0.0.53)',
|
||||
'status': 'NOERROR',
|
||||
'when': 'Thu Oct 31 14:21:05 UTC 2019'}])
|
||||
self.assertEqual(jc.parsers.dig.parse(self.ubuntu_18_4_dig_x, quiet=True), self.ubuntu_18_4_dig_x_json)
|
||||
|
||||
def test_dig_aaaa_centos_7_7(self):
|
||||
"""
|
||||
Test 'dig AAAA' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.centos_7_7_dig_aaaa), [{'additional_num': '1',
|
||||
'answer': [{'class': 'IN',
|
||||
'data': '2607:f8b0:4000:808::2004',
|
||||
'name': 'www.google.com.',
|
||||
'ttl': '5',
|
||||
'type': 'AAAA'}],
|
||||
'answer_num': '1',
|
||||
'authority_num': '0',
|
||||
'flags': 'qr rd ra',
|
||||
'id': '25779',
|
||||
'opcode': 'QUERY',
|
||||
'query_num': '1',
|
||||
'query_time': '28 msec',
|
||||
'question': {'class': 'IN', 'name': 'www.google.com.', 'type': 'AAAA'},
|
||||
'rcvd': '71',
|
||||
'server': '192.168.71.2#53(192.168.71.2)',
|
||||
'status': 'NOERROR',
|
||||
'when': 'Wed Oct 30 05:12:53 PDT 2019'}])
|
||||
self.assertEqual(jc.parsers.dig.parse(self.centos_7_7_dig_aaaa, quiet=True), self.centos_7_7_dig_aaaa_json)
|
||||
|
||||
def test_dig_aaaa_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'dig AAAA' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.ubuntu_18_4_dig_aaaa), [{'additional_num': '1',
|
||||
'answer': [{'class': 'IN',
|
||||
'data': '2607:f8b0:4000:812::2004',
|
||||
'name': 'www.google.com.',
|
||||
'ttl': '5',
|
||||
'type': 'AAAA'}],
|
||||
'answer_num': '1',
|
||||
'authority_num': '0',
|
||||
'flags': 'qr rd ra',
|
||||
'id': '45806',
|
||||
'opcode': 'QUERY',
|
||||
'query_num': '1',
|
||||
'query_time': '39 msec',
|
||||
'question': {'class': 'IN', 'name': 'www.google.com.', 'type': 'AAAA'},
|
||||
'rcvd': '71',
|
||||
'server': '127.0.0.53#53(127.0.0.53)',
|
||||
'status': 'NOERROR',
|
||||
'when': 'Thu Oct 31 14:21:04 UTC 2019'}])
|
||||
self.assertEqual(jc.parsers.dig.parse(self.ubuntu_18_4_dig_aaaa, quiet=True), self.ubuntu_18_4_dig_aaaa_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import json
|
||||
import unittest
|
||||
import jc.parsers.env
|
||||
|
||||
@ -8,23 +9,31 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
class MyTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
# input
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/env.out'), 'r') as f:
|
||||
self.centos_7_7_env = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/env.out'), 'r') as f:
|
||||
self.ubuntu_18_4_env = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/env.json'), 'r') as f:
|
||||
self.centos_7_7_env_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/env.json'), 'r') as f:
|
||||
self.ubuntu_18_4_env_json = json.loads(f.read())
|
||||
|
||||
def test_env_centos_7_7(self):
|
||||
"""
|
||||
Test 'env' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.env.parse(self.centos_7_7_env)['SSH_CONNECTION'], '192.168.71.1 58727 192.168.71.137 22')
|
||||
self.assertEqual(jc.parsers.env.parse(self.centos_7_7_env, quiet=True), self.centos_7_7_env_json)
|
||||
|
||||
def test_env_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'env' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.env.parse(self.ubuntu_18_4_env)['SSH_CONNECTION'], '192.168.71.1 65159 192.168.71.131 22')
|
||||
self.assertEqual(jc.parsers.env.parse(self.ubuntu_18_4_env, quiet=True), self.ubuntu_18_4_env_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import json
|
||||
import unittest
|
||||
import jc.parsers.free
|
||||
|
||||
@ -8,6 +9,7 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
class MyTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
# input
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/free.out'), 'r') as f:
|
||||
self.centos_7_7_free = f.read()
|
||||
|
||||
@ -20,47 +22,42 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/free-h.out'), 'r') as f:
|
||||
self.ubuntu_18_4_free_h = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/free.json'), 'r') as f:
|
||||
self.centos_7_7_free_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/free.json'), 'r') as f:
|
||||
self.ubuntu_18_4_free_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/free-h.json'), 'r') as f:
|
||||
self.centos_7_7_free_h_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/free-h.json'), 'r') as f:
|
||||
self.ubuntu_18_4_free_h_json = json.loads(f.read())
|
||||
|
||||
def test_free_centos_7_7(self):
|
||||
"""
|
||||
Test 'free' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.free.parse(self.centos_7_7_free)[1], {'type': 'Swap',
|
||||
'total': '2097148',
|
||||
'used': '0',
|
||||
'free': '2097148'})
|
||||
self.assertEqual(jc.parsers.free.parse(self.centos_7_7_free, quiet=True), self.centos_7_7_free_json)
|
||||
|
||||
def test_free_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'free' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.free.parse(self.ubuntu_18_4_free)[0], {'type': 'Mem',
|
||||
'total': '2017300',
|
||||
'used': '242740',
|
||||
'free': '478228',
|
||||
'shared': '1196',
|
||||
'buff_cache': '1296332',
|
||||
'available': '1585920'})
|
||||
self.assertEqual(jc.parsers.free.parse(self.ubuntu_18_4_free, quiet=True), self.ubuntu_18_4_free_json)
|
||||
|
||||
def test_free_h_centos_7_7(self):
|
||||
"""
|
||||
Test 'free -h' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.free.parse(self.centos_7_7_free_h)[0], {'type': 'Mem',
|
||||
'total': '3.7G',
|
||||
'used': '217M',
|
||||
'free': '3.2G',
|
||||
'shared': '11M',
|
||||
'buff_cache': '267M',
|
||||
'available': '3.2G'})
|
||||
self.assertEqual(jc.parsers.free.parse(self.centos_7_7_free_h, quiet=True), self.centos_7_7_free_h_json)
|
||||
|
||||
def test_free_h_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'free -h' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.free.parse(self.ubuntu_18_4_free_h)[1], {'type': 'Swap',
|
||||
'total': '2.0G',
|
||||
'used': '268K',
|
||||
'free': '2.0G'})
|
||||
self.assertEqual(jc.parsers.free.parse(self.ubuntu_18_4_free_h, quiet=True), self.ubuntu_18_4_free_h_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import json
|
||||
import unittest
|
||||
import jc.parsers.history
|
||||
|
||||
@ -8,23 +9,31 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
class MyTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
# input
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/history.out'), 'r') as f:
|
||||
self.centos_7_7_history = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/history.out'), 'r') as f:
|
||||
self.ubuntu_18_4_history = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/history.json'), 'r') as f:
|
||||
self.centos_7_7_history_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/history.json'), 'r') as f:
|
||||
self.ubuntu_18_4_history_json = json.loads(f.read())
|
||||
|
||||
def test_history_centos_7_7(self):
|
||||
"""
|
||||
Test 'history' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.history.parse(self.centos_7_7_history)['n658'], 'cat testing ')
|
||||
self.assertEqual(jc.parsers.history.parse(self.centos_7_7_history, quiet=True), self.centos_7_7_history_json)
|
||||
|
||||
def test_history_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'history' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.history.parse(self.ubuntu_18_4_history)['n214'], 'netstat -lp | jc --netstat')
|
||||
self.assertEqual(jc.parsers.history.parse(self.ubuntu_18_4_history, quiet=True), self.ubuntu_18_4_history_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Reference in New Issue
Block a user