def test_create(self): dev = sysfs.node('block').node(self.sd).node('device') sysfsdev = SysfsDevice(dev, subsys='block', sysfsdev_pattern='sd*') self.assertEqual(sysfsdev.device.path, join(sysfsroot, 'block/%s/device' % self.sd)) self.assertEqual(sysfsdev.sysfsnode.path, join(sysfsroot, 'block/%s/device/block/%s' % (self.sd, self.sd)))
def test_create(self): sysfsobj = SysfsObject(sysfs.node('block').node(self.sd)) self.assertEqual(sysfsobj.sysfsnode.path, join(sysfsroot, 'block/%s' % self.sd)) self.assertTrue(sysfsobj.attrs.size > 0)
def setUp(self): self.sd = str(sysfs.node('block').glob('sd*')[0])
def test_get(self): blkdevnode = sysfs.node('block').node(self.sd) self.assertIn(blkdevnode.get('removable'), ('0', '1')) self.assertRaises(KeyError, blkdevnode.get, 'dummyentry') self.assertEqual(blkdevnode.get('dummyentry', ignore_errors=True), None)
def test_node(self): blkdevnode = sysfs.node('block').node(self.sd) self.assertRaises(KeyError, blkdevnode.node, 'dummyentry') self.assertEqual(blkdevnode.node('dummyentry', default='foo'), 'foo')
def test_globfile(self): blkdevnode = sysfs.node('block').node(self.sd) self.assertTrue(blkdevnode.glob('remov*')[0], 'removable')
def test_glob(self): block = sysfs.node('block') self.assertEqual(block.path, join(sysfsroot, 'block')) sdlist = block.glob('sd*') self.assertTrue(isinstance(sdlist[0], SysfsNode)) self.assertEqual(dirname(sdlist[0].path), join(sysfsroot, 'block'))
def test_iter(self): block = sysfs.node('block') for i in block: self.assertTrue( isinstance(i, SysfsNode) or isinstance(i, (str, bytes)))