Skip to content

Commit 8b72bae

Browse files
committed
Create test code for supporting 'about_resource_path' #287
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 1731a88 commit 8b72bae

File tree

10 files changed

+47
-10
lines changed

10 files changed

+47
-10
lines changed

tests/test_model.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -826,10 +826,6 @@ def test_About_as_dict_contains_special_paths(self):
826826
result = as_dict[model.About.about_file_path_attr]
827827
assert expected == result
828828

829-
expected = 'complete'
830-
result = as_dict[model.About.about_resource_path_attr]
831-
assert expected == result
832-
833829
def test_About_as_dict_with_empty(self):
834830
test_file = get_test_loc('as_dict/about.ABOUT')
835831
a = model.About(test_file, about_file_path='complete/about.ABOUT')
@@ -1211,9 +1207,35 @@ def test_collect_inventory_basic_from_directory(self):
12111207
expected = get_test_loc('inventory/basic/expected.csv')
12121208
self.check_csv(expected, result)
12131209

1214-
# FIXME: The self.chec_csv is failing because there are many keys in the ABOUT files that are
1210+
def test_collect_inventory_with_about_resource_path_from_directory(self):
1211+
location = get_test_loc('inventory/basic_with_about_resource_path')
1212+
result = get_temp_file()
1213+
errors, abouts = model.collect_inventory(location)
1214+
1215+
model.write_output(abouts, result, format = 'csv')
1216+
1217+
expected_errors = []
1218+
assert expected_errors == errors
1219+
1220+
expected = get_test_loc('inventory/basic_with_about_resource_path/expected.csv')
1221+
self.check_csv(expected, result)
1222+
1223+
def test_collect_inventory_with_no_about_resource_from_directory(self):
1224+
location = get_test_loc('inventory/no_about_resource_key')
1225+
result = get_temp_file()
1226+
errors, abouts = model.collect_inventory(location)
1227+
1228+
model.write_output(abouts, result, format = 'csv')
1229+
1230+
expected_errors = [Error(CRITICAL, u'about/about.ABOUT: Field about_resource is required')]
1231+
assert expected_errors == errors
1232+
1233+
expected = get_test_loc('inventory/no_about_resource_key/expected.csv')
1234+
self.check_csv(expected, result)
1235+
1236+
# FIXME: The self.check_csv is failing because there are many keys in the ABOUT files that are
12151237
# not supported. Instead of removing all the non-supported keys in the output
1216-
# and do the comparson, it may be best to apply the mapping to include theses keys
1238+
# and do the comparison, it may be best to apply the mapping to include theses keys
12171239
@expectedFailure
12181240
def test_collect_inventory_complex_from_directory(self):
12191241
location = get_test_loc('inventory/complex')

tests/test_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ def test_load_json(self):
275275
test_file = get_test_loc('load/expected.json')
276276
expected = [OrderedDict(
277277
[('about_file_path', '/load/this.ABOUT'),
278+
('about_resource_path', '.'),
278279
('about_resource', '.'),
279-
('about_resource_path', '/load/'),
280280
('name', 'AboutCode'),
281281
('version', '0.11.0')])
282282
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
about_file_path,about_resource_path,about_resource,name,version,download_url,description,home_url,notes,license,license_expression,license_name,license_file,license_url,copyright,notice_file,notice_url,redistribute,attribute,track_change,modified,changelog_file,owner,owner_url,contact,author,vcs_tool,vcs_repository,vcs_path,vcs_tag,vcs_branch,vcs_revision,checksum,spec_version
2-
/about/about.ABOUT,/about/,.,AboutCode,0.11.0,,AboutCode is a tool to process ABOUT files. An ABOUT file is a file.,http://dejacode.org,,apache-2.0,,,apache-2.0.LICENSE,,Copyright (c) 2013-2014 nexB Inc.,NOTICE,,,,,,,nexB Inc.,,,"Jillian Daguil, Chin Yeung Li, Philippe Ombredanne, Thomas Druez",git,https://github.com/dejacode/about-code-tool.git,,,,,,
2+
/about/about.ABOUT,.,.,AboutCode,0.11.0,,AboutCode is a tool to process ABOUT files. An ABOUT file is a file.,http://dejacode.org,,apache-2.0,,,apache-2.0.LICENSE,,Copyright (c) 2013-2014 nexB Inc.,NOTICE,,,,,,,nexB Inc.,,,"Jillian Daguil, Chin Yeung Li, Philippe Ombredanne, Thomas Druez",git,https://github.com/dejacode/about-code-tool.git,,,,,,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
about_resource: apache-2.0.LICENSE
2+
name: Apache License 2.0
3+
4+
about_resource_path: |
5+
./apache-2.0.LICENSE
6+
../../complex/about/apache-2.0.LICENSE
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
about_file_path,about_resource_path,about_resource,name,version,download_url,description,home_url,notes,license,license_expression,license_name,license_file,license_url,copyright,notice_file,notice_url,redistribute,attribute,track_change,modified,changelog_file,owner,owner_url,contact,author,vcs_tool,vcs_repository,vcs_path,vcs_tag,vcs_branch,vcs_revision,checksum,spec_version
2+
/about/about_with_about_resource_path.ABOUT,"./apache-2.0.LICENSE
3+
../../complex/about/apache-2.0.LICENSE",apache-2.0.LICENSE,Apache License 2.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name: AboutCode
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
about_file_path,about_resource_path,about_resource,name,version,download_url,description,home_url,notes,license,license_expression,license_name,license_file,license_url,copyright,notice_file,notice_url,redistribute,attribute,track_change,modified,changelog_file,owner,owner_url,contact,author,vcs_tool,vcs_repository,vcs_path,vcs_tag,vcs_branch,vcs_revision,checksum,spec_version
2+
/about/about.ABOUT,,,AboutCode,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

tests/testdata/load/expected.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
about_file_path,about_resource_path,about_resource,name,version,download_url,description,home_url,notes,license,license_expression,license_name,license_file,license_url,copyright,notice_file,notice_url,redistribute,attribute,track_change,modified,changelog_file,owner,owner_url,contact,author,vcs_tool,vcs_repository,vcs_path,vcs_tag,vcs_branch,vcs_revision,checksum,spec_version
2-
/load/this.ABOUT,/load/,.,AboutCode,0.11.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
2+
/load/this.ABOUT,.,.,AboutCode,0.11.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

tests/testdata/load/expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"about_file_path": "/load/this.ABOUT",
4-
"about_resource_path": "/load/",
4+
"about_resource_path": ".",
55
"about_resource": ".",
66
"name": "AboutCode",
77
"version": "0.11.0"

0 commit comments

Comments
 (0)