Skip to content

Commit 6ae711b

Browse files
committed
#479 - Fix/Update test code/case
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent b698c6b commit 6ae711b

File tree

2 files changed

+39
-17
lines changed

2 files changed

+39
-17
lines changed

tests/test_attrib.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def test_generate_from_collected_inventory_wih_custom_temaplte(self):
8989
license_dict = {}
9090
is_about_input = True
9191
min_license_score=0
92-
error, result = attrib.generate(abouts, is_about_input, license_dict, min_license_score, template=template)
92+
scancode = False
93+
error, result = attrib.generate(abouts, is_about_input, license_dict, scancode, min_license_score, template=template)
9394
assert expected == result
9495
assert not error
9596

@@ -101,8 +102,9 @@ def test_generate_with_default_template(self):
101102
license_dict = {}
102103
is_about_input = True
103104
min_license_score=0
105+
scancode = False
104106

105-
error, result = attrib.generate_from_file(abouts, is_about_input, license_dict, min_license_score)
107+
error, result = attrib.generate_from_file(abouts, is_about_input, license_dict, scancode, min_license_score)
106108
assert not error
107109

108110
expected_file = get_test_loc(
@@ -140,9 +142,12 @@ def test_lic_key_name_sync(self):
140142
def test_scancode_input(self):
141143
test_file = get_test_loc('test_attrib/scancode_input/clean-text-0.3.0-mod-lceupi.json')
142144
errors, abouts = gen.load_inventory(test_file, scancode=True)
143-
expected_errors = [(40, 'Field about_resource: Unable to verify path: isc_lic.py: No base directory provided')]
145+
# No validation is done for the scancode input as it usually contains duplicated entry of
146+
# detected licenses which is not allow in the current spec.
147+
#expected_errors = [(40, 'Field about_resource: Unable to verify path: isc_lic.py: No base directory provided')]
144148
result = [(level, e) for level, e in errors if level > INFO]
145-
assert expected_errors == result
149+
#assert expected_errors == result
150+
assert result == []
146151

147152
lic_dict = {'isc': ['ISC License',
148153
'isc.LICENSE',
@@ -153,7 +158,8 @@ def test_scancode_input(self):
153158
'Permission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n"Software"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.',
154159
'https://scancode-licensedb.aboutcode.org/mit.LICENSE']}
155160
is_about_input = False
156-
errors, result = attrib.generate_from_file(abouts, is_about_input, lic_dict, min_license_score=0)
161+
scancode = True
162+
errors, result = attrib.generate_from_file(abouts, is_about_input, lic_dict, scancode, min_license_score=0)
157163
expected_errors = []
158164
#result = [(level, e) for level, e in errors if level > INFO]
159165
#assert expected_errors == result
@@ -171,7 +177,7 @@ def test_scancode_input(self):
171177
# expected doesn't work well, it works after removed all the newline and spaces
172178
#assert expected == result
173179
#assert expected.splitlines(False) == result.splitlines(False)
174-
assert expected.replace('\n','').replace(' ','') == result.replace('\n','').replace(' ','')
180+
assert expected.replace('\n','').replace(' ','').replace('\t','') == result.replace('\n','').replace(' ','').replace('\t','')
175181

176182
def test_generate_with_csv(self):
177183
test_file = get_test_loc('test_attrib/default_template/simple_sample.csv')
@@ -182,7 +188,9 @@ def test_generate_with_csv(self):
182188
'Permission to use, copy, modify, and/or distribute this software for any purpose\nwith or without fee is hereby granted, provided that the above copyright notice\nand this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\nOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\nTORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n',
183189
'https://scancode-licensedb.aboutcode.org/isc.LICENSE']}
184190
is_about_input = False
185-
error, result = attrib.generate_from_file(abouts, is_about_input, lic_dict, min_license_score=0)
191+
scancode = False
192+
193+
error, result = attrib.generate_from_file(abouts, is_about_input, lic_dict, scancode, min_license_score=0)
186194
assert not error
187195

188196
expected_file = get_test_loc(

tests/testdata/test_attrib/scancode_input/expect.html

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<!doctype html>
32
<html>
43
<head>
@@ -20,27 +19,42 @@ <h2> </h2>
2019

2120
<div class="oss-table-of-contents">
2221

23-
<p><a href="#component_0">isc_lic.py</a></p>
22+
23+
24+
25+
26+
<p><a href="#component_0">isc_lic.py</a></p>
27+
28+
29+
30+
2431

2532
</div>
2633

2734
<hr/>
2835

2936

30-
<div class="oss-component" id="component_0">
31-
<h3 class="component-name">isc_lic.py </h3>
37+
38+
39+
40+
41+
<div class="oss-component" id="component_0">
42+
<h3 class="component-name">isc_lic.py </h3>
43+
3244

3345

3446

3547

3648

3749

38-
<p>Full text of <a class="isc" href="#component-license-isc"> isc</a> is available at the end of this document.</p>
50+
<p>This component is licensed under isc</p>
3951

52+
<p>Full text of <a class="isc" href="#component-license-isc"> isc</a> is available at the end of this document.</p>
4053

4154

42-
<p>Full text of <a class="mit" href="#component-license-mit"> mit</a> is available at the end of this document.</p>
55+
<p>This component is licensed under mit</p>
4356

57+
<p>Full text of <a class="mit" href="#component-license-mit"> mit</a> is available at the end of this document.</p>
4458

4559

4660

@@ -52,8 +66,8 @@ <h3 class="component-name">isc_lic.py </h3>
5266
<h3>Common Licenses Used in This Product</h3>
5367

5468

55-
<h3 id="component-license-isc">isc</h3>
56-
<pre> Permission to use, copy, modify, and/or distribute this software for any purpose
69+
<h3 id="component-license-isc">isc</h3>
70+
<pre> Permission to use, copy, modify, and/or distribute this software for any purpose
5771
with or without fee is hereby granted, provided that the above copyright notice
5872
and this permission notice appear in all copies.
5973

@@ -68,8 +82,8 @@ <h3 id="component-license-isc">isc</h3>
6882

6983

7084

71-
<h3 id="component-license-mit">mit</h3>
72-
<pre> Permission is hereby granted, free of charge, to any person obtaining
85+
<h3 id="component-license-mit">mit</h3>
86+
<pre> Permission is hereby granted, free of charge, to any person obtaining
7387
a copy of this software and associated documentation files (the
7488
&#34;Software&#34;), to deal in the Software without restriction, including
7589
without limitation the rights to use, copy, modify, merge, publish,

0 commit comments

Comments
 (0)