Skip to content

Commit b28e6c0

Browse files
committed
Update tests
Signed-off-by: Jono Yang <jyang@nexb.com>
1 parent 706e3da commit b28e6c0

4 files changed

Lines changed: 193 additions & 9 deletions

File tree

tests/scancode/data/plugin_origin_summary/clear-summary-expected.json

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,54 @@
99
],
1010
"--copyright": true,
1111
"--info": true,
12+
"--json-pp": "clear-summary.json",
13+
"--license": true
14+
},
15+
"notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.",
16+
"start_timestamp": "2019-06-06T234321.851466",
17+
"end_timestamp": "2019-06-06T234327.251991",
18+
"message": null,
19+
"errors": [],
20+
"extra_data": {
21+
"files_count": 13
22+
}
23+
},
24+
{
25+
"tool_name": "scancode-toolkit",
26+
"tool_version": "3.0.2.post622.ca4dcb2.dirty.20190530214353",
27+
"options": {
28+
"input": [
29+
"clear-summary.json"
30+
],
31+
"--from-json": true,
1232
"--json-pp": "clear-summary-expected.json",
13-
"--license": true,
1433
"--origin-summary": true
1534
},
1635
"notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.",
17-
"start_timestamp": "2019-06-07T012733.684306",
18-
"end_timestamp": "2019-06-07T012738.755282",
36+
"start_timestamp": "2019-06-10T234229.010923",
37+
"end_timestamp": "2019-06-10T234229.038775",
1938
"message": null,
2039
"errors": [],
2140
"extra_data": {
2241
"files_count": 13
2342
}
2443
}
2544
],
45+
"summarized_directories": {
46+
"apache-2.0": {
47+
"Acme Corporation": [
48+
"clear_summary",
49+
"clear_summary/src"
50+
]
51+
},
52+
"mit": {
53+
"Omega Inc.": [
54+
"clear_summary/third_party",
55+
"clear_summary/third_party/module_2",
56+
"clear_summary/third_party/module_3"
57+
]
58+
}
59+
},
2660
"files": [
2761
{
2862
"path": "clear_summary",
Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,110 @@
1-
{"headers":[{"tool_name":"scancode-toolkit","tool_version":"3.0.2.post622.ca4dcb2.dirty.20190530214353","options":{"input":["samples/arch"],"--copyright":true,"--info":true,"--json":"no_null-expected.json","--license":true,"--origin-summary":true},"notice":"Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.","start_timestamp":"2019-06-07T004906.744290","end_timestamp":"2019-06-07T004911.468445","message":null,"errors":[],"extra_data":{"files_count":1}}],"files":[{"path":"arch","type":"directory","name":"arch","base_name":"arch","extension":"","size":0,"date":null,"sha1":null,"md5":null,"mime_type":null,"file_type":null,"programming_language":null,"is_binary":false,"is_text":false,"is_archive":false,"is_media":false,"is_source":false,"is_script":false,"licenses":[],"license_expressions":[],"holders":[],"copyrights":[],"authors":[],"origin_summary":{},"summarized_to":null,"files_count":1,"dirs_count":0,"size_count":28103,"scan_errors":[]},{"path":"arch/zlib.tar.gz","type":"file","name":"zlib.tar.gz","base_name":"zlib","extension":".tar.gz","size":28103,"date":"2019-04-23","sha1":"576f0ccfe534d7f5ff5d6400078d3c6586de3abd","md5":"20b2370751abfc08bb3556c1d8114b5a","mime_type":"application/x-gzip","file_type":"gzip compressed data, last modified: Wed Jul 15 02:08:19 2015, from Unix","programming_language":null,"is_binary":true,"is_text":false,"is_archive":true,"is_media":false,"is_source":false,"is_script":false,"licenses":[],"license_expressions":[],"holders":[],"copyrights":[],"authors":[],"origin_summary":{},"summarized_to":null,"files_count":0,"dirs_count":0,"size_count":0,"scan_errors":[]}]}
1+
{
2+
"headers": [
3+
{
4+
"tool_name": "scancode-toolkit",
5+
"tool_version": "3.0.2.post622.ca4dcb2.dirty.20190530214353",
6+
"options": {
7+
"input": [
8+
"samples/arch"
9+
],
10+
"--copyright": true,
11+
"--info": true,
12+
"--json": "no_null.json",
13+
"--license": true
14+
},
15+
"notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.",
16+
"start_timestamp": "2019-06-07T004635.398786",
17+
"end_timestamp": "2019-06-07T004639.535534",
18+
"message": null,
19+
"errors": [],
20+
"extra_data": {
21+
"files_count": 1
22+
}
23+
},
24+
{
25+
"tool_name": "scancode-toolkit",
26+
"tool_version": "3.0.2.post622.ca4dcb2.dirty.20190530214353",
27+
"options": {
28+
"input": [
29+
"no-null-in-origin-summary.json"
30+
],
31+
"--from-json": true,
32+
"--json-pp": "no-null-in-origin-summary-expected.json",
33+
"--origin-summary": true
34+
},
35+
"notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.",
36+
"start_timestamp": "2019-06-10T234741.859959",
37+
"end_timestamp": "2019-06-10T234741.867201",
38+
"message": null,
39+
"errors": [],
40+
"extra_data": {
41+
"files_count": 1
42+
}
43+
}
44+
],
45+
"summarized_directories": {},
46+
"files": [
47+
{
48+
"path": "arch",
49+
"type": "directory",
50+
"name": "arch",
51+
"base_name": "arch",
52+
"extension": "",
53+
"size": 0,
54+
"date": null,
55+
"sha1": null,
56+
"md5": null,
57+
"mime_type": null,
58+
"file_type": null,
59+
"programming_language": null,
60+
"is_binary": false,
61+
"is_text": false,
62+
"is_archive": false,
63+
"is_media": false,
64+
"is_source": false,
65+
"is_script": false,
66+
"licenses": [],
67+
"license_expressions": [],
68+
"holders": [],
69+
"copyrights": [],
70+
"authors": [],
71+
"origin_summary": {},
72+
"summarized_to": null,
73+
"files_count": 1,
74+
"dirs_count": 0,
75+
"size_count": 28103,
76+
"scan_errors": []
77+
},
78+
{
79+
"path": "arch/zlib.tar.gz",
80+
"type": "file",
81+
"name": "zlib.tar.gz",
82+
"base_name": "zlib",
83+
"extension": ".tar.gz",
84+
"size": 28103,
85+
"date": "2019-04-23",
86+
"sha1": "576f0ccfe534d7f5ff5d6400078d3c6586de3abd",
87+
"md5": "20b2370751abfc08bb3556c1d8114b5a",
88+
"mime_type": "application/x-gzip",
89+
"file_type": "gzip compressed data, last modified: Wed Jul 15 02:08:19 2015, from Unix",
90+
"programming_language": null,
91+
"is_binary": true,
92+
"is_text": false,
93+
"is_archive": true,
94+
"is_media": false,
95+
"is_source": false,
96+
"is_script": false,
97+
"licenses": [],
98+
"license_expressions": [],
99+
"holders": [],
100+
"copyrights": [],
101+
"authors": [],
102+
"origin_summary": {},
103+
"summarized_to": null,
104+
"files_count": 0,
105+
"dirs_count": 0,
106+
"size_count": 0,
107+
"scan_errors": []
108+
}
109+
]
110+
}

tests/scancode/data/plugin_origin_summary/no-summary-expected.json

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,53 @@
99
],
1010
"--copyright": true,
1111
"--info": true,
12+
"--json-pp": "no-summary.json",
13+
"--license": true
14+
},
15+
"notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.",
16+
"start_timestamp": "2019-06-06T234629.299676",
17+
"end_timestamp": "2019-06-06T234634.617394",
18+
"message": null,
19+
"errors": [],
20+
"extra_data": {
21+
"files_count": 7
22+
}
23+
},
24+
{
25+
"tool_name": "scancode-toolkit",
26+
"tool_version": "3.0.2.post622.ca4dcb2.dirty.20190530214353",
27+
"options": {
28+
"input": [
29+
"no-summary.json"
30+
],
31+
"--from-json": true,
1232
"--json-pp": "no-summary-expected.json",
13-
"--license": true,
1433
"--origin-summary": true
1534
},
1635
"notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.",
17-
"start_timestamp": "2019-06-07T012821.074369",
18-
"end_timestamp": "2019-06-07T012825.892004",
36+
"start_timestamp": "2019-06-10T234749.437124",
37+
"end_timestamp": "2019-06-10T234749.457181",
1938
"message": null,
2039
"errors": [],
2140
"extra_data": {
2241
"files_count": 7
2342
}
2443
}
2544
],
45+
"summarized_directories": {
46+
"apache-2.0": {
47+
"Acme Corporation": [
48+
"no_summary/src"
49+
]
50+
},
51+
"mit": {
52+
"Omega Inc.": [
53+
"no_summary/third_party",
54+
"no_summary/third_party/module_2",
55+
"no_summary/third_party/module_3"
56+
]
57+
}
58+
},
2659
"files": [
2760
{
2861
"path": "no_summary",

tests/scancode/test_plugin_summary.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,20 @@ class TestOriginSummary(FileDrivenTesting):
4141
def test_is_majority_above_threshold(self):
4242
files_count = 10
4343
src_count = 8
44-
assert is_majority(src_count, files_count)
44+
threshold = None
45+
assert is_majority(src_count, files_count, threshold)
4546

4647
def test_is_majority_below_threshold(self):
4748
files_count = 10
4849
src_count = 7
49-
assert not is_majority(src_count, files_count)
50+
threshold = None
51+
assert not is_majority(src_count, files_count, threshold)
52+
53+
def test_is_majority_set_custom_threshold(self):
54+
files_count = 10
55+
src_count = 6
56+
threshold = 0.5
57+
assert is_majority(src_count, files_count, threshold)
5058

5159
def test_origin_summary_clear_summary(self):
5260
scan_loc = self.get_test_loc('plugin_origin_summary/clear-summary.json')

0 commit comments

Comments
 (0)