def test_from_name_nonexisting_subsystem(self, a_context): with pytest.raises(DeviceNotFoundByNameError) as exc_info: Devices.from_name(a_context, 'no_such_subsystem', 'foobar') error = exc_info.value assert error.subsystem == 'no_such_subsystem' assert error.sys_name == 'foobar' assert str(error) == 'No device {0!r} in {1!r}'.format( error.sys_name, error.subsystem)
def test_from_name_is_path(self, a_context, a_device): """ Lookup using a sys_name which is actually a path should always fail. See: rhbz#1263351. """ with pytest.raises(DeviceNotFoundByNameError): Devices.from_name(a_context, a_device.subsystem, a_device.sys_name)
def test_from_name_nonexisting_subsystem(self): """ Verify that a non-existant subsystem causes an exception. """ with pytest.raises(DeviceNotFoundByNameError) as exc_info: Devices.from_name(_CONTEXT, 'no_such_subsystem', 'foobar') error = exc_info.value assert error.subsystem == 'no_such_subsystem' assert error.sys_name == 'foobar'
def test_from_name_no_device_in_existing_subsystem(self, a_context, subsys): """ Verify that a real subsystem and non-existant name causes an exception to be raised. """ with pytest.raises(DeviceNotFoundByNameError) as exc_info: Devices.from_name(a_context, subsys, 'foobar') error = exc_info.value assert error.subsystem == subsys assert error.sys_name == 'foobar'
def test_from_name(self, a_context, a_device): """ Test that getting a new device based on the name and subsystem yields an equivalent device. """ new_device = Devices.from_name(a_context, a_device.subsystem, a_device.sys_name) assert new_device == a_device
def test_from_journal_name(self, a_context, entry): """ Test that kernel subsystem combined with udev sysname yields a device. """ udev_sysname = entry['_UDEV_SYSNAME'] subsystem = entry['_KERNEL_SUBSYSTEM'] device = Devices.from_name(a_context, subsystem, udev_sysname) assert device is not None
def test_from_name(self, a_context, a_device): """ Test that getting a new device based on the name and subsystem yields an equivalent device. """ new_device = Devices.from_name( a_context, a_device.subsystem, a_device.sys_name ) assert new_device == a_device