def setup_install_source_task_failure_test(self, mount_mock): """Test NFS source setup failure""" task = SetUpNFSSourceTask(mount_location, nfs_url) with self.assertRaises(PayloadSetupError): task.run() mount_mock.assert_called_once_with(nfs_address, mount_location, fstype="nfs", options="nolock")
def test_setup_install_source_task_mount_failure(self, mount_mock): """Test NFS source setup failure""" task = SetUpNFSSourceTask(DEVICE_MOUNT_LOCATION, ISO_MOUNT_LOCATION, NFS_URL) with pytest.raises(SourceSetupError): task.run() mount_mock.assert_called_once_with(NFS_ADDRESS, DEVICE_MOUNT_LOCATION, fstype="nfs", options="nolock")
def test_setup_install_source_task_success_options( self, mount_mock, find_and_mount_iso_image_mock): """Test NFS source setup handling nolock in options""" task = SetUpNFSSourceTask(DEVICE_MOUNT_LOCATION, ISO_MOUNT_LOCATION, "nfs:some-option,nolock:" + NFS_ADDRESS) task.run() mount_mock.assert_called_with(NFS_ADDRESS, DEVICE_MOUNT_LOCATION, fstype="nfs", options="some-option,nolock") find_and_mount_iso_image_mock.assert_called_once_with( DEVICE_MOUNT_LOCATION, ISO_MOUNT_LOCATION)
def setup_install_source_task_success_options_test( self, mount_mock, find_and_mount_iso_image_mock): """Test NFS source setup handling nolock in options""" task = SetUpNFSSourceTask(device_mount_location, iso_mount_location, "nfs:some-option,nolock:" + nfs_address) task.run() mount_mock.assert_called_with(nfs_address, device_mount_location, fstype="nfs", options="some-option,nolock") find_and_mount_iso_image_mock.assert_called_once_with( device_mount_location, iso_mount_location)
def test_setup_install_source_task_find_anything_failure( self, mount_mock, find_and_mount_iso_image_mock, verify_valid_repository_mock, unmount_mock): """Test NFS can't find anything to install from""" task = SetUpNFSSourceTask(DEVICE_MOUNT_LOCATION, ISO_MOUNT_LOCATION, NFS_URL) with pytest.raises(SourceSetupError): task.run() mount_mock.assert_called_once_with(NFS_ADDRESS, DEVICE_MOUNT_LOCATION, fstype="nfs", options="nolock") find_and_mount_iso_image_mock.assert_called_once_with( DEVICE_MOUNT_LOCATION, ISO_MOUNT_LOCATION) verify_valid_repository_mock.assert_called_once_with( DEVICE_MOUNT_LOCATION) unmount_mock.assert_called_once_with(DEVICE_MOUNT_LOCATION)
def setup_install_source_task_find_anything_failure_test( self, mount_mock, find_and_mount_iso_image_mock, verify_valid_installtree_mock, unmount_mock): """Test NFS can't find anything to install from""" task = SetUpNFSSourceTask(device_mount_location, iso_mount_location, nfs_url) with self.assertRaises(SourceSetupError): task.run() mount_mock.assert_called_once_with(nfs_address, device_mount_location, fstype="nfs", options="nolock") find_and_mount_iso_image_mock.assert_called_once_with( device_mount_location, iso_mount_location) verify_valid_installtree_mock.assert_called_once_with( device_mount_location) unmount_mock.assert_called_once_with(device_mount_location)
def _set_up_additional_repository(self, data): """Set up sources for the additional repository.""" # Check the validity of the repository. if not data.url: msg = "The '{}' repository has no mirror, baseurl or metalink set." raise SourceSetupError(msg.format(data.name)) from None # Set up the NFS source with a substituted URL. elif data.url.startswith("nfs://"): device_mount = self._create_mount_point(constants.MOUNT_DIR, data.name + "-nfs-device") iso_mount = self._create_mount_point(constants.MOUNT_DIR, data.name + "-nfs-iso") task = SetUpNFSSourceTask(device_mount=device_mount, iso_mount=iso_mount, url=self._dnf_manager.substitute( data.url)) mount_point = task.run() data.url = "file://" + mount_point # Set up the HDD source. elif data.url.startswith("hd:"): device_mount = self._create_mount_point(ISO_DIR + "-" + data.name + "-hdd-device") iso_mount = self._create_mount_point(INSTALL_TREE + "-" + data.name + "-hdd-iso") partition, directory = parse_hdd_url(data.url) task = SetUpHardDriveSourceTask( device_mount=device_mount, iso_mount=iso_mount, partition=partition, directory=directory, ) result = task.run() data.url = "file://" + result.install_tree_path