Repository navigation
Expand file tree
/
Copy pathtest_todo.py
More file actions
108 lines (95 loc) · 4.52 KB
/
Copy pathtest_todo.py
File metadata and controls
108 lines (95 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# ScanCode 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/scancode-toolkit for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
from copy import copy
from os import path
import pytest
from commoncode.testcase import FileDrivenTesting
from scancode.cli_test_utils import check_json_scan
from scancode.cli_test_utils import run_scan_click
from scancode_config import REGEN_TEST_FIXTURES
class TestScanReview(FileDrivenTesting):
test_data_dir = path.join(path.dirname(__file__), 'data/todo/')
def test_end2end_todo_works_on_codebase_without_ambiguous_detections(self):
test_dir = self.get_test_loc('no_todo/base64-arraybuffer-0.1.4/')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('no_todo/base64-arraybuffer.expected.json')
run_scan_click([
'-clip',
'--todo',
'--json-pp', result_file, test_dir
])
check_json_scan(expected_file, result_file, remove_uuid=True, remove_file_date=True, regen=REGEN_TEST_FIXTURES)
def test_end2end_todo_works_on_unknown_licenses_plain(self):
test_dir = self.get_test_loc('todo_present/unknown-license.txt')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('todo_present/unknown-license-expected.json')
run_scan_click([
'--license',
'--license-text',
'--unknown-licenses',
'--todo',
'--json-pp', result_file, test_dir
])
check_json_scan(expected_file, result_file, remove_uuid=True, remove_file_date=True, regen=REGEN_TEST_FIXTURES)
def test_end2end_todo_works_on_unknown_licenses_diagnostics(self):
test_dir = self.get_test_loc('todo_present/unknown-license.txt')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('todo_present/unknown-license-expected-diag.json')
run_scan_click([
'--license',
'--license-text',
'--license-diagnostics',
'--license-text-diagnostics',
'--unknown-licenses',
'--todo',
'--json-pp', result_file, test_dir
])
check_json_scan(expected_file, result_file, remove_uuid=True, remove_file_date=True, regen=REGEN_TEST_FIXTURES)
def test_end2end_todo_works_on_package_manifest_without_version(self):
test_dir = self.get_test_loc('todo_present/incomplete-setup.cfg')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('todo_present/incomplete-setup-cfg-expected.json')
run_scan_click([
'--package',
'--todo',
'--json-pp', result_file, test_dir
])
check_json_scan(expected_file, result_file, remove_uuid=True, remove_file_date=True, regen=REGEN_TEST_FIXTURES)
def test_end2end_todo_works_on_from_json(self):
test_dir = self.get_test_loc('todo_present/unknown-license.txt')
intermediate_result_file = self.get_temp_file('json')
final_result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('todo_present/unknown-license-expected-diag.json')
run_scan_click([
'--license',
'--license-text',
'--license-diagnostics',
'--license-text-diagnostics',
'--unknown-licenses',
'--json-pp', intermediate_result_file, test_dir
])
run_scan_click([
'--todo',
'--from-json', intermediate_result_file,
'--json-pp', final_result_file
])
check_json_scan(expected_file, final_result_file, remove_uuid=True, remove_file_date=True, regen=REGEN_TEST_FIXTURES)
def test_end2end_todo_works_on_license_clues_diagnostics(self):
test_dir = self.get_test_loc('todo_present/README.multi-orig-tarball-package')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('todo_present/README.multi-orig-tarball-package-expected-diag.json')
run_scan_click([
'--license',
'--license-text',
'--license-diagnostics',
'--license-text-diagnostics',
'--todo',
'--json-pp', result_file, test_dir
])
check_json_scan(expected_file, result_file, remove_uuid=True, remove_file_date=True, regen=REGEN_TEST_FIXTURES)