Skip to content

Commit 3fefbee

Browse files
committed
fixed: test_utils.py::TestUtils::test_update_from_license_info_no_license_changes
Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
1 parent 65508e0 commit 3fefbee

3 files changed

Lines changed: 58 additions & 32 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.1.0",
4+
"scancode_options": {
5+
"--license": true,
6+
"--info": true
7+
},
8+
"files_count": 1,
9+
"files": [
10+
{
11+
"path":"test/path.txt",
12+
"name": "path.txt",
13+
"sha1": "a",
14+
"original_path": "",
15+
"licenses": [
16+
{
17+
"key": "gpl-2.0",
18+
"score": 70.0,
19+
"short_name": "GPL 2.0",
20+
"category": "Copyleft"
21+
}
22+
]
23+
}
24+
]
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.1.0",
4+
"scancode_options": {
5+
"--license": true,
6+
"--info": true
7+
},
8+
"files_count": 1,
9+
"files": [
10+
{
11+
"path":"test/path.txt",
12+
"name": "path.txt",
13+
"sha1": "a_modified",
14+
"original_path": "",
15+
"licenses": [
16+
{
17+
"key": "gpl-2.0",
18+
"score": 70.0,
19+
"short_name": "GPL 2.0",
20+
"category": "Copyleft"
21+
}
22+
]
23+
}
24+
]
25+
}

tests/test_utils.py

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@
3636
from click.testing import CliRunner
3737

3838
from commoncode.testcase import FileBasedTesting
39+
from commoncode.resource import VirtualCodebase
3940
import deltacode
4041
from deltacode import utils
4142
from deltacode import models
43+
from deltacode import DeltaCode
4244

4345

4446
unique_categories = set([
@@ -93,41 +95,15 @@ def test_update_from_license_info_no_license_key_value(self):
9395
assert len(test_delta.factors) == 0
9496

9597
def test_update_from_license_info_no_license_changes(self):
96-
test_file_new = models.File({
97-
'path':'/test/path.txt',
98-
'name': 'path.txt',
99-
'sha1': 'a',
100-
'original_path': '',
101-
"licenses": [
102-
{
103-
"key": "gpl-2.0",
104-
"score": 70.0,
105-
"short_name": "GPL 2.0",
106-
"category": "Copyleft"
107-
}
108-
]
109-
})
110-
test_file_old = models.File({
111-
'path':'/test/path.txt',
112-
'name': 'path.txt',
113-
'sha1': 'a_modified',
114-
'original_path': '',
115-
"licenses": [
116-
{
117-
"key": "gpl-2.0",
118-
"score": 70.0,
119-
"short_name": "GPL 2.0",
120-
"category": "Copyleft"
121-
}
122-
]
123-
})
98+
test_scan_new = self.get_test_loc('utils/update_from_license_info_no_license_changes_new.json')
99+
test_scan_old = self.get_test_loc('utils/update_from_license_info_no_license_changes_old.json')
124100

125-
test_delta = deltacode.Delta(20, test_file_new, test_file_old)
101+
result = DeltaCode(test_scan_new, test_scan_old, {})
126102

127-
utils.update_modified_from_license_info(test_delta, unique_categories)
103+
utils.update_modified_from_license_info(result.deltas, unique_categories)
128104

129-
assert test_delta.score == 20
130-
assert len(test_delta.factors) == 0
105+
assert result.deltas[0].score == 20
106+
assert len(result.deltas[0].factors) == 0
131107

132108
def test_update_from_license_info_single_license_change(self):
133109
test_file_new = models.File({

0 commit comments

Comments
 (0)