@@ -834,6 +834,42 @@ describe('inspect', () => {
834
834
835
835
expect ( result . dependencyGraph . equals ( expected ) ) . toBeTruthy ( ) ;
836
836
} ) ;
837
+ it ( 'should return expected dependencies for poetry-v2-app' , async ( ) => {
838
+ const workspace = 'poetry-v2-app' ;
839
+ testUtils . chdirWorkspaces ( workspace ) ;
840
+
841
+ const result = await inspect ( '.' , FILENAMES . poetry . lockfile ) ;
842
+ expect ( result ) . toMatchObject ( {
843
+ plugin : {
844
+ name : 'snyk-python-plugin' ,
845
+ runtime : expect . any ( String ) , // any version of Python
846
+ targetFile : FILENAMES . poetry . manifest ,
847
+ } ,
848
+ package : null , // no dep-tree
849
+ dependencyGraph : { } , // match any dep-graph (equality checked below)
850
+ } ) ;
851
+
852
+ const builder = new DepGraphBuilder (
853
+ { name : 'poetry' } ,
854
+ { name : 'poetry-fixtures-project' , version : '0.1.0' }
855
+ ) ;
856
+ const expected = builder
857
+ . addPkgNode ( { name : 'jinja2' , version : '3.1.5' } , 'jinja2' , {
858
+ labels : { scope : 'prod' } ,
859
+ } )
860
+ . connectDep ( builder . rootNodeId , 'jinja2' )
861
+ . addPkgNode ( { name : 'markupsafe' , version : '3.0.2' } , 'markupsafe' , {
862
+ labels :
{ scope :
'prod' , pkgIdProvenance :
'[email protected] ' } ,
863
+ } )
864
+ . connectDep ( 'jinja2' , 'markupsafe' )
865
+ . addPkgNode ( { name : 'isodd' , version : '0.1.2' } , 'isodd' , {
866
+ labels :
{ scope :
'prod' , pkgIdProvenance :
'[email protected] ' } ,
867
+ } )
868
+ . connectDep ( builder . rootNodeId , 'isodd' )
869
+ . build ( ) ;
870
+
871
+ expect ( result . dependencyGraph . equals ( expected ) ) . toBeTruthy ( ) ;
872
+ } ) ;
837
873
838
874
it ( 'should return expected dependencies for poetry-optional-dependencies' , async ( ) => {
839
875
const workspace = 'poetry-app-optional-dependencies' ;
@@ -853,6 +889,25 @@ describe('inspect', () => {
853
889
854
890
compareTransitiveLines ( result . dependencyGraph , expected ) ;
855
891
} ) ;
892
+
893
+ it ( 'should return expected dependencies for poetry-v2-app-optional-dependencies' , async ( ) => {
894
+ const workspace = 'poetry-v2-app-optional-dependencies' ;
895
+ testUtils . chdirWorkspaces ( workspace ) ;
896
+
897
+ const result = await inspect ( '.' , FILENAMES . poetry . lockfile ) ;
898
+
899
+ const expected = [
900
+ {
901
+ pkg : {
902
+ name : 'opentelemetry-distro' ,
903
+ version : '0.35b0' ,
904
+ } ,
905
+ directDeps : [ 'opentelemetry-distro' ] ,
906
+ } ,
907
+ ] ;
908
+
909
+ compareTransitiveLines ( result . dependencyGraph , expected ) ;
910
+ } ) ;
856
911
} ) ;
857
912
858
913
it ( 'should return correct target file for poetry project when relative path to poetry lock file is passed' , async ( ) => {
@@ -865,6 +920,16 @@ describe('inspect', () => {
865
920
expect ( result . plugin . targetFile ) . toEqual ( expectedTargetFile ) ;
866
921
} ) ;
867
922
923
+ it ( 'should return correct target file for poetry v2 project when relative path to poetry lock file is passed' , async ( ) => {
924
+ const dirname = 'test/fixtures/poetry-v2-project' ;
925
+ const manifestFilePath = `${ dirname } /poetry.lock` ;
926
+
927
+ const result = await inspect ( '.' , manifestFilePath ) ;
928
+
929
+ const expectedTargetFile = `${ dirname } /pyproject.toml` ;
930
+ expect ( result . plugin . targetFile ) . toEqual ( expectedTargetFile ) ;
931
+ } ) ;
932
+
868
933
describe ( 'Pipfile projects' , ( ) => {
869
934
const mockedExecuteSync = jest . spyOn ( subProcess , 'executeSync' ) ;
870
935
const mockedExecute = jest . spyOn ( subProcess , 'execute' ) ;
0 commit comments