mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-15 01:24:29 +02:00
add dpkg-l tests
This commit is contained in:
1
tests/fixtures/ubuntu-18.04/dpkg-l-codes.json
vendored
Normal file
1
tests/fixtures/ubuntu-18.04/dpkg-l-codes.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"codes":"ii","name":"accountsservice","version":"0.6.45-1ubuntu1.3","architecture":"amd64","description":"query and manipulate user account information","desired":"install","status":"installed"},{"codes":"rc","name":"acl","version":"2.2.52-3build1","architecture":"amd64","description":"Access control list utilities","desired":"remove","status":"config-files"},{"codes":"uWR","name":"acpi","version":"1.7-1.1","architecture":"amd64","description":"displays information on ACPI devices","desired":"unknown","status":"trigger await","error":"reinstall required"},{"codes":"rh","name":"acpid","version":"1:2.0.28-1ubuntu1","architecture":"amd64","description":"Advanced Configuration and Power Interface event daemon","desired":"remove","status":"half installed"},{"codes":"pn","name":"adduser","version":"3.116ubuntu1","architecture":"all","description":"add and remove users and groups","desired":"purge","status":"not installed"},{"codes":"ii","name":"amd64-microcode","version":"3.20191021.1+really3","architecture":"amd64","description":"Processor microcode firmware for AMD CPUs","desired":"install","status":"installed"},{"codes":"ii","name":"apparmor","version":"2.12-4ubuntu5.1","architecture":"amd64","description":"user-space parser utility for AppArmor","desired":"install","status":"installed"},{"codes":"ii","name":"apport","version":"2.20.9-0ubuntu7.23","architecture":"all","description":"automatically generate crash reports for debugging","desired":"install","status":"installed"},{"codes":"ii","name":"apport-symptoms","version":"0.20","architecture":"all","description":"symptom scripts for apport","desired":"install","status":"installed"},{"codes":"rc","name":"linux-image-4.15.0-136-generic","version":"4.15.0-136.140","architecture":"amd64","description":"Signed kernel image generic","desired":"remove","status":"config-files"},{"codes":"ii","name":"linux-image-4.15.0-137-generic","version":"4.15.0-137.141","architecture":"amd64","description":"Signed kernel image generic","desired":"install","status":"installed"},{"codes":"ii","name":"linux-image-4.15.0-139-generic","version":"4.15.0-139.143","architecture":"amd64","description":"Signed kernel image generic","desired":"install","status":"installed"},{"codes":"ii","name":"linux-image-4.15.0-140-generic","version":"4.15.0-140.144","architecture":"amd64","description":"Signed kernel image generic","desired":"install","status":"installed"},{"codes":"rc","name":"linux-image-4.15.0-55-generic","version":"4.15.0-55.60","architecture":"amd64","description":"Signed kernel image generic","desired":"remove","status":"config-files"},{"codes":"rc","name":"linux-image-4.15.0-58-generic","version":"4.15.0-58.64","architecture":"amd64","description":"Signed kernel image generic","desired":"remove","status":"config-files"},{"codes":"rc","name":"linux-image-4.15.0-65-generic","version":"4.15.0-65.74","architecture":"amd64","description":"Signed kernel image generic","desired":"remove","status":"config-files"}]
|
1
tests/fixtures/ubuntu-18.04/dpkg-l-columns500.json
vendored
Normal file
1
tests/fixtures/ubuntu-18.04/dpkg-l-columns500.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
tests/fixtures/ubuntu-18.04/dpkg-l.json
vendored
Normal file
1
tests/fixtures/ubuntu-18.04/dpkg-l.json
vendored
Normal file
File diff suppressed because one or more lines are too long
58
tests/test_dpkg_l.py
Normal file
58
tests/test_dpkg_l.py
Normal file
@ -0,0 +1,58 @@
|
||||
import os
|
||||
import json
|
||||
import unittest
|
||||
import jc.parsers.dpkg_l
|
||||
|
||||
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/ubuntu-18.04/dpkg-l.out'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_dpkg_l = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dpkg-l-columns500.out'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_dpkg_l_columns500 = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dpkg-l-codes.out'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_dpkg_l_codes = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dpkg-l.json'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_dpkg_l_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dpkg-l-columns500.json'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_dpkg_l_columns500_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dpkg-l-codes.json'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_dpkg_l_codes_json = json.loads(f.read())
|
||||
|
||||
def test_dpkg_l_nodata(self):
|
||||
"""
|
||||
Test plain 'dpkg_l' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dpkg_l.parse('', quiet=True), [])
|
||||
|
||||
def test_dpkg_l_ubuntu_18_4(self):
|
||||
"""
|
||||
Test plain 'dpkg -l' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dpkg_l.parse(self.ubuntu_18_4_dpkg_l, quiet=True), self.ubuntu_18_4_dpkg_l_json)
|
||||
|
||||
def test_dpkg_l_columns500_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'dpkg -l' on Ubuntu 18.4 with COLUMNS=500 set
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dpkg_l.parse(self.ubuntu_18_4_dpkg_l_columns500, quiet=True), self.ubuntu_18_4_dpkg_l_columns500_json)
|
||||
|
||||
def test_dpkg_l_codes_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'dpkg -l' on Ubuntu 18.4 with multiple codes set
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dpkg_l.parse(self.ubuntu_18_4_dpkg_l_codes, quiet=True), self.ubuntu_18_4_dpkg_l_codes_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Reference in New Issue
Block a user