Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memorial Day API changes #6056

Merged
merged 9 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/client/datascience/notebook/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export function notebookModelToVSCNotebookData(
cells.push(new NotebookCellData(NotebookCellKind.Code, '', preferredLanguage));
}
const notebookData = new NotebookData(cells);
notebookData.metadata = { custom: notebookContentWithoutCells, trusted: isNotebookTrusted };
notebookData.metadata = { custom: notebookContentWithoutCells };
return notebookData;
}
export function cellRunStateToCellState(cellRunState?: NotebookCellRunState): CellState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class NotebookControllerManager implements INotebookControllerManager, IE
// When a document is opened we need to look for a perferred kernel for it
private onDidOpenNotebookDocument(document: NotebookDocument) {
// Restrict to only our notebook documents
if (document.notebookType !== JupyterNotebookView) {
if (document.notebookType !== JupyterNotebookView || !this.workspace.isTrusted) {
return;
}

Expand Down
158 changes: 24 additions & 134 deletions src/test/datascience/notebook/contentProviderMain.vscode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,132 +46,22 @@ suite('DataScience - VSCode Notebook ContentProvider', () => {
);
});
teardown(() => disposeAllDisposables(disposables));
[true, false].forEach((isNotebookTrusted) => {
suite(isNotebookTrusted ? 'Trusted Notebook' : 'Un-trusted notebook', () => {
test('Return notebook with 2 cells', async () => {
const model = createNotebookModel(
isNotebookTrusted,
Uri.file('any'),
instance(mock<Memento>()),
instance(mock<ICryptoUtils>()),
{
cells: [
{
cell_type: 'code',
execution_count: 10,
outputs: [],
source: 'print(1)',
metadata: {}
},
{
cell_type: 'markdown',
source: '# HEAD',
metadata: {}
}
]
}
);
when(storageProvider.getOrCreateModel(anything())).thenResolve(model);

const notebook = await contentProvider.openNotebook(fileUri, {}, new CancellationTokenSource().token);

assert.isOk(notebook);

assert.deepEqual(notebook.cells, [
DonJayamanne marked this conversation as resolved.
Show resolved Hide resolved
new NotebookCellData(
NotebookCellKind.Code,
'print(1)',
PYTHON_LANGUAGE,
[],
{
custom: {
metadata: {}
}
},
{
executionOrder: 10
}
),
new NotebookCellData(
NotebookCellKind.Markup,
'# HEAD',
MARKDOWN_LANGUAGE,
[],
{
custom: {
metadata: {}
}
}
)
]);
});

test('Return notebook with csharp language', async () => {
const model = createNotebookModel(
isNotebookTrusted,
Uri.file('any'),
instance(mock<Memento>()),
instance(mock<ICryptoUtils>()),
{
metadata: {
language_info: {
name: 'csharp'
},
orig_nbformat: 5
},
cells: [
{
cell_type: 'code',
execution_count: 10,
outputs: [],
source: 'Console.WriteLine("1")',
metadata: {}
},
{
cell_type: 'markdown',
source: '# HEAD',
metadata: {}
}
]
}
);
when(storageProvider.getOrCreateModel(anything())).thenResolve(model);

const notebook = await contentProvider.openNotebook(fileUri, {}, new CancellationTokenSource().token);

assert.isOk(notebook);

assert.deepEqual(notebook.cells, [
new NotebookCellData(
NotebookCellKind.Code,
'Console.WriteLine("1")',
'csharp',
[],
{
custom: {
metadata: {}
}
},
{
executionOrder: 10
}
),
new NotebookCellData(
NotebookCellKind.Markup,
'# HEAD',
MARKDOWN_LANGUAGE,
[],
{
custom: {
metadata: {}
}
}
)
]);
});
test('Verify mime types and order', () => {
// https://github.com/microsoft/vscode-python/issues/11880
});
test('Return notebook with 2 cells', async () => {
const model = createNotebookModel(Uri.file('any'), instance(mock<Memento>()), instance(mock<ICryptoUtils>()), {
cells: [
{
cell_type: 'code',
execution_count: 10,
outputs: [],
source: 'print(1)',
metadata: {}
},
{
cell_type: 'markdown',
source: '# HEAD',
metadata: {}
}
]
});
when(storageProvider.getOrCreateModel(anything())).thenResolve(model);

Expand All @@ -185,11 +75,11 @@ suite('DataScience - VSCode Notebook ContentProvider', () => {
'print(1)',
PYTHON_LANGUAGE,
[],
new NotebookCellMetadata().with({
{
custom: {
metadata: {}
}
}),
},
{
executionOrder: 10
}
Expand All @@ -199,11 +89,11 @@ suite('DataScience - VSCode Notebook ContentProvider', () => {
'# HEAD',
MARKDOWN_LANGUAGE,
[],
new NotebookCellMetadata().with({
{
custom: {
metadata: {}
}
})
}
)
]);
});
Expand Down Expand Up @@ -243,11 +133,11 @@ suite('DataScience - VSCode Notebook ContentProvider', () => {
'Console.WriteLine("1")',
'csharp',
[],
new NotebookCellMetadata().with({
{
custom: {
metadata: {}
}
}),
},
{
executionOrder: 10
}
Expand All @@ -257,11 +147,11 @@ suite('DataScience - VSCode Notebook ContentProvider', () => {
'# HEAD',
MARKDOWN_LANGUAGE,
[],
new NotebookCellMetadata().with({
{
custom: {
metadata: {}
}
})
}
)
]);
});
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.