generated from aboutcode-org/skeleton
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
- Loading branch information
1 parent
da8d816
commit bc869d2
Showing
2 changed files
with
165 additions
and
63 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -99,22 +99,21 @@ def test_validate_purl_strip(self): | |
|
||
self.assertEqual(validated_purls, expected_results) | ||
|
||
def test_versions(self): | ||
purls = ["pkg:pypi/fetchcode"] | ||
abc = purlcli.list_versions(purls) | ||
# def test_versions(self): | ||
# purls = ["pkg:pypi/fetchcode"] | ||
# abc = purlcli.list_versions(purls) | ||
# print(f"\nabc = {abc}") | ||
|
||
print(f"\nabc = {abc}") | ||
# for purl_list in abc: | ||
# for p in purl_list: | ||
# # print(PackageVersion.to_dict(p)) | ||
# p_dict = PackageVersion.to_dict(p) | ||
# print(f"\np_dict = {p_dict}") | ||
# print(f"\ntype(p_dict) = {type(p_dict)}") | ||
|
||
for purl_list in abc: | ||
for p in purl_list: | ||
# print(PackageVersion.to_dict(p)) | ||
p_dict = PackageVersion.to_dict(p) | ||
# print(f"\np_dict = {p_dict}") | ||
# print(f"\ntype(p_dict) = {type(p_dict)}") | ||
|
||
json_p_dict = json.dumps(p_dict) | ||
# print(f"\njson_p_dict = {json_p_dict}") | ||
# print(f"\ntype(json_p_dict) = {type(json_p_dict)}") | ||
# json_p_dict = json.dumps(p_dict) | ||
# print(f"\njson_p_dict = {json_p_dict}") | ||
# print(f"\ntype(json_p_dict) = {type(json_p_dict)}") | ||
|
||
|
||
# 2024-01-08 Monday 17:55:15. Based on test_api.py's class PurlValidateApiTestCase(TestCase). | ||
|
@@ -138,7 +137,8 @@ def setUp(self): | |
|
||
def test_api_purl_validation(self): | ||
data1 = { | ||
"purl": "pkg:npm/[email protected]", | ||
# "purl": "pkg:npm/[email protected]", | ||
"purl": "pkg:pypi/[email protected]", | ||
"check_existence": True, | ||
} | ||
response1 = self.client.get(f"/api/validate/", data=data1) | ||
|
@@ -148,7 +148,8 @@ def test_api_purl_validation(self): | |
print(f"") | ||
|
||
data2 = { | ||
"purl": "pkg:npm/[email protected]", | ||
# "purl": "pkg:npm/[email protected]", | ||
"purl": "pkg:pypi/[email protected]", | ||
"check_existence": True, | ||
} | ||
response2 = self.client.get(f"/api/validate/", data=data2) | ||
|
@@ -157,22 +158,24 @@ def test_api_purl_validation(self): | |
print(f"\nresponse2.data = {response2.data}") | ||
print(f"") | ||
|
||
self.assertEquals(True, response1.data["valid"]) | ||
self.assertEquals(True, response1.data["exists"]) | ||
self.assertEquals( | ||
self.assertEqual(True, response1.data["valid"]) | ||
self.assertEqual(True, response1.data["exists"]) | ||
self.assertEqual( | ||
"The provided Package URL is valid, and the package exists in the upstream repo.", | ||
response1.data["message"], | ||
) | ||
|
||
self.assertEquals(False, response2.data["valid"]) | ||
self.assertEquals( | ||
self.assertEqual(False, response2.data["valid"]) | ||
self.assertEqual( | ||
"The provided PackageURL is not valid.", response2.data["message"] | ||
) | ||
|
||
# ZZZ: 2024-01-08 Monday 18:54:51. Some exploring: | ||
|
||
data3 = { | ||
"purl": "pkg:npm/ogdendunes", | ||
# "purl": "pkg:npm/ogdendunes", | ||
# "purl": "pkg:pypi/ogdendunes", | ||
"purl": "pkg:pypi/[email protected]", | ||
"check_existence": True, | ||
} | ||
response3 = self.client.get(f"/api/validate/", data=data3) | ||
|
@@ -184,6 +187,24 @@ def test_api_purl_validation(self): | |
self.assertEqual(True, response3.data["valid"]) | ||
self.assertEqual(False, response3.data["exists"]) | ||
self.assertEqual( | ||
"The provided Package URL is valid but does not exist in the upstream repo.", | ||
"The provided PackageURL is valid but does not exist in the upstream repo.", | ||
response3.data["message"], | ||
) | ||
|
||
data4 = { | ||
# "purl": "pkg:nginx/[email protected]?os=windows", | ||
"purl": "pkg:nginx/[email protected]", | ||
"check_existence": True, | ||
} | ||
response4 = self.client.get(f"/api/validate/", data=data4) | ||
|
||
print(f"\nresponse4 = {response4}") | ||
print(f"\nresponse4.data = {response4.data}") | ||
print(f"") | ||
|
||
self.assertEqual(True, response4.data["valid"]) | ||
self.assertEqual(False, response4.data["exists"]) | ||
self.assertEqual( | ||
"The provided PackageURL is valid but does not exist in the upstream repo.", | ||
response4.data["message"], | ||
) |
This file contains 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