@@ -697,4 +697,54 @@ suite('testing python-poetry error handling', () => {
697697 expect ( ( ) => instance . _verifyPoetryAccessible ( 'poetry' ) )
698698 . to . throw ( 'failed to check for poetry binary' )
699699 } ) . timeout ( TIMEOUT )
700+
701+ /** Verifies that _getDependencyData skips binary verification when both env vars bypass poetry. */
702+ test ( 'verify _getDependencyData skips binary check when both env vars are set' , async ( ) => {
703+ let provider = await esmock ( '../../src/providers/python_poetry.js' , {
704+ '../../src/tools.js' : {
705+ getCustomPath : ( ) => '/nonexistent/poetry' ,
706+ environmentVariableIsPopulated : ( name ) => {
707+ return name === 'TRUSTIFY_DA_POETRY_SHOW_TREE' || name === 'TRUSTIFY_DA_POETRY_SHOW_ALL'
708+ } ,
709+ invokeCommand : ( ) => {
710+ let err = new Error ( 'spawn /nonexistent/poetry ENOENT' )
711+ err . code = 'ENOENT'
712+ throw err
713+ }
714+ }
715+ } )
716+
717+ let instance = new provider . default ( )
718+ instance . _getPoetryShowTreeOutput = ( ) => ''
719+ instance . _getPoetryShowAllOutput = ( ) => ''
720+ instance . _parsePoetryShowAll = ( ) => new Map ( )
721+ instance . _findLockFileDir = ( ) => '/tmp'
722+ instance . _extractMarkerData = ( ) => ( { } )
723+ instance . _parsePoetryTree = ( ) => ( { directDeps : [ ] , graph : new Map ( ) } )
724+
725+ await instance . _getDependencyData ( '/tmp' , '/tmp' , { tool : { } } , { } )
726+ } ) . timeout ( TIMEOUT )
727+
728+ /** Verifies that _getDependencyData runs binary verification when env vars are not set. */
729+ test ( 'verify _getDependencyData runs binary check when env vars are not set' , async ( ) => {
730+ let provider = await esmock ( '../../src/providers/python_poetry.js' , {
731+ '../../src/tools.js' : {
732+ getCustomPath : ( ) => '/nonexistent/poetry' ,
733+ environmentVariableIsPopulated : ( ) => false ,
734+ invokeCommand : ( ) => {
735+ let err = new Error ( 'spawn /nonexistent/poetry ENOENT' )
736+ err . code = 'ENOENT'
737+ throw err
738+ }
739+ }
740+ } )
741+
742+ let instance = new provider . default ( )
743+ try {
744+ await instance . _getDependencyData ( '/tmp' , '/tmp' , { tool : { } } , { } )
745+ expect . fail ( 'Expected error to be thrown' )
746+ } catch ( e ) {
747+ expect ( e . message ) . to . include ( 'poetry is not accessible' )
748+ }
749+ } ) . timeout ( TIMEOUT )
700750} )
0 commit comments