Skip to content

Commit 441b333

Browse files
Address PR feedback: Remove copyright header and add init notebook test
- Removed Microsoft copyright header from test file - Added test to verify init notebook execution automatically when kernel starts - Test checks that hasInitNotebookBeenRun returns true for the project - Test verifies environment setup by checking sys module availability Co-Authored-By: Filip Pyrek <PyrekFilip@gmail.com>
1 parent ef1f07c commit 441b333

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/test/datascience/notebook/deepnote.vscode.test.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Copyright (c) Microsoft Corporation.
2-
// Licensed under the MIT License.
3-
41
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
52
import { assert } from 'chai';
63
import * as path from '../../../platform/vscode-path/path';
@@ -105,6 +102,33 @@ suite('Deepnote Integration Tests @kernelCore', function () {
105102
logger.debug('Test: Kernel starts for .deepnote file - completed');
106103
});
107104

105+
test('Init notebook executes automatically', async function () {
106+
logger.debug('Test: Init notebook executes automatically - starting');
107+
108+
const notebookManager = api.serviceContainer.get<IDeepnoteNotebookManager>(IDeepnoteNotebookManager);
109+
110+
notebookManager.selectNotebookForProject('test-project-id', 'main-notebook-id');
111+
112+
await workspace.openNotebookDocument(deepnoteFilePath);
113+
114+
const hasInitNotebookRun = notebookManager.hasInitNotebookBeenRun('test-project-id');
115+
assert.isTrue(hasInitNotebookRun, 'Init notebook should have been executed automatically when kernel started');
116+
117+
const cell = await notebook.appendCodeCell(
118+
'import sys; print("Init notebook executed" if "sys" in globals() else "Init notebook not executed")'
119+
);
120+
await Promise.all([kernelExecution.executeCell(cell), waitForExecutionCompletedSuccessfully(cell)]);
121+
122+
const output = getCellOutputs(cell);
123+
assert.include(
124+
output,
125+
'Init notebook executed',
126+
'Init notebook should have executed and set up the environment'
127+
);
128+
129+
logger.debug('Test: Init notebook executes automatically - completed');
130+
});
131+
108132
test('Execute code block', async function () {
109133
logger.debug('Test: Execute code block - starting');
110134

0 commit comments

Comments
 (0)