@@ -686,4 +686,212 @@ suite('DeepnoteEnvironmentsView', () => {
686686 verify ( mockedVSCodeNamespaces . window . showInformationMessage ( anything ( ) ) ) . once ( ) ;
687687 } ) ;
688688 } ) ;
689+
690+ suite ( 'startServer' , ( ) => {
691+ const testEnvironmentId = 'test-env-id' ;
692+ const testInterpreter : PythonEnvironment = {
693+ id : 'test-python-id' ,
694+ uri : Uri . file ( '/usr/bin/python3' ) ,
695+ version : { major : 3 , minor : 11 , patch : 0 , raw : '3.11.0' }
696+ } as PythonEnvironment ;
697+
698+ const testEnvironment : DeepnoteEnvironment = {
699+ id : testEnvironmentId ,
700+ name : 'Test Environment' ,
701+ pythonInterpreter : testInterpreter ,
702+ venvPath : Uri . file ( '/path/to/venv' ) ,
703+ createdAt : new Date ( ) ,
704+ lastUsedAt : new Date ( )
705+ } ;
706+
707+ setup ( ( ) => {
708+ resetCalls ( mockConfigManager ) ;
709+ resetCalls ( mockedVSCodeNamespaces . window ) ;
710+ } ) ;
711+
712+ test ( 'should call environmentManager.startServer' , async ( ) => {
713+ when ( mockConfigManager . getEnvironment ( testEnvironmentId ) ) . thenReturn ( testEnvironment ) ;
714+ when ( mockConfigManager . startServer ( testEnvironmentId , anything ( ) ) ) . thenResolve ( ) ;
715+
716+ when ( mockedVSCodeNamespaces . window . withProgress ( anything ( ) , anything ( ) ) ) . thenCall (
717+ ( _options : ProgressOptions , callback : Function ) => {
718+ const mockProgress = {
719+ report : ( ) => {
720+ // Mock progress reporting
721+ }
722+ } ;
723+ const mockToken : CancellationToken = {
724+ isCancellationRequested : false ,
725+ onCancellationRequested : ( ) => ( {
726+ dispose : ( ) => {
727+ // Mock disposable
728+ }
729+ } )
730+ } ;
731+ return callback ( mockProgress , mockToken ) ;
732+ }
733+ ) ;
734+
735+ when ( mockedVSCodeNamespaces . window . showInformationMessage ( anything ( ) ) ) . thenResolve ( undefined ) ;
736+
737+ await ( view as any ) . startServer ( testEnvironmentId ) ;
738+
739+ verify ( mockConfigManager . startServer ( testEnvironmentId , anything ( ) ) ) . once ( ) ;
740+ } ) ;
741+ } ) ;
742+
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 ;
750+
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+ } ;
759+
760+ setup ( ( ) => {
761+ resetCalls ( mockConfigManager ) ;
762+ resetCalls ( mockedVSCodeNamespaces . window ) ;
763+ } ) ;
764+
765+ test ( 'should call environmentManager.stopServer' , async ( ) => {
766+ when ( mockConfigManager . getEnvironment ( testEnvironmentId ) ) . thenReturn ( testEnvironment ) ;
767+ when ( mockConfigManager . stopServer ( testEnvironmentId , anything ( ) ) ) . thenResolve ( ) ;
768+
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+
790+ await ( view as any ) . stopServer ( testEnvironmentId ) ;
791+
792+ verify ( mockConfigManager . stopServer ( testEnvironmentId , anything ( ) ) ) . once ( ) ;
793+ } ) ;
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+ } ) ;
817+
818+ test ( 'should call environmentManager.restartServer' , async ( ) => {
819+ when ( mockConfigManager . getEnvironment ( testEnvironmentId ) ) . thenReturn ( testEnvironment ) ;
820+ when ( mockConfigManager . restartServer ( testEnvironmentId , anything ( ) ) ) . thenResolve ( ) ;
821+
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+
843+ await ( view as any ) . restartServer ( testEnvironmentId ) ;
844+
845+ verify ( mockConfigManager . restartServer ( testEnvironmentId , anything ( ) ) ) . once ( ) ;
846+ } ) ;
847+ } ) ;
848+
849+ suite ( 'managePackages' , ( ) => {
850+ const testEnvironmentId = 'test-env-id' ;
851+ const testInterpreter : PythonEnvironment = {
852+ id : 'test-python-id' ,
853+ uri : Uri . file ( '/usr/bin/python3' ) ,
854+ version : { major : 3 , minor : 11 , patch : 0 , raw : '3.11.0' }
855+ } as PythonEnvironment ;
856+
857+ const testEnvironment : DeepnoteEnvironment = {
858+ id : testEnvironmentId ,
859+ name : 'Test Environment' ,
860+ pythonInterpreter : testInterpreter ,
861+ venvPath : Uri . file ( '/path/to/venv' ) ,
862+ packages : [ 'numpy' , 'pandas' ] ,
863+ createdAt : new Date ( ) ,
864+ lastUsedAt : new Date ( )
865+ } ;
866+
867+ setup ( ( ) => {
868+ resetCalls ( mockConfigManager ) ;
869+ resetCalls ( mockedVSCodeNamespaces . window ) ;
870+ } ) ;
871+
872+ test ( 'should call environmentManager.updateEnvironment with parsed packages' , async ( ) => {
873+ when ( mockConfigManager . getEnvironment ( testEnvironmentId ) ) . thenReturn ( testEnvironment ) ;
874+ when ( mockedVSCodeNamespaces . window . showInputBox ( anything ( ) ) ) . thenReturn (
875+ Promise . resolve ( 'matplotlib, scipy, sklearn' )
876+ ) ;
877+ when ( mockConfigManager . updateEnvironment ( anything ( ) , anything ( ) ) ) . thenResolve ( ) ;
878+
879+ when ( mockedVSCodeNamespaces . window . withProgress ( anything ( ) , anything ( ) ) ) . thenCall (
880+ ( _options : ProgressOptions , callback : Function ) => {
881+ return callback ( ) ;
882+ }
883+ ) ;
884+
885+ when ( mockedVSCodeNamespaces . window . showInformationMessage ( anything ( ) ) ) . thenResolve ( undefined ) ;
886+
887+ await ( view as any ) . managePackages ( testEnvironmentId ) ;
888+
889+ verify (
890+ mockConfigManager . updateEnvironment (
891+ testEnvironmentId ,
892+ deepEqual ( { packages : [ 'matplotlib' , 'scipy' , 'sklearn' ] } )
893+ )
894+ ) . once ( ) ;
895+ } ) ;
896+ } ) ;
689897} ) ;
0 commit comments