use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze in project synopsys-detect by blackducksoftware.
the class PipenvTransformerTest method resolvesLowercaseNameWithFreezeCapital.
@Test
void resolvesLowercaseNameWithFreezeCapital() {
List<PipFreezeEntry> pipFreezeEntries = new ArrayList<>();
pipFreezeEntries.add(new PipFreezeEntry("Example", "2.0.0"));
PipFreeze pipFreeze = new PipFreeze(pipFreezeEntries);
List<PipenvGraphEntry> pipenvGraphEntries = new ArrayList<>();
pipenvGraphEntries.add(new PipenvGraphEntry("example", "fuzzy", new ArrayList<>()));
PipenvGraph pipenvGraph = new PipenvGraph(pipenvGraphEntries);
PipenvTransformer pipenvTransformer = new PipenvTransformer(new ExternalIdFactory());
CodeLocation codeLocation = pipenvTransformer.transform("", "", pipFreeze, pipenvGraph, false);
DependencyGraph graph = codeLocation.getDependencyGraph();
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasDependency("Example", "2.0.0");
}
use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze in project synopsys-detect by blackducksoftware.
the class PipenvTransformerTest method usesProjectDependencyAsRoot.
@Test
void usesProjectDependencyAsRoot() {
PipFreeze pipFreeze = new PipFreeze(new ArrayList<>());
List<PipenvGraphEntry> pipenvGraphEntries = new ArrayList<>();
List<PipenvGraphDependency> children = new ArrayList<>();
children.add(new PipenvGraphDependency("shouldBeAtRoot", "shouldbeAtRootVersion", new ArrayList<>()));
pipenvGraphEntries.add(new PipenvGraphEntry("projectName", "projectVersion", children));
PipenvGraph pipenvGraph = new PipenvGraph(pipenvGraphEntries);
PipenvTransformer pipenvTransformer = new PipenvTransformer(new ExternalIdFactory());
CodeLocation codeLocation = pipenvTransformer.transform("projectName", "projectVersion", pipFreeze, pipenvGraph, false);
DependencyGraph graph = codeLocation.getDependencyGraph();
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasRootDependency("shouldBeAtRoot", "shouldbeAtRootVersion");
}
use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze in project synopsys-detect by blackducksoftware.
the class PipenvTransformerTest method resolvesFuzzyVersion.
@Test
void resolvesFuzzyVersion() {
List<PipFreezeEntry> pipFreezeEntries = new ArrayList<>();
pipFreezeEntries.add(new PipFreezeEntry("example", "2.0.0"));
PipFreeze pipFreeze = new PipFreeze(pipFreezeEntries);
List<PipenvGraphEntry> pipenvGraphEntries = new ArrayList<>();
pipenvGraphEntries.add(new PipenvGraphEntry("example", "fuzzy", new ArrayList<>()));
PipenvGraph pipenvGraph = new PipenvGraph(pipenvGraphEntries);
PipenvTransformer pipenvTransformer = new PipenvTransformer(new ExternalIdFactory());
CodeLocation codeLocation = pipenvTransformer.transform("", "", pipFreeze, pipenvGraph, false);
DependencyGraph graph = codeLocation.getDependencyGraph();
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasDependency("example", "2.0.0");
}
use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze in project synopsys-detect by blackducksoftware.
the class PipenvFreezeParserTests method findsThreeNamesAndVersions.
@Test
void findsThreeNamesAndVersions() {
List<String> pipFreezeText = new ArrayList<>();
pipFreezeText.add("simple==1");
pipFreezeText.add("with-dashes==2.0");
pipFreezeText.add("dots.and-dashes==3.1.2");
PipenvFreezeParser pipenvFreezeParser = new PipenvFreezeParser();
PipFreeze pipFreeze = pipenvFreezeParser.parse(pipFreezeText);
Assertions.assertEquals(3, pipFreeze.getEntries().size(), "Pip freeze should have created three entries.");
assertContains("simple", "1", pipFreeze);
assertContains("with-dashes", "2.0", pipFreeze);
assertContains("dots.and-dashes", "3.1.2", pipFreeze);
}
use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze in project synopsys-detect by blackducksoftware.
the class PipenvExtractor method extract.
public Extraction extract(File directory, ExecutableTarget pythonExe, ExecutableTarget pipenvExe, File setupFile, String providedProjectName, String providedProjectVersionName, boolean includeOnlyProjectTree) {
Extraction extraction;
try {
String projectName = resolveProjectName(directory, pythonExe, setupFile, providedProjectName);
String projectVersionName = resolveProjectVersionName(directory, pythonExe, setupFile, providedProjectVersionName);
ExecutableOutput pipFreezeOutput = executableRunner.execute(ExecutableUtils.createFromTarget(directory, pipenvExe, Arrays.asList("run", "pip", "freeze")));
ExecutableOutput graphOutput = executableRunner.execute(ExecutableUtils.createFromTarget(directory, pipenvExe, Arrays.asList("graph", "--bare", "--json-tree")));
PipFreeze pipFreeze = pipenvFreezeParser.parse(pipFreezeOutput.getStandardOutputAsList());
PipenvGraph pipenvGraph = pipEnvJsonGraphParser.parse(graphOutput.getStandardOutput());
CodeLocation codeLocation = pipenvTransformer.transform(projectName, projectVersionName, pipFreeze, pipenvGraph, includeOnlyProjectTree);
return new Extraction.Builder().projectName(projectName).projectVersion(projectVersionName).success(codeLocation).build();
} catch (Exception e) {
extraction = new Extraction.Builder().exception(e).build();
}
return extraction;
}
Aggregations