Skip to content

Commit b129e79

Browse files
committed
Fixed the test code
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent fda0a9e commit b129e79

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

src/attributecode/attrib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def generate(abouts, template_string=None):
4848
try:
4949
captured_license = []
5050
license_key_and_context = {}
51+
sorted_license_key_and_context = {}
5152
license_text_name_and_key = {}
5253
for about in abouts:
5354
# about.license_file.value is a OrderDict with license_text_name as

src/attributecode/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,8 +1251,8 @@ def by_license(abouts):
12511251
grouped[''] = []
12521252
no_license = grouped['']
12531253
for about in abouts:
1254-
if about.license.value:
1255-
special_char_in_expression, lic_list = parse_license_expression(about.license.value)
1254+
if about.license_expression.value:
1255+
special_char_in_expression, lic_list = parse_license_expression(about.license_expression.value)
12561256
if not special_char_in_expression:
12571257
for lic in lic_list:
12581258
if lic in grouped:

tests/test_model.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ def test_About_dumps_does_not_transform_strings_in_lists(self):
584584
home_url: http://dejacode.org
585585
notes:
586586
license: apache-2.0 public-domain
587+
license_expression:
587588
license_name:
588589
license_file: apache-2.0.LICENSE
589590
license_url:
@@ -656,6 +657,7 @@ def test_field_names(self):
656657
'home_url',
657658
'notes',
658659
'license',
660+
'license_expression',
659661
'license_name',
660662
'license_file',
661663
'license_url',
@@ -754,6 +756,7 @@ def test_About_dumps_all_fields_if_not_present_with_absent_True(self):
754756
home_url:
755757
notes:
756758
license:
759+
license_expression:
757760
license_name:
758761
license_file:
759762
license_url:
@@ -864,6 +867,7 @@ def test_About_as_dict_with_present(self):
864867
'download_url': u'',
865868
'home_url': u'',
866869
'license': u'apache-2.0',
870+
'license_expression': u'',
867871
'license_file': u'',
868872
'license_name': u'',
869873
'license_url': u'',
@@ -1143,7 +1147,7 @@ def test_collect_inventory_with_license_expression(self):
11431147
errors, abouts = model.collect_inventory(test_loc)
11441148
assert [] == errors
11451149
expected_lic = u'mit or apache-2.0'
1146-
returned_lic = abouts[0].license.value
1150+
returned_lic = abouts[0].license_expression.value
11471151
assert expected_lic == returned_lic
11481152

11491153
def test_parse_license_expression(self):
@@ -1246,13 +1250,13 @@ def test_unique(self):
12461250
def test_by_license(self):
12471251
base_dir = 'some_dir'
12481252
a = model.About()
1249-
a.load_dict({'license': u'apache-2.0 and cddl-1.0', }, base_dir)
1253+
a.load_dict({'license_expression': u'apache-2.0 and cddl-1.0', }, base_dir)
12501254
b = model.About()
1251-
b.load_dict({'license': u'apache-2.0', }, base_dir)
1255+
b.load_dict({'license_expression': u'apache-2.0', }, base_dir)
12521256
c = model.About()
12531257
c.load_dict({}, base_dir)
12541258
d = model.About()
1255-
d.load_dict({'license': u'bsd', }, base_dir)
1259+
d.load_dict({'license_expression': u'bsd', }, base_dir)
12561260

12571261
abouts = [a, b, c, d]
12581262
results = model.by_license(abouts)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
about_file_path,about_resource_path,about_resource,name,version,download_url,description,home_url,notes,license,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,,,,,,
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,/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,,,,,,

tests/testdata/load/expected.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
about_file_path,about_resource_path,about_resource,name,version,download_url,description,home_url,notes,license,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,,,,,,,,,,,,,,,,,,,,,,,,,,,,
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+
/load/this.ABOUT,/load/,.,AboutCode,0.11.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
about_resource: .
22
name: test
3-
license: mit or apache-2.0
3+
license_expression: mit or apache-2.0
44
license_url: |
55
https://enterprise.dejacode.com/urn/?urn=urn:dje:license:mit
66
https://enterprise.dejacode.com/urn/?urn=urn:dje:license:apache-2.0

0 commit comments

Comments
 (0)