1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-08-06 22:32:54 +02:00

add tests

This commit is contained in:
Kelly Brazil
2022-07-30 11:10:10 -07:00
parent ebec5c98b8
commit 0993fec114
4 changed files with 1399 additions and 0 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
[{"bus":"002","device":"002","id":"8087:8000","description":"Intel Corp. Integrated Rate Matching Hub","device_descriptor":{"bLength":{"value":"18"},"bDescriptorType":{"value":"1"},"bcdUSB":{"value":"2.00"},"bDeviceClass":{"value":"9","description":"Hub"},"bDeviceSubClass":{"value":"0"},"bDeviceProtocol":{"value":"1","description":"Single TT"},"bMaxPacketSize0":{"value":"64"},"idVendor":{"value":"0x8087","description":"Intel Corp."},"idProduct":{"value":"0x8000","description":"Integrated Rate Matching Hub"},"bcdDevice":{"value":"0.04"},"iManufacturer":{"value":"0"},"iProduct":{"value":"0"},"iSerial":{"value":"0"},"bNumConfigurations":{"value":"1"},"configuration_descriptor":{"bLength":{"value":"9"},"bDescriptorType":{"value":"2"},"wTotalLength":{"value":"0x0019"},"bNumInterfaces":{"value":"1"},"bConfigurationValue":{"value":"1"},"iConfiguration":{"value":"0"},"bmAttributes":{"value":"0xe0","attributes":["Self Powered","Remote Wakeup"]},"MaxPower":{"description":"0mA"},"interface_descriptors":[{"bLength":{"value":"9"},"bDescriptorType":{"value":"4"},"bInterfaceNumber":{"value":"0"},"bAlternateSetting":{"value":"0"},"bNumEndpoints":{"value":"1"},"bInterfaceClass":{"value":"9","description":"Hub"},"bInterfaceSubClass":{"value":"0"},"bInterfaceProtocol":{"value":"0","description":"Full speed (or root) hub"},"iInterface":{"value":"0"},"endpoint_descriptors":[{"bLength":{"value":"7"},"bDescriptorType":{"value":"5"},"bEndpointAddress":{"value":"0x81","description":"EP 1 IN"},"bmAttributes":{"value":"3","attributes":["Transfer Type Interrupt","Synch Type None","Usage Type Data"]},"wMaxPacketSize":{"value":"0x0002","description":"1x 2 bytes"},"bInterval":{"value":"12"}}]}]}},"hub_descriptor":{"bLength":{"value":"11"},"bDescriptorType":{"value":"41"},"nNbrPorts":{"value":"8"},"wHubCharacteristic":{"value":"0x0009","attributes":["Per-port power switching","Per-port overcurrent protection","TT think time 8 FS bits"]},"bPwrOn2PwrGood":{"value":"0 *","description":"2 milli seconds"},"bHubContrCurrent":{"value":"0","description":"milli Ampere"},"DeviceRemovable":{"value":"0x00","description":"0x00"},"PortPwrCtrlMask":{"value":"0xff","description":"0xff"},"hub_port_status":{"Port 1":{"value":"0000.0100","attributes":["power"]},"Port 2":{"value":"0000.0100","attributes":["power"]},"Port 3":{"value":"0000.0100","attributes":["power"]},"Port 4":{"value":"0000.0100","attributes":["power"]},"Port 5":{"value":"0000.0100","attributes":["power"]},"Port 6":{"value":"0000.0100","attributes":["power"]},"Port 7":{"value":"0000.0100","attributes":["power"]},"Port 8":{"value":"0000.0100","attributes":["power"]}}},"device_qualifier":{"bLength":{"value":"10"},"bDescriptorType":{"value":"6"},"bcdUSB":{"value":"2.00"},"bDeviceClass":{"value":"9","description":"Hub"},"bDeviceSubClass":{"value":"0"},"bDeviceProtocol":{"value":"0","description":"Full speed (or root) hub"},"bMaxPacketSize0":{"value":"64"},"bNumConfigurations":{"value":"1"}},"device_status":{"value":"0x0001","description":"Self Powered"}}]

View File

@ -29,6 +29,12 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/lsusb-t.out'), 'r', encoding='utf-8') as f:
self.generic_lsusb_t = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/lsusb-device-qualifier.out'), 'r', encoding='utf-8') as f:
self.generic_lsusb_device_qualifier = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/lsusb-binary-object-store.out'), 'r', encoding='utf-8') as f:
self.generic_lsusb_binary_object_store = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/lsusb.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_lsusb_json = json.loads(f.read())
@ -45,6 +51,12 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/lsusb-test-attributes2.json'), 'r', encoding='utf-8') as f:
self.generic_lsusb_test_attributes2_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/lsusb-device-qualifier.json'), 'r', encoding='utf-8') as f:
self.generic_lsusb_devicez_qualifier_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/lsusb-binary-object-store.json'), 'r', encoding='utf-8') as f:
self.generic_lsusb_binary_object_store_json = json.loads(f.read())
def test_lsusb_nodata(self):
"""
Test 'lsusb' with no data
@ -87,6 +99,18 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(jc.parsers.lsusb.parse(self.generic_lsusb_test_attributes2, quiet=True), self.generic_lsusb_test_attributes2_json)
def test_lsusb_device_qualifier(self):
"""
Test 'lsusb -v' with device qualifier section
"""
self.assertEqual(jc.parsers.lsusb.parse(self.generic_lsusb_device_qualifier, quiet=True), self.generic_lsusb_devicez_qualifier_json)
def test_lsusb_binary_object_store(self):
"""
Test 'lsusb -v' with binary object store section
"""
self.assertEqual(jc.parsers.lsusb.parse(self.generic_lsusb_binary_object_store, quiet=True), self.generic_lsusb_binary_object_store_json)
if __name__ == '__main__':
unittest.main()