feat(report): wrap POST /report/import endpoint#184
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 support for importing external SPDX reports into a Fossology upload and validates the new API behavior with tests.
Changes:
- Introduce
Fossology.import_report()that uploads a report file and schedules areportImportjob. - Add integration/unit tests covering success, authorization failure, server error, and unparseable API responses.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
fossology/report.py |
Adds import_report() API wrapper with response handling and errors. |
tests/test_report.py |
Adds tests for report import scenarios (success + failure modes). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b9cf928 to
989ecab
Compare
|
All five review points addressed in
|
Add `Report.import_report()` to schedule a reportImport job for an
upload by uploading an external SPDX RDF report. Completes the report
triad with `generate_report` and `download_report`.
The endpoint is `POST /report/import?upload={id}&reportFormat={fmt}`
with the report file as a `report` multipart field. Response message
is the integer job id (returned directly, no string parsing).
Tests cover the live happy path (round-trip via generate → download →
import), the not-authorized path, the 500 error path, and a
defensively-parsed malformed-response path.
Refs fossology#52
Signed-off-by: RAJVEER42 <irajveer.bishnoi2310@gmail.com>
989ecab to
5e098fb
Compare
|
Trimmed the implementation after a second review pass. The previous The implementation is now simply: return int(response.json()["message"])This removes unnecessary complexity and cuts 25 lines from the diff. All 16 tests in |
Adds
Report.import_report()as a wrapper forPOST /report/import, completing the report workflow alongsidegenerate_report()anddownload_report().The method imports external SPDX RDF reports via multipart upload and returns the scheduled
reportImportjob ID (int).API Details
Validated against Fossology 4.4.0 / API 1.6.2.
POST /report/importupload,reportFormat(spdxrdfcurrently required)reportaddConcludedAsDecisions,groupNameheaderSuccess response:
{ "code": 201, "message": <job_id_int>, "type": "INFO" }Tests
test_report.pynow covers:generate_report()→download_report()→import_report()500server errorsAll 17 tests pass against the live Fossology container.
Refs #52.