From cad6dde4ac66cf970a7f52d8e7958ea35c083629 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 10 Jun 2020 17:54:06 -0700 Subject: [PATCH] fix for no data --- tests/test_group.py | 6 ++++++ tests/test_gshadow.py | 6 ++++++ tests/test_history.py | 6 ++++++ tests/test_hosts.py | 6 ++++++ tests/test_id.py | 6 ++++++ tests/test_ifconfig.py | 6 ++++++ tests/test_ini.py | 6 ++++++ tests/test_iptables.py | 6 ++++++ tests/test_jobs.py | 6 ++++++ tests/test_last.py | 6 ++++++ 10 files changed, 60 insertions(+) diff --git a/tests/test_group.py b/tests/test_group.py index b6f4755d..cf192e4f 100644 --- a/tests/test_group.py +++ b/tests/test_group.py @@ -29,6 +29,12 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/group.json'), 'r', encoding='utf-8') as f: self.osx_10_14_6_group_json = json.loads(f.read()) + def test_group_nodata(self): + """ + Test 'cat /etc/group' with no data + """ + self.assertEqual(jc.parsers.group.parse('', quiet=True), []) + def test_group_centos_7_7(self): """ Test 'cat /etc/group' on Centos 7.7 diff --git a/tests/test_gshadow.py b/tests/test_gshadow.py index 67ee525e..2a3eb7e5 100644 --- a/tests/test_gshadow.py +++ b/tests/test_gshadow.py @@ -23,6 +23,12 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/gshadow.json'), 'r', encoding='utf-8') as f: self.ubuntu_18_4_gshadow_json = json.loads(f.read()) + def test_gshadow_nodata(self): + """ + Test 'cat /etc/gshadow' with no data + """ + self.assertEqual(jc.parsers.gshadow.parse('', quiet=True), []) + def test_gshadow_centos_7_7(self): """ Test 'cat /etc/gshadow' on Centos 7.7 diff --git a/tests/test_history.py b/tests/test_history.py index d71259e5..b7cdaa8c 100644 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -23,6 +23,12 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/history.json'), 'r', encoding='utf-8') as f: self.ubuntu_18_4_history_json = json.loads(f.read()) + def test_history_nodata(self): + """ + Test 'history' with no data + """ + self.assertEqual(jc.parsers.history.parse('', quiet=True), []) + def test_history_centos_7_7(self): """ Test 'history' on Centos 7.7 diff --git a/tests/test_hosts.py b/tests/test_hosts.py index bdc071ce..2a5205bb 100644 --- a/tests/test_hosts.py +++ b/tests/test_hosts.py @@ -23,6 +23,12 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/hosts.json'), 'r', encoding='utf-8') as f: self.ubuntu_18_4_hosts_json = json.loads(f.read()) + def test_hosts_nodata(self): + """ + Test 'cat /etc/hosts' with no data + """ + self.assertEqual(jc.parsers.hosts.parse('', quiet=True), []) + def test_hosts_centos_7_7(self): """ Test 'cat /etc/hosts' on Centos 7.7 diff --git a/tests/test_id.py b/tests/test_id.py index 0f826686..d139b3bf 100644 --- a/tests/test_id.py +++ b/tests/test_id.py @@ -23,6 +23,12 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/id.json'), 'r', encoding='utf-8') as f: self.osx_10_14_6_id_json = json.loads(f.read()) + def test_id_nodata(self): + """ + Test 'id' with no data + """ + self.assertEqual(jc.parsers.id.parse('', quiet=True), {}) + def test_id_centos_7_7(self): """ Test 'id' on Centos 7.7 diff --git a/tests/test_ifconfig.py b/tests/test_ifconfig.py index 41b1bf60..8038d29d 100644 --- a/tests/test_ifconfig.py +++ b/tests/test_ifconfig.py @@ -47,6 +47,12 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/ifconfig2.json'), 'r', encoding='utf-8') as f: self.osx_10_14_6_ifconfig2_json = json.loads(f.read()) + def test_ifconfig_nodata(self): + """ + Test 'ifconfig' with no data + """ + self.assertEqual(jc.parsers.ifconfig.parse('', quiet=True), []) + def test_ifconfig_centos_7_7(self): """ Test 'ifconfig' on Centos 7.7 diff --git a/tests/test_ini.py b/tests/test_ini.py index 1a07e32e..977886e1 100644 --- a/tests/test_ini.py +++ b/tests/test_ini.py @@ -23,6 +23,12 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/ini-iptelserver.json'), 'r', encoding='utf-8') as f: self.generic_ini_iptelserver_json = json.loads(f.read()) + def test_ini_nodata(self): + """ + Test the test ini file with no data + """ + self.assertEqual(jc.parsers.ini.parse('', quiet=True), {}) + def test_ini_test(self): """ Test the test ini file diff --git a/tests/test_iptables.py b/tests/test_iptables.py index 2a325f82..148a5d73 100644 --- a/tests/test_iptables.py +++ b/tests/test_iptables.py @@ -83,6 +83,12 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/iptables-raw.json'), 'r', encoding='utf-8') as f: self.ubuntu_18_4_iptables_raw_json = json.loads(f.read()) + def test_iptables_nodata(self): + """ + Test 'sudo iptables' with no data + """ + self.assertEqual(jc.parsers.iptables.parse('', quiet=True), []) + def test_iptables_filter_centos_7_7(self): """ Test 'sudo iptables -L -t filter' on Centos 7.7 diff --git a/tests/test_jobs.py b/tests/test_jobs.py index 24f99e1f..c359b8d3 100644 --- a/tests/test_jobs.py +++ b/tests/test_jobs.py @@ -23,6 +23,12 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/jobs.json'), 'r', encoding='utf-8') as f: self.ubuntu_18_4_jobs_json = json.loads(f.read()) + def test_jobs_nodata(self): + """ + Test 'jobs' with no data + """ + self.assertEqual(jc.parsers.jobs.parse('', quiet=True), []) + def test_jobs_centos_7_7(self): """ Test 'jobs' on Centos 7.7 diff --git a/tests/test_last.py b/tests/test_last.py index 7f146786..048d9b06 100644 --- a/tests/test_last.py +++ b/tests/test_last.py @@ -65,6 +65,12 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/last.json'), 'r', encoding='utf-8') as f: self.freebsd12_last_json = json.loads(f.read()) + def test_last_nodata(self): + """ + Test plain 'last' with no data + """ + self.assertEqual(jc.parsers.last.parse('', quiet=True), []) + def test_last_centos_7_7(self): """ Test plain 'last' on Centos 7.7