Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endpoint to create or update a package set #205 #350

Merged
merged 10 commits into from
Apr 4, 2024

Conversation

404-geek
Copy link
Contributor

I have crafted an api for updating a package set with purl entry.

Below is the approach which I have taken.

Take a list of packages (where each item is a dictionary containing PURL and content_type).

If uuid is given then all purls will be added to package set if it exists else a new set would be created and all the purls will be added to that new set.

Note: There is also a slight addition to the logic where a purl already exists in the database
and so there are no changes done to the purl entry it is passed as it is.

Request example:

{
          "purls": [
            {"purl": "pkg:npm/[email protected]", "content_type": 1}
          ],
          "uuid" : "b67ceb49-1538-481f-a572-431062f382gg"
        }

Please feel free to suggest any changes to the approach or if anything false has been assumed/coded.

Copy link
Member

@JonoYang JonoYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@404-geek Thanks for the PR! Can you make a test for this new view?

@404-geek
Copy link
Contributor Author

@404-geek Thanks for the PR! Can you make a test for this new view?

@JonoYang I have added some test cases for the view in packagedb/tests/test_api.py. Please review the changes.

@404-geek 404-geek requested a review from JonoYang March 31, 2024 23:59
Copy link
Member

@JonoYang JonoYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@404-geek Thanks for the revisions! I left a comment about using the text label for content_type choices instead of the integer value when updating a package set

}

self.assertAlmostEquals(expected, response.data)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add one more test for when an invalid or nonexisting uuid is given to the API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test for non exisiting uuid

@404-geek 404-geek requested a review from JonoYang April 4, 2024 04:49
Copy link
Member

@JonoYang JonoYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@404-geek LGTM, thanks!

@JonoYang JonoYang merged commit 7134dcf into aboutcode-org:main Apr 4, 2024
8 checks passed
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