@@ -263,7 +263,7 @@ suite('Data Science - Native Editor', () => {
263
263
test ( 'Create new editor and add some cells' , async ( ) => {
264
264
const editor = createEditor ( ) ;
265
265
await editor . load ( baseFile , Uri . parse ( 'file:///foo.ipynb' ) ) ;
266
- expect ( editor . contents ) . to . be . equal ( baseFile ) ;
266
+ expect ( await editor . getContents ( ) ) . to . be . equal ( baseFile ) ;
267
267
editor . onMessage ( InteractiveWindowMessages . InsertCell , { index : 0 , cell : createEmptyCell ( '1' , 1 ) } ) ;
268
268
expect ( editor . cells ) . to . be . lengthOf ( 4 ) ;
269
269
expect ( editor . isDirty ) . to . be . equal ( true , 'Editor should be dirty' ) ;
@@ -273,7 +273,7 @@ suite('Data Science - Native Editor', () => {
273
273
test ( 'Move cells around' , async ( ) => {
274
274
const editor = createEditor ( ) ;
275
275
await editor . load ( baseFile , Uri . parse ( 'file:///foo.ipynb' ) ) ;
276
- expect ( editor . contents ) . to . be . equal ( baseFile ) ;
276
+ expect ( await editor . getContents ( ) ) . to . be . equal ( baseFile ) ;
277
277
editor . onMessage ( InteractiveWindowMessages . SwapCells , { firstCellId : 'NotebookImport#0' , secondCellId : 'NotebookImport#1' } ) ;
278
278
expect ( editor . cells ) . to . be . lengthOf ( 3 ) ;
279
279
expect ( editor . isDirty ) . to . be . equal ( true , 'Editor should be dirty' ) ;
@@ -283,7 +283,7 @@ suite('Data Science - Native Editor', () => {
283
283
test ( 'Edit/delete cells' , async ( ) => {
284
284
const editor = createEditor ( ) ;
285
285
await editor . load ( baseFile , Uri . parse ( 'file:///foo.ipynb' ) ) ;
286
- expect ( editor . contents ) . to . be . equal ( baseFile ) ;
286
+ expect ( await editor . getContents ( ) ) . to . be . equal ( baseFile ) ;
287
287
expect ( editor . isDirty ) . to . be . equal ( false , 'Editor should not be dirty' ) ;
288
288
editor . onMessage ( InteractiveWindowMessages . EditCell , {
289
289
changes : [ {
@@ -313,7 +313,7 @@ suite('Data Science - Native Editor', () => {
313
313
async function loadEditorAddCellAndWaitForMementoUpdate ( file : Uri ) {
314
314
const editor = createEditor ( ) ;
315
315
await editor . load ( baseFile , file ) ;
316
- expect ( editor . contents ) . to . be . equal ( baseFile ) ;
316
+ expect ( await editor . getContents ( ) ) . to . be . equal ( baseFile ) ;
317
317
storageUpdateSpy . resetHistory ( ) ;
318
318
editor . onMessage ( InteractiveWindowMessages . InsertCell , { index : 0 , cell : createEmptyCell ( '1' , 1 ) } ) ;
319
319
expect ( editor . cells ) . to . be . lengthOf ( 4 ) ;
@@ -325,7 +325,7 @@ suite('Data Science - Native Editor', () => {
325
325
326
326
// Confirm contents were saved.
327
327
expect ( storage . get ( `notebook-storage-${ file . toString ( ) } ` ) ) . not . to . be . undefined ;
328
- expect ( editor . contents ) . not . to . be . equal ( baseFile ) ;
328
+ expect ( await editor . getContents ( ) ) . not . to . be . equal ( baseFile ) ;
329
329
330
330
return editor ;
331
331
}
@@ -359,8 +359,8 @@ suite('Data Science - Native Editor', () => {
359
359
360
360
// Verify contents are different.
361
361
// Meaning it was not loaded from file, but loaded from our storage.
362
- expect ( newEditor . contents ) . not . to . be . equal ( baseFile ) ;
363
- const notebook = JSON . parse ( newEditor . contents ) ;
362
+ expect ( await newEditor . getContents ( ) ) . not . to . be . equal ( baseFile ) ;
363
+ const notebook = JSON . parse ( await newEditor . getContents ( ) ) ;
364
364
// 4 cells (1 extra for what was added)
365
365
expect ( notebook . cells ) . to . be . lengthOf ( 4 ) ;
366
366
} ) ;
@@ -387,8 +387,8 @@ suite('Data Science - Native Editor', () => {
387
387
388
388
// Verify contents are different.
389
389
// Meaning it was not loaded from file, but loaded from our storage.
390
- expect ( newEditor . contents ) . not . to . be . equal ( baseFile ) ;
391
- const notebook = JSON . parse ( newEditor . contents ) ;
390
+ expect ( await newEditor . getContents ( ) ) . not . to . be . equal ( baseFile ) ;
391
+ const notebook = JSON . parse ( await newEditor . getContents ( ) ) ;
392
392
// 4 cells (1 extra for what was added)
393
393
expect ( notebook . cells ) . to . be . lengthOf ( 4 ) ;
394
394
} ) ;
@@ -417,18 +417,36 @@ suite('Data Science - Native Editor', () => {
417
417
418
418
// Verify contents are different.
419
419
// Meaning it was not loaded from file, but loaded from our storage.
420
- expect ( newEditor . contents ) . to . be . equal ( baseFile ) ;
420
+ expect ( await newEditor . getContents ( ) ) . to . be . equal ( baseFile ) ;
421
421
expect ( newEditor . cells ) . to . be . lengthOf ( 3 ) ;
422
422
} ) ;
423
423
424
+ test ( 'Python version info is not queried on creating a blank editor' , async ( ) => {
425
+ const file = Uri . parse ( 'file:///Untitled1.ipynb' ) ;
426
+
427
+ // When a cell is executed, then ensure we store the python version info in the notebook data.
428
+ when ( executionProvider . getUsableJupyterPython ( ) ) . thenReject ( ) ;
429
+
430
+ const editor = createEditor ( ) ;
431
+ await editor . load ( '' , file ) ;
432
+
433
+ try {
434
+ await editor . getContents ( ) ;
435
+ expect ( false , 'Did not throw an error' ) ;
436
+ } catch {
437
+ // This should throw an error
438
+ noop ( ) ;
439
+ }
440
+ } ) ;
441
+
424
442
test ( 'Pyton version info will be updated in notebook when a cell has been executed' , async ( ) => {
425
443
const file = Uri . parse ( 'file:///foo.ipynb' ) ;
426
444
427
445
const editor = createEditor ( ) ;
428
446
await editor . load ( baseFile , file ) ;
429
- expect ( editor . contents ) . to . be . equal ( baseFile ) ;
447
+ expect ( await editor . getContents ( ) ) . to . be . equal ( baseFile ) ;
430
448
// At the begining version info is NOT in the file (at least not the same as what we are using to run cells).
431
- let contents = JSON . parse ( editor . contents ) as nbformat . INotebookContent ;
449
+ let contents = JSON . parse ( await editor . getContents ( ) ) as nbformat . INotebookContent ;
432
450
expect ( contents . metadata ! . language_info ! . version ) . to . not . equal ( '10.11.12' ) ;
433
451
434
452
// When a cell is executed, then ensure we store the python version info in the notebook data.
@@ -453,7 +471,7 @@ suite('Data Science - Native Editor', () => {
453
471
} , 5_000 , 'Timeout' ) ;
454
472
455
473
// Verify the version info is in the notbook.
456
- contents = JSON . parse ( editor . contents ) as nbformat . INotebookContent ;
474
+ contents = JSON . parse ( await editor . getContents ( ) ) as nbformat . INotebookContent ;
457
475
expect ( contents . metadata ! . language_info ! . version ) . to . equal ( '10.11.12' ) ;
458
476
} ) ;
459
477
@@ -471,7 +489,7 @@ suite('Data Science - Native Editor', () => {
471
489
await editor . load ( '' , file ) ;
472
490
473
491
// It should load with that value
474
- expect ( editor . contents ) . to . be . equal ( baseFile ) ;
492
+ expect ( await editor . getContents ( ) ) . to . be . equal ( baseFile ) ;
475
493
expect ( editor . cells ) . to . be . lengthOf ( 3 ) ;
476
494
} ) ;
477
495
@@ -496,7 +514,7 @@ suite('Data Science - Native Editor', () => {
496
514
497
515
const editor = createEditor ( ) ;
498
516
await editor . load ( baseFile , file ) ;
499
- expect ( editor . contents ) . to . be . equal ( baseFile ) ;
517
+ expect ( await editor . getContents ( ) ) . to . be . equal ( baseFile ) ;
500
518
501
519
// Make our call to actually export
502
520
editor . onMessage ( InteractiveWindowMessages . Export , editor . cells ) ;
0 commit comments