mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
fix free -w parse
This commit is contained in:
@ -96,7 +96,7 @@ def _process(proc_data):
|
|||||||
|
|
||||||
List of Dictionaries. Structured data to conform to the schema.
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
"""
|
"""
|
||||||
int_list = {'total', 'used', 'free', 'shared', 'buff_cache', 'available'}
|
int_list = {'total', 'used', 'free', 'shared', 'buff_cache', 'buffers', 'cache', 'available'}
|
||||||
|
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
for key in entry:
|
for key in entry:
|
||||||
|
1
tests/fixtures/centos-7.7/free-w.json
vendored
Normal file
1
tests/fixtures/centos-7.7/free-w.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"type": "Mem", "total": 8053804, "used": 1262704, "free": 5830864, "shared": 60576, "buffers": 61596, "cache": 898640, "available": 6483996}, {"type": "Swap", "total": 2097152, "used": 0, "free": 2097152}]
|
3
tests/fixtures/centos-7.7/free-w.out
vendored
Normal file
3
tests/fixtures/centos-7.7/free-w.out
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
total used free shared buffers cache available
|
||||||
|
Mem: 8053804 1262704 5830864 60576 61596 898640 6483996
|
||||||
|
Swap: 2097152 0 2097152
|
1
tests/fixtures/ubuntu-18.04/free-w.json
vendored
Normal file
1
tests/fixtures/ubuntu-18.04/free-w.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"type": "Mem", "total": 8053804, "used": 1262704, "free": 5830864, "shared": 60576, "buffers": 61596, "cache": 898640, "available": 6483996}, {"type": "Swap", "total": 2097152, "used": 0, "free": 2097152}]
|
3
tests/fixtures/ubuntu-18.04/free-w.out
vendored
Normal file
3
tests/fixtures/ubuntu-18.04/free-w.out
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
total used free shared buffers cache available
|
||||||
|
Mem: 8053804 1262704 5830864 60576 61596 898640 6483996
|
||||||
|
Swap: 2097152 0 2097152
|
@ -22,6 +22,12 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/free-h.out'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/free-h.out'), 'r', encoding='utf-8') as f:
|
||||||
self.ubuntu_18_4_free_h = f.read()
|
self.ubuntu_18_4_free_h = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/free-w.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.centos_7_7_free_w = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/free-w.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.ubuntu_18_4_free_w = f.read()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/free.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/free.json'), 'r', encoding='utf-8') as f:
|
||||||
self.centos_7_7_free_json = json.loads(f.read())
|
self.centos_7_7_free_json = json.loads(f.read())
|
||||||
@ -35,6 +41,12 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/free-h.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/free-h.json'), 'r', encoding='utf-8') as f:
|
||||||
self.ubuntu_18_4_free_h_json = json.loads(f.read())
|
self.ubuntu_18_4_free_h_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/free-w.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.centos_7_7_free_w_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/free-w.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.ubuntu_18_4_free_w_json = json.loads(f.read())
|
||||||
|
|
||||||
def test_free_nodata(self):
|
def test_free_nodata(self):
|
||||||
"""
|
"""
|
||||||
Test 'free' with no data
|
Test 'free' with no data
|
||||||
@ -65,6 +77,18 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.free.parse(self.ubuntu_18_4_free_h, quiet=True), self.ubuntu_18_4_free_h_json)
|
self.assertEqual(jc.parsers.free.parse(self.ubuntu_18_4_free_h, quiet=True), self.ubuntu_18_4_free_h_json)
|
||||||
|
|
||||||
|
def test_free_h_centos_7_7(self):
|
||||||
|
"""
|
||||||
|
Test 'free -w' on Centos 7.7
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.free.parse(self.centos_7_7_free_w, quiet=True), self.centos_7_7_free_w_json)
|
||||||
|
|
||||||
|
def test_free_h_ubuntu_18_4(self):
|
||||||
|
"""
|
||||||
|
Test 'free -w' on Ubuntu 18.4
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.free.parse(self.ubuntu_18_4_free_w, quiet=True), self.ubuntu_18_4_free_w_json)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user