Skip to content

Commit cb71eb3

Browse files
committed
* Add more test code Signed-off-by: Chin Yeung Li <[email protected]>
1 parent db39b1e commit cb71eb3

File tree

3 files changed

+97
-19
lines changed

3 files changed

+97
-19
lines changed

tests/test_util.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,67 @@ def test_load_non_list_json(self):
328328
result = util.load_json(test_file)
329329
assert expected == result
330330

331+
def test_load_json_from_abc_mgr(self):
332+
test_file = get_test_loc('load/aboutcode_manager_exported.json')
333+
mapping_file = get_test_loc('custom-mapping-file/mapping.config')
334+
expected = [dict(OrderedDict(
335+
[('license_expression', 'apache-2.0'),
336+
('copyright', 'Copyright (c) 2017 nexB Inc.'),
337+
('licenses',[{'key':'apache-2.0'}]),
338+
('copyrights',[{'statements':['Copyright (c) 2017 nexB Inc.']}]),
339+
('about_file_path', 'ScanCode'),
340+
('review_status', 'Analyzed'),
341+
('name', 'ScanCode'),
342+
('version', '2.2.1'),
343+
('owner', 'nexB Inc.'),
344+
('code_type', 'Source'),
345+
('is_modified', False),
346+
('is_deployed', False),
347+
('feature', ''),
348+
('purpose', ''),
349+
('homepage_url', None),
350+
('download_url',None),
351+
('license_url',None),
352+
('notice_url',None),
353+
('programming_language','Python'),
354+
('notes',''),
355+
('fileId',8458),
356+
]
357+
))]
358+
result = util.load_json(test_file, use_mapping=False, mapping_file=mapping_file)
359+
assert expected == result
360+
361+
def test_load_json_from_scancode(self):
362+
test_file = get_test_loc('load/scancode_info.json')
363+
mapping_file = get_test_loc('custom-mapping-file/mapping.config')
364+
expected = [dict(OrderedDict(
365+
[('about_file_path', 'Api.java'),
366+
('type', 'file'),
367+
('name', 'Api.java'),
368+
('base_name', 'Api'),
369+
('extension', '.java'),
370+
('size', 5074),
371+
('date', '2017-07-15'),
372+
('sha1', 'c3a48ec7e684a35417241dd59507ec61702c508c'),
373+
('md5', '326fb262bbb9c2ce32179f0450e24601'),
374+
('mime_type', 'text/plain'),
375+
('file_type', 'ASCII text'),
376+
('programming_language', 'Java'),
377+
('is_binary', False),
378+
('is_text', True),
379+
('is_archive', False),
380+
('is_media', False),
381+
('is_source', True),
382+
('is_script', False),
383+
('files_count', 0),
384+
('dirs_count', 0),
385+
('size_count', 0),
386+
('scan_errors', []),
387+
]
388+
))]
389+
result = util.load_json(test_file, use_mapping=False, mapping_file=mapping_file)
390+
assert expected == result
391+
331392
def test_get_about_file_path_from_csv_using_mapping(self):
332393
test_file = get_test_loc('util/about.csv')
333394
expected = ['about.ABOUT']
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"scancode_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.",
3+
"scancode_version": "2.9.0b1.post32.fea65d3",
4+
"scancode_options": {
5+
"input": "C:\\Users\\CYL\\Downloads\\io\\swagger\\annotations\\Api.java",
6+
"--info": true,
7+
"--json-pp": "C:\\Users\\CYL\\Desktop\\test\\scancode-info.json"
8+
},
9+
"files_count": 1,
10+
"files": [
11+
{
12+
"path": "Api.java",
13+
"type": "file",
14+
"name": "Api.java",
15+
"base_name": "Api",
16+
"extension": ".java",
17+
"size": 5074,
18+
"date": "2017-07-15",
19+
"sha1": "c3a48ec7e684a35417241dd59507ec61702c508c",
20+
"md5": "326fb262bbb9c2ce32179f0450e24601",
21+
"mime_type": "text/plain",
22+
"file_type": "ASCII text",
23+
"programming_language": "Java",
24+
"is_binary": false,
25+
"is_text": true,
26+
"is_archive": false,
27+
"is_media": false,
28+
"is_source": true,
29+
"is_script": false,
30+
"files_count": 0,
31+
"dirs_count": 0,
32+
"size_count": 0,
33+
"scan_errors": []
34+
}
35+
]
36+
}

tests/testdata/load/scancode_result.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)