def test_scvmm_detection_without_file(self):
        # setup
        conf.get_dvd_mount_point = Mock(return_value=self.tmp_dir)
        conf.get_detect_scvmm_env = Mock(return_value=True)
        scvmm_file = os.path.join(self.tmp_dir, scvmm.VMM_CONF_FILE_NAME)
        if os.path.exists(scvmm_file):
            os.remove(scvmm_file)

        with mock.patch.object(scvmm.ScvmmHandler,
                               'start_scvmm_agent') as patch_start:
            # execute
            scvmm.ScvmmHandler().detect_scvmm_env()
            # assert
            patch_start.assert_not_called()
    def test_scvmm_detection_with_multiple_cdroms(self):
        # setup
        conf.get_dvd_mount_point = Mock(return_value=self.tmp_dir)
        conf.get_detect_scvmm_env = Mock(return_value=True)

        # execute
        with mock.patch.object(DefaultOSUtil, 'mount_dvd') as patch_mount:
            with patch('os.listdir', return_value=["sr0", "sr1", "sr2"]):
                scvmm.ScvmmHandler().detect_scvmm_env()
                # assert
                assert patch_mount.call_count == 3
                assert patch_mount.call_args_list[0][1][
                    'dvd_device'] == '/dev/sr0'
                assert patch_mount.call_args_list[1][1][
                    'dvd_device'] == '/dev/sr1'
                assert patch_mount.call_args_list[2][1][
                    'dvd_device'] == '/dev/sr2'