-
-
Notifications
You must be signed in to change notification settings - Fork 69
Support indexing of directory listed and GNU packages #318
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8e21c87
Use proper pattern to route generic PURL with download_url
keshav-space 1306c5b
Support directory listed package indexing
keshav-space 77d9faa
Support GNU package indexing
keshav-space c36ec1e
Add test for generic dir listed packages
keshav-space f0171d5
Add test for gnu package indexing
keshav-space 5d6e1d7
Merge remote-tracking branch 'origin/main' into support-indexing-of-d…
keshav-space e63e3ef
Bump fetchcode from 0.3.0 to 0.4.0
keshav-space 798ba8b
Update docstring
keshav-space 6ab8b1d
Remove debug statements
keshav-space 4953229
Add packagedata_from_dict to filter out unsupported fields
keshav-space File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # | ||
| # Copyright (c) nexB Inc. and others. All rights reserved. | ||
| # purldb is a trademark of nexB Inc. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. | ||
| # See https://github.com/nexB/purldb for support or download. | ||
| # See https://aboutcode.org for more information about nexB OSS projects. | ||
| # | ||
|
|
||
|
|
||
| import os | ||
|
|
||
| from django.test import TestCase | ||
| from mock import patch | ||
|
|
||
| from minecode.utils_test import JsonBasedTesting | ||
| from minecode.visitors import gnu | ||
| from packagedb.models import Package | ||
|
|
||
|
|
||
| class GnuPriorityQueueTests(JsonBasedTesting, TestCase): | ||
| test_data_dir = os.path.join(os.path.dirname(__file__), "testfiles") | ||
|
|
||
| def setUp(self): | ||
| super(GnuPriorityQueueTests, self).setUp() | ||
| glibc_data_loc = self.get_test_loc("gnu/glibc/index.html") | ||
|
|
||
| with open(glibc_data_loc) as f: | ||
| self.glibc_data_content = f.read() | ||
|
|
||
| @patch("requests.get") | ||
| def test_process_request(self, mock_get): | ||
| mock_get.side_effect = [ | ||
| type( | ||
| "Response", | ||
| (), | ||
| { | ||
| "content": self.glibc_data_content.encode(), | ||
| "raise_for_status": lambda: None, | ||
| }, | ||
| ) | ||
| ] | ||
|
|
||
| package_count = Package.objects.all().count() | ||
| self.assertEqual(0, package_count) | ||
|
|
||
| purl = "pkg:gnu/glibc@2.15" | ||
| error_msg = gnu.process_request(purl) | ||
|
|
||
| self.assertEqual(None, error_msg) | ||
| package_count = Package.objects.all().count() | ||
| self.assertEqual(1, package_count) | ||
|
|
||
| package = Package.objects.first() | ||
| self.assertEqual("glibc", package.name) | ||
| self.assertEqual("2.15", package.version) | ||
| print(package.download_url) | ||
|
keshav-space marked this conversation as resolved.
Outdated
|
||
| self.assertEqual( | ||
| "https://ftp.gnu.org/pub/gnu/glibc/glibc-2.15.tar.gz", | ||
| package.download_url, | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.