mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
add pci-ids and udevadm tests
This commit is contained in:
1
tests/fixtures/generic/pci.ids.json
vendored
Normal file
1
tests/fixtures/generic/pci.ids.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
tests/fixtures/generic/udevadm.json
vendored
Normal file
1
tests/fixtures/generic/udevadm.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"P":"/devices/pci0000:00/0000:00:10.0/host32/target32:0:0/32:0:0:0/block/sda","N":"sda","L":0,"S":["disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0"],"E":{"DEVPATH":"/devices/pci0000:00/0000:00:10.0/host32/target32:0:0/32:0:0:0/block/sda","DEVNAME":"/dev/sda","DEVTYPE":"disk","MAJOR":"8","MINOR":"0","SUBSYSTEM":"block","USEC_INITIALIZED":"6100111","SCSI_TPGS":"0","SCSI_TYPE":"disk","SCSI_VENDOR":"VMware,","SCSI_VENDOR_ENC":"VMware,\\x20","SCSI_MODEL":"VMware_Virtual_S","SCSI_MODEL_ENC":"VMware\\x20Virtual\\x20S","SCSI_REVISION":"1.0","ID_SCSI":"1","ID_VENDOR":"VMware_","ID_VENDOR_ENC":"VMware\\x2c\\x20","ID_MODEL":"VMware_Virtual_S","ID_MODEL_ENC":"VMware\\x20Virtual\\x20S","ID_REVISION":"1.0","ID_TYPE":"disk","MPATH_SBIN_PATH":"/sbin","ID_BUS":"scsi","ID_PATH":"pci-0000:00:10.0-scsi-0:0:0:0","ID_PATH_TAG":"pci-0000_00_10_0-scsi-0_0_0_0","ID_PART_TABLE_UUID":"a5bd0c01-4210-46f2-b558-5c11c209a8f7","ID_PART_TABLE_TYPE":"gpt","DEVLINKS":"/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0","TAGS":":systemd:"}}
|
44
tests/test_pci_ids.py
Normal file
44
tests/test_pci_ids.py
Normal file
@ -0,0 +1,44 @@
|
||||
import os
|
||||
import unittest
|
||||
import json
|
||||
from typing import Dict
|
||||
import jc.parsers.pci_ids
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
f_in: Dict = {}
|
||||
f_json: Dict = {}
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
fixtures = {
|
||||
'pci_ids': (
|
||||
'fixtures/generic/pci.ids',
|
||||
'fixtures/generic/pci.ids.json')
|
||||
}
|
||||
|
||||
for file, filepaths in fixtures.items():
|
||||
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||
cls.f_in[file] = a.read()
|
||||
cls.f_json[file] = json.loads(b.read())
|
||||
|
||||
|
||||
def test_pci_ids_nodata(self):
|
||||
"""
|
||||
Test 'pci_ids' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.pci_ids.parse('', quiet=True), {})
|
||||
|
||||
def test_pci_ids(self):
|
||||
"""
|
||||
Test 'pci_ids'
|
||||
"""
|
||||
self.assertEqual(jc.parsers.pci_ids.parse(self.f_in['pci_ids'], quiet=True),
|
||||
self.f_json['pci_ids'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
44
tests/test_udevadm.py
Normal file
44
tests/test_udevadm.py
Normal file
@ -0,0 +1,44 @@
|
||||
import os
|
||||
import unittest
|
||||
import json
|
||||
from typing import Dict
|
||||
import jc.parsers.udevadm
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
f_in: Dict = {}
|
||||
f_json: Dict = {}
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
fixtures = {
|
||||
'udevadm': (
|
||||
'fixtures/generic/udevadm.out',
|
||||
'fixtures/generic/udevadm.json')
|
||||
}
|
||||
|
||||
for file, filepaths in fixtures.items():
|
||||
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||
cls.f_in[file] = a.read()
|
||||
cls.f_json[file] = json.loads(b.read())
|
||||
|
||||
|
||||
def test_udevadm_nodata(self):
|
||||
"""
|
||||
Test 'udevadm' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.udevadm.parse('', quiet=True), {})
|
||||
|
||||
def test_udevadm(self):
|
||||
"""
|
||||
Test 'udevadm'
|
||||
"""
|
||||
self.assertEqual(jc.parsers.udevadm.parse(self.f_in['udevadm'], quiet=True),
|
||||
self.f_json['udevadm'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Reference in New Issue
Block a user