Skip to content

Commit 2726272

Browse files
committed
Just a dummy commit wiyh changes in tests
1 parent 9c891a8 commit 2726272

File tree

4 files changed

+132
-7
lines changed

4 files changed

+132
-7
lines changed

src/fetchcode/package.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,10 @@ def get_rubygems_data_from_purl(purl):
311311
name = purl.name
312312
api_url = f"https://rubygems.org/api/v1/gems/{name}.json"
313313
releases_url = f"https://rubygems.org/api/v1/versions/{name}.json"
314-
releases = get_response(releases_url)
315314
response = get_response(api_url)
315+
releases = get_response(releases_url)
316+
print(response)
317+
# print(releases)
316318
declared_license = response.get("licenses") or None
317319
version = response.get("version")
318320
version_purl = PackageURL(

tests/data/rubygems.json

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1-
{"0": {"type": "rubygems", "namespace": null, "name": "rubocop", "version": null, "qualifiers": {}, "subpath": null, "primary_language": null, "description": null, "release_date": null, "parties": [], "keywords": [], "homepage_url": "https://rubocop.org/", "download_url": "https://rubygems.org/gems/rubocop-0.89.1.gem", "api_url": "https://rubygems.org/api/v1/gems/rubocop.json", "size": null, "sha1": null, "md5": null, "sha256": null, "sha512": null, "bug_tracking_url": "https://github.com/rubocop-hq/rubocop/issues", "code_view_url": "https://github.com/rubocop-hq/rubocop/", "vcs_url": null, "copyright": null, "license_expression": null, "declared_license": ["MIT"], "notice_text": null, "root_path": null, "dependencies": [], "contains_source_code": null, "source_packages": [], "purl": "pkg:rubygems/rubocop", "repository_homepage_url": null, "repository_download_url": null, "api_data_url": null}}
1+
{
2+
"0": {
3+
"type": "rubygems",
4+
"namespace": null,
5+
"name": "rubocop",
6+
"version": null,
7+
"qualifiers": {},
8+
"subpath": null,
9+
"primary_language": null,
10+
"description": null,
11+
"release_date": null,
12+
"parties": [],
13+
"keywords": [],
14+
"homepage_url": "https://rubocop.org/",
15+
"download_url": "https://rubygems.org/gems/rubocop-0.89.1.gem",
16+
"api_url": "https://rubygems.org/api/v1/gems/rubocop.json",
17+
"size": null,
18+
"sha1": null,
19+
"md5": null,
20+
"sha256": null,
21+
"sha512": null,
22+
"bug_tracking_url": "https://github.com/rubocop-hq/rubocop/issues",
23+
"code_view_url": "https://github.com/rubocop-hq/rubocop/",
24+
"vcs_url": null,
25+
"copyright": null,
26+
"license_expression": null,
27+
"declared_license": [
28+
"MIT"
29+
],
30+
"notice_text": null,
31+
"root_path": null,
32+
"dependencies": [],
33+
"contains_source_code": null,
34+
"source_packages": [],
35+
"purl": "pkg:rubygems/rubocop",
36+
"repository_homepage_url": null,
37+
"repository_download_url": null,
38+
"api_data_url": null
39+
}
40+
}

tests/data/rubygems_mock_data.json

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,79 @@
1-
{"name":"rubocop","downloads":111809413,"version":"0.89.1","version_downloads":259770,"platform":"ruby","authors":"Bozhidar Batsov, Jonas Arvidsson, Yuji Nakayama","info":" RuboCop is a Ruby code style checking and code formatting tool.\n It aims to enforce the community-driven Ruby Style Guide.\n","licenses":["MIT"],"metadata":{"homepage_uri":"https://rubocop.org/","changelog_uri":"https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md","bug_tracker_uri":"https://github.com/rubocop-hq/rubocop/issues","source_code_uri":"https://github.com/rubocop-hq/rubocop/","documentation_uri":"https://docs.rubocop.org/"},"yanked":false,"sha":"30794116b2804aab1abc74780a201fae5160c1d6a21550ce9786abd3ca0e07fa","project_uri":"https://rubygems.org/gems/rubocop","gem_uri":"https://rubygems.org/gems/rubocop-0.89.1.gem","homepage_uri":"https://rubocop.org/","wiki_uri":null,"documentation_uri":"https://docs.rubocop.org/","mailing_list_uri":null,"source_code_uri":"https://github.com/rubocop-hq/rubocop/","bug_tracker_uri":"https://github.com/rubocop-hq/rubocop/issues","changelog_uri":"https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md","dependencies":{"development":[{"name":"bundler","requirements":"\u003e= 1.15.0, \u003c 3.0"}],"runtime":[{"name":"parallel","requirements":"~\u003e 1.10"},{"name":"parser","requirements":"\u003e= 2.7.1.1"},{"name":"rainbow","requirements":"\u003e= 2.2.2, \u003c 4.0"},{"name":"regexp_parser","requirements":"\u003e= 1.7"},{"name":"rexml","requirements":"\u003e= 0"},{"name":"rubocop-ast","requirements":"\u003e= 0.3.0, \u003c 1.0"},{"name":"ruby-progressbar","requirements":"~\u003e 1.7"},{"name":"unicode-display_width","requirements":"\u003e= 1.4.0, \u003c 2.0"}]}}
1+
{
2+
"name": "rubocop",
3+
"downloads": 281548679,
4+
"version": "1.40.0",
5+
"version_created_at": "2022-12-08T07:50:52.498Z",
6+
"version_downloads": 198668,
7+
"platform": "ruby",
8+
"authors": "Bozhidar Batsov, Jonas Arvidsson, Yuji Nakayama",
9+
"info": " RuboCop is a Ruby code style checking and code formatting tool. It aims to enforce the community-driven Ruby Style Guide. ",
10+
"licenses": [
11+
"MIT"
12+
],
13+
"metadata": {
14+
"homepage_uri": "https://rubocop.org/",
15+
"changelog_uri": "https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md",
16+
"bug_tracker_uri": "https://github.com/rubocop/rubocop/issues",
17+
"source_code_uri": "https://github.com/rubocop/rubocop/",
18+
"documentation_uri": "https://docs.rubocop.org/rubocop/1.40/",
19+
"rubygems_mfa_required": "true"
20+
},
21+
"yanked": false,
22+
"sha": "031881f824594fdb08713d5187c7bf07a11ff83fda869a7dd2d7765f92846a35",
23+
"project_uri": "https://rubygems.org/gems/rubocop",
24+
"gem_uri": "https://rubygems.org/gems/rubocop-1.40.0.gem",
25+
"homepage_uri": "https://rubocop.org/",
26+
"wiki_uri": null,
27+
"documentation_uri": "https://docs.rubocop.org/rubocop/1.40/",
28+
"mailing_list_uri": null,
29+
"source_code_uri": "https://github.com/rubocop/rubocop/",
30+
"bug_tracker_uri": "https://github.com/rubocop/rubocop/issues",
31+
"changelog_uri": "https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md",
32+
"funding_uri": null,
33+
"dependencies": {
34+
"development": [
35+
{
36+
"name": "bundler",
37+
"requirements": ">= 1.15.0, < 3.0"
38+
}
39+
],
40+
"runtime": [
41+
{
42+
"name": "json",
43+
"requirements": "~> 2.3"
44+
},
45+
{
46+
"name": "parallel",
47+
"requirements": "~> 1.10"
48+
},
49+
{
50+
"name": "parser",
51+
"requirements": ">= 3.1.2.1"
52+
},
53+
{
54+
"name": "rainbow",
55+
"requirements": ">= 2.2.2, < 4.0"
56+
},
57+
{
58+
"name": "regexp_parser",
59+
"requirements": ">= 1.8, < 3.0"
60+
},
61+
{
62+
"name": "rexml",
63+
"requirements": ">= 3.2.5, < 4.0"
64+
},
65+
{
66+
"name": "rubocop-ast",
67+
"requirements": ">= 1.23.0, < 2.0"
68+
},
69+
{
70+
"name": "ruby-progressbar",
71+
"requirements": "~> 1.7"
72+
},
73+
{
74+
"name": "unicode-display_width",
75+
"requirements": ">= 1.4.0, < 3.0"
76+
}
77+
]
78+
}
79+
}

tests/test_package.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ def test_npm_packages(mock_get):
5656

5757
@mock.patch("fetchcode.package.get_response")
5858
def test_pypi_packages(mock_get):
59-
side_effect = [file_data("tests/data/pypi_mock_data.json")]
59+
side_effect = [file_data("./data/pypi_mock_data.json")]
6060
purl = "pkg:pypi/flask"
61-
expected_data = file_data("tests/data/pypi.json")
61+
expected_data = file_data("./data/pypi.json")
6262
mock_get.side_effect = side_effect
6363
packages = list(info(purl))
6464
match_data(packages, expected_data)
@@ -90,13 +90,19 @@ def test_bitbucket_packages(mock_get):
9090
match_data(packages, expected_data)
9191

9292

93+
# @mock.patch("fetchcode.package.get_response")
9394
@mock.patch("fetchcode.package.get_response")
9495
def test_rubygems_packages(mock_get):
95-
side_effect = [file_data("tests/data/rubygems_mock_data.json")]
96+
# print(mock_get)
97+
side_effect = [file_data("./data/rubygems_mock_data.json"), file_data("./data/rubygems_mock_data2.json")]
98+
# side_effect2 = [file_data("./data/rubygems_mock_data2.json")]
9699
purl = "pkg:rubygems/rubocop"
97-
expected_data = file_data("tests/data/rubygems.json")
100+
expected_data = file_data("./data/rubygems.json")
98101
mock_get.side_effect = side_effect
102+
# mock_get2.side_effect = side_effect
99103
packages = list(info(purl))
104+
# print(packages)
105+
# print(packages, expected_data)
100106
match_data(packages, expected_data)
101107

102108

0 commit comments

Comments
 (0)