Skip to content

Conversation

ivangoranov
Copy link
Contributor

@ivangoranov ivangoranov commented Apr 25, 2025

Related: #98

This pull request adds new functionalities to the ScrapydClient class and introduces comprehensive test coverage for these features. The changes include new methods for managing Scrapyd projects, versions, and jobs, as well as corresponding unit tests to ensure their correctness.

New Features in ScrapydClient:

  • Daemon Status and Versions Management:

    • Added daemonstatus method to fetch the status of the Scrapyd daemon.
    • Added versions method to list versions of a given project.
  • Project and Version Deletion:

    • Added delproject method to delete a project, with error handling for non-existent projects.
    • Added delversion method to delete specific or all versions of a project, with error handling for invalid versions.
  • Job Management:

    • Added cancel method to cancel a specific job or all running jobs within a project, with validation for project and job existence.

Test Coverage:

  • Tests for Daemon Status and Versions:

    • Added tests for daemonstatus to validate successful and error responses.
    • Added tests for versions to handle scenarios with valid versions, no versions, and error responses.
  • Tests for Project and Version Deletion:

    • Added tests for delproject to ensure proper handling of non-existent projects and successful deletion.
    • Added tests for delversion to validate deletion of specific or all versions and error handling for invalid inputs.
  • Tests for Job Management:

    • Added tests for cancel to verify cancellation of specific jobs, all jobs, and error handling for invalid projects or jobs.

@ivangoranov ivangoranov changed the title Feature enhancement issue 98 Add Commands for Remaining Scrapyd API Endpoints Apr 25, 2025
@jpmckinney
Copy link
Contributor

Thank you for this!

I removed the error handling for non-existent projects/versions/jobs, as the API already returns an error response if the project/version/job doesn't exist, and it is an unnecessary API request if the user knows the project/version/job exists.

I also think users should be able to implement the "all" functionality of delversion and cancel, so I removed it. For example:

for version in client.versions(project):
    client.delversion(project, version)
responses = {jobid: client.cancel(project, jobid) for jobid in client.jobs(project)["running"]}

@jpmckinney
Copy link
Contributor

I rebased this branch into the default branch from the command line.

@jpmckinney jpmckinney closed this May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants