@@ -687,7 +687,7 @@ suite('DeepnoteEnvironmentsView', () => {
687687 } ) ;
688688 } ) ;
689689
690- suite ( 'startServer' , ( ) => {
690+ suite ( 'Server Management ( startServer, stopServer, restartServer) ' , ( ) => {
691691 const testEnvironmentId = 'test-env-id' ;
692692 const testInterpreter : PythonEnvironment = {
693693 id : 'test-python-id' ,
@@ -707,11 +707,9 @@ suite('DeepnoteEnvironmentsView', () => {
707707 setup ( ( ) => {
708708 resetCalls ( mockConfigManager ) ;
709709 resetCalls ( mockedVSCodeNamespaces . window ) ;
710- } ) ;
711710
712- test ( 'should call environmentManager.startServer' , async ( ) => {
711+ // Common mocks for all server management operations
713712 when ( mockConfigManager . getEnvironment ( testEnvironmentId ) ) . thenReturn ( testEnvironment ) ;
714- when ( mockConfigManager . startServer ( testEnvironmentId , anything ( ) ) ) . thenResolve ( ) ;
715713
716714 when ( mockedVSCodeNamespaces . window . withProgress ( anything ( ) , anything ( ) ) ) . thenCall (
717715 ( _options : ProgressOptions , callback : Function ) => {
@@ -733,113 +731,27 @@ suite('DeepnoteEnvironmentsView', () => {
733731 ) ;
734732
735733 when ( mockedVSCodeNamespaces . window . showInformationMessage ( anything ( ) ) ) . thenResolve ( undefined ) ;
736-
737- await ( view as any ) . startServer ( testEnvironmentId ) ;
738-
739- verify ( mockConfigManager . startServer ( testEnvironmentId , anything ( ) ) ) . once ( ) ;
740734 } ) ;
741- } ) ;
742735
743- suite ( 'stopServer' , ( ) => {
744- const testEnvironmentId = 'test-env-id' ;
745- const testInterpreter : PythonEnvironment = {
746- id : 'test-python-id' ,
747- uri : Uri . file ( '/usr/bin/python3' ) ,
748- version : { major : 3 , minor : 11 , patch : 0 , raw : '3.11.0' }
749- } as PythonEnvironment ;
736+ test ( 'should call environmentManager.startServer' , async ( ) => {
737+ when ( mockConfigManager . startServer ( testEnvironmentId , anything ( ) ) ) . thenResolve ( ) ;
750738
751- const testEnvironment : DeepnoteEnvironment = {
752- id : testEnvironmentId ,
753- name : 'Test Environment' ,
754- pythonInterpreter : testInterpreter ,
755- venvPath : Uri . file ( '/path/to/venv' ) ,
756- createdAt : new Date ( ) ,
757- lastUsedAt : new Date ( )
758- } ;
739+ await ( view as any ) . startServer ( testEnvironmentId ) ;
759740
760- setup ( ( ) => {
761- resetCalls ( mockConfigManager ) ;
762- resetCalls ( mockedVSCodeNamespaces . window ) ;
741+ verify ( mockConfigManager . startServer ( testEnvironmentId , anything ( ) ) ) . once ( ) ;
763742 } ) ;
764743
765744 test ( 'should call environmentManager.stopServer' , async ( ) => {
766- when ( mockConfigManager . getEnvironment ( testEnvironmentId ) ) . thenReturn ( testEnvironment ) ;
767745 when ( mockConfigManager . stopServer ( testEnvironmentId , anything ( ) ) ) . thenResolve ( ) ;
768746
769- when ( mockedVSCodeNamespaces . window . withProgress ( anything ( ) , anything ( ) ) ) . thenCall (
770- ( _options : ProgressOptions , callback : Function ) => {
771- const mockProgress = {
772- report : ( ) => {
773- // Mock progress reporting
774- }
775- } ;
776- const mockToken : CancellationToken = {
777- isCancellationRequested : false ,
778- onCancellationRequested : ( ) => ( {
779- dispose : ( ) => {
780- // Mock disposable
781- }
782- } )
783- } ;
784- return callback ( mockProgress , mockToken ) ;
785- }
786- ) ;
787-
788- when ( mockedVSCodeNamespaces . window . showInformationMessage ( anything ( ) ) ) . thenResolve ( undefined ) ;
789-
790747 await ( view as any ) . stopServer ( testEnvironmentId ) ;
791748
792749 verify ( mockConfigManager . stopServer ( testEnvironmentId , anything ( ) ) ) . once ( ) ;
793750 } ) ;
794- } ) ;
795-
796- suite ( 'restartServer' , ( ) => {
797- const testEnvironmentId = 'test-env-id' ;
798- const testInterpreter : PythonEnvironment = {
799- id : 'test-python-id' ,
800- uri : Uri . file ( '/usr/bin/python3' ) ,
801- version : { major : 3 , minor : 11 , patch : 0 , raw : '3.11.0' }
802- } as PythonEnvironment ;
803-
804- const testEnvironment : DeepnoteEnvironment = {
805- id : testEnvironmentId ,
806- name : 'Test Environment' ,
807- pythonInterpreter : testInterpreter ,
808- venvPath : Uri . file ( '/path/to/venv' ) ,
809- createdAt : new Date ( ) ,
810- lastUsedAt : new Date ( )
811- } ;
812-
813- setup ( ( ) => {
814- resetCalls ( mockConfigManager ) ;
815- resetCalls ( mockedVSCodeNamespaces . window ) ;
816- } ) ;
817751
818752 test ( 'should call environmentManager.restartServer' , async ( ) => {
819- when ( mockConfigManager . getEnvironment ( testEnvironmentId ) ) . thenReturn ( testEnvironment ) ;
820753 when ( mockConfigManager . restartServer ( testEnvironmentId , anything ( ) ) ) . thenResolve ( ) ;
821754
822- when ( mockedVSCodeNamespaces . window . withProgress ( anything ( ) , anything ( ) ) ) . thenCall (
823- ( _options : ProgressOptions , callback : Function ) => {
824- const mockProgress = {
825- report : ( ) => {
826- // Mock progress reporting
827- }
828- } ;
829- const mockToken : CancellationToken = {
830- isCancellationRequested : false ,
831- onCancellationRequested : ( ) => ( {
832- dispose : ( ) => {
833- // Mock disposable
834- }
835- } )
836- } ;
837- return callback ( mockProgress , mockToken ) ;
838- }
839- ) ;
840-
841- when ( mockedVSCodeNamespaces . window . showInformationMessage ( anything ( ) ) ) . thenResolve ( undefined ) ;
842-
843755 await ( view as any ) . restartServer ( testEnvironmentId ) ;
844756
845757 verify ( mockConfigManager . restartServer ( testEnvironmentId , anything ( ) ) ) . once ( ) ;
0 commit comments