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