<commit_before>// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { assert } from 'chai';
import * as fs from 'fs-extra';
import { sha256 } from 'hash.js';
import { shutdown } from 'log4js';
import * as nock from 'nock';
import * as path from 'path';
import { Readable } from 'stream';
import { anything, instance, mock, verify, when } from 'ts-mockito';
import { EventEmitter, Uri } from 'vscode';
import { PythonSettings } from '../../../client/common/configSettings';
import { ConfigurationService } from '../../../client/common/configuration/service';
import { HttpClient } from '../../../client/common/net/httpClient';
import { FileSystem } from '../../../client/common/platform/fileSystem';
import { IFileSystem } from '../../../client/common/platform/types';
import { IConfigurationService, IHttpClient, WidgetCDNs } from '../../../client/common/types';
import { noop } from '../../../client/common/utils/misc';
import { EXTENSION_ROOT_DIR } from '../../../client/constants';
import { CDNWidgetScriptSourceProvider } from '../../../client/datascience/ipywidgets/cdnWidgetScriptSourceProvider';
import { IPyWidgetScriptSource } from '../../../client/datascience/ipywidgets/ipyWidgetScriptSource';
import { IWidgetScriptSourceProvider } from '../../../client/datascience/ipywidgets/types';
import { JupyterNotebookBase } from '../../../client/datascience/jupyter/jupyterNotebook';
import { IJupyterConnection, ILocalResourceUriConverter, INotebook } from '../../../client/datascience/types';

// tslint:disable: no-var-requires no-require-imports max-func-body-length no-any match-default-export-name no-console
const request = require('request');
const sanitize = require('sanitize-filename');

const unpgkUrl = 'https://unpkg.com/';
const jsdelivrUrl = 'https://cdn.jsdelivr.net/npm/';

// tslint:disable: max-func-body-length no-any
suite('DataScience - ipywidget - CDN', () => {
    let scriptSourceProvider: IWidgetScriptSourceProvider;
    let notebook: INotebook;
    let configService: IConfigurationService;
    let httpClient: IHttpClient;
    let settings: PythonSettings;
    let fileSystem: IFileSystem;
    let webviewUriConverter: ILocalResourceUriConverter;
    let tempFileCount = 0;
    setup(() => {
        notebook = mock(JupyterNotebookBase);
        configService = mock(ConfigurationService);
        httpClient = mock(HttpClient);
        fileSystem = mock(FileSystem);
        webviewUriConverter = mock(IPyWidgetScriptSource);
        settings = { datascience: { widgetScriptSources: [] } } as any;
        when(configService.getSettings(anything())).thenReturn(settings as any);
        when(httpClient.downloadFile(anything())).thenCall(request);
        when(fileSystem.fileExists(anything())).thenCall((f) => fs.pathExists(f));

        when(fileSystem.createTemporaryFile(anything())).thenCall(createTemporaryFile);
        when(fileSystem.createWriteStream(anything())).thenCall((p) => fs.createWriteStream(p));
        when(fileSystem.createDirectory(anything())).thenCall((d) => fs.ensureDir(d));<commit_msg>Disable cdn tests again (#12022)<commit_after>// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { assert } from 'chai';
import * as fs from 'fs-extra';
import { sha256 } from 'hash.js';
import { shutdown } from 'log4js';
import * as nock from 'nock';
import * as path from 'path';
import { Readable } from 'stream';
import { anything, instance, mock, verify, when } from 'ts-mockito';
import { EventEmitter, Uri } from 'vscode';
import { PythonSettings } from '../../../client/common/configSettings';
import { ConfigurationService } from '../../../client/common/configuration/service';
import { HttpClient } from '../../../client/common/net/httpClient';
import { FileSystem } from '../../../client/common/platform/fileSystem';
import { IFileSystem } from '../../../client/common/platform/types';
import { IConfigurationService, IHttpClient, WidgetCDNs } from '../../../client/common/types';
import { noop } from '../../../client/common/utils/misc';
import { EXTENSION_ROOT_DIR } from '../../../client/constants';
import { CDNWidgetScriptSourceProvider } from '../../../client/datascience/ipywidgets/cdnWidgetScriptSourceProvider';
import { IPyWidgetScriptSource } from '../../../client/datascience/ipywidgets/ipyWidgetScriptSource';
import { IWidgetScriptSourceProvider } from '../../../client/datascience/ipywidgets/types';
import { JupyterNotebookBase } from '../../../client/datascience/jupyter/jupyterNotebook';
import { IJupyterConnection, ILocalResourceUriConverter, INotebook } from '../../../client/datascience/types';

// tslint:disable: no-var-requires no-require-imports max-func-body-length no-any match-default-export-name no-console
const request = require('request');
const sanitize = require('sanitize-filename');

const unpgkUrl = 'https://unpkg.com/';
const jsdelivrUrl = 'https://cdn.jsdelivr.net/npm/';

// tslint:disable: max-func-body-length no-any
suite('DataScience - ipywidget - CDN', () => {
    let scriptSourceProvider: IWidgetScriptSourceProvider;
    let notebook: INotebook;
    let configService: IConfigurationService;
    let httpClient: IHttpClient;
    let settings: PythonSettings;
    let fileSystem: IFileSystem;
    let webviewUriConverter: ILocalResourceUriConverter;
    let tempFileCount = 0;
    setup(function () {
        // Nock seems to fail randomly on CI builds. See bug
        // https://github.com/microsoft/vscode-python/issues/11442
        // tslint:disable-next-line: no-invalid-this
        this.skip();
        notebook = mock(JupyterNotebookBase);
        configService = mock(ConfigurationService);
        httpClient = mock(HttpClient);
        fileSystem = mock(FileSystem);
        webviewUriConverter = mock(IPyWidgetScriptSource);
        settings = { datascience: { widgetScriptSources: [] } } as any;
        when(configService.getSettings(anything())).thenReturn(settings as any);
        when(httpClient.downloadFile(anything())).thenCall(request);
        when(fileSystem.fileExists(anything())).thenCall((f) => fs.pathExists(f));

        when(fileSystem.createTemporaryFile(anything())).thenCall(createTemporaryFile);
        when(fileSystem.createWriteStream(anything())).thenCall((p) => fs.createWriteStream(p));
        when(fileSystem.createDirectory(anything())).thenCall((d) => fs.ensureDir(d));
{'fraction_non_alphanumeric': 0.15637155749183135, 'fraction_numerical': 0.0031118717908822156, 'mean_word_length': 4.021875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4266467', 'n_tokens_mistral': 1865, 'n_tokens_neox': 1844, 'n_words': 395}