feat(license): wrap POST /license/import-csv endpoint#185
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new import_licenses_csv method to the Fossology license API wrapper, enabling bulk import of licenses from a CSV file via POST /license/import-csv, along with tests for success and error scenarios.
Changes:
- New
import_licenses_csvmethod on the license client with delimiter/enclosure options. - Integration-style test for successful CSV import.
- Mocked test for error handling on import failure.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| fossology/license.py | Implements the CSV license import API method. |
| tests/test_license.py | Adds success and error tests for the new method. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add `LicenseEndpoint.import_licenses_csv()` to import a CSV file of license rows via the Fossology REST API. Multipart form-data with required `file_input` plus optional `delimiter` and `enclosure`. Returns the server's multi-line summary message (inserted / already-existing rows). Tests cover the live happy path (round-trip a small CSV against the container; the server is idempotent for duplicate shortnames) and a mocked 400 error path. Refs fossology#52 Signed-off-by: RAJVEER42 <irajveer.bishnoi2310@gmail.com>
e0862cf to
230fbe4
Compare
|
Reviewed each suggestion against the rest of the codebase and applied only the one that is consistent with the existing project style. Applied — payload-asserting mocked test ( Added
This addressed a genuine coverage gap. Not applied — Checked existing file-upload APIs for consistency. Keeping Not applied — Verified that the sibling Additionally, none of the existing file-based methods ( If the project wants to adopt either of these patterns, it would be better handled as a separate, repository-wide change affecting the existing methods as well. All 16 tests in |
|
cc @deveaud-m
|
Refs #52.
Wraps the
POST /license/import-csvendpoint asLicenseEndpoint.import_licenses_csv().Performs a multipart upload of a CSV file with optional
delimiter(default",") andenclosure(default"\""), returning the server's multi-line summary message indicating inserted and already-existing rows.The implementation matches the live contract verified against Fossology 4.4.0:
Endpoint path is
/license/import-csv(the OpenAPI spec was renamed from the original/license/importin feat(API): import csv-license file fossology#2292; the current spec lives alongside/license/export-csv,/license/import-json,/license/export-json)Required field:
file_input; optionaldelimiter,enclosure200 success →
Infoschema with multi-line message400 → validation error
Tests cover the live happy path by round-tripping a small CSV against the container (the server is idempotent on duplicate shortnames, so repeated test runs do not pollute state), as well as a mocked
400 Bad Requesterror path.