diff --git a/.pytest_cache/v/cache/lastfailed b/.pytest_cache/v/cache/lastfailed new file mode 100644 index 00000000..31e349ad --- /dev/null +++ b/.pytest_cache/v/cache/lastfailed @@ -0,0 +1,10 @@ +{ + "src/deltacode/__init__.py": true, + "src/deltacode/cli.py": true, + "src/deltacode/models.py": true, + "src/deltacode/utils.py": true, + "tests/test_cli.py": true, + "tests/test_deltacode.py": true, + "tests/test_models.py": true, + "tests/test_utils.py": true +} \ No newline at end of file diff --git a/.pytest_cache/v/cache/nodeids b/.pytest_cache/v/cache/nodeids new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/.pytest_cache/v/cache/nodeids @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/etc/scripts/testdata/json2csv/copyright_and_license_info_added.csv b/etc/scripts/testdata/json2csv/copyright_and_license_info_added.csv index 2140cb0b..e7325a47 100644 --- a/etc/scripts/testdata/json2csv/copyright_and_license_info_added.csv +++ b/etc/scripts/testdata/json2csv/copyright_and_license_info_added.csv @@ -1,2 +1,2 @@ Score,Factors,Path,Name,Type,Size,Old Path -70,modified license info added copyleft added copyright info added,path.txt,path.txt,file,300, +70,modified license info added copyright info added,path.txt,path.txt,file,300, diff --git a/etc/scripts/testdata/json2csv/copyright_and_license_info_added.json b/etc/scripts/testdata/json2csv/copyright_and_license_info_added.json index 1d1e17e3..fe4de341 100644 --- a/etc/scripts/testdata/json2csv/copyright_and_license_info_added.json +++ b/etc/scripts/testdata/json2csv/copyright_and_license_info_added.json @@ -1,8 +1,8 @@ { "deltacode_notice": "Generated with DeltaCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nDeltaCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nDeltaCode is a free software codebase-comparison tool from nexB Inc. and others.\nVisit https://github.com/nexB/deltacode/ for support and download.", "deltacode_options": { - "new_scan_path": "C:/code/nexb/dev/deltacode/tests/data/cli/copyright_and_license_info_added_new.json", - "old_scan_path": "C:/code/nexb/dev/deltacode/tests/data/cli/copyright_and_license_info_added_old.json", + "--new": "C:/code/nexb/dev/deltacode/tests/data/cli/copyright_and_license_info_added_new.json", + "--old": "C:/code/nexb/dev/deltacode/tests/data/cli/copyright_and_license_info_added_old.json", "--all-delta-types": false }, "deltacode_version": "1.0.0.post37.cba847f.dirty.20180402221516", diff --git a/etc/scripts/testdata/json2csv/license_info_added_copyright_info_removed.csv b/etc/scripts/testdata/json2csv/license_info_added_copyright_info_removed.csv index 6bede931..c8c798f8 100644 --- a/etc/scripts/testdata/json2csv/license_info_added_copyright_info_removed.csv +++ b/etc/scripts/testdata/json2csv/license_info_added_copyright_info_removed.csv @@ -1,2 +1,2 @@ Score,Factors,Path,Name,Type,Size,Old Path -70,modified license info added copyleft added copyright info removed,path.txt,path.txt,file,300, +70,modified license info added copyright info removed,path.txt,path.txt,file,300, diff --git a/etc/scripts/testdata/json2csv/license_info_added_copyright_info_removed.json b/etc/scripts/testdata/json2csv/license_info_added_copyright_info_removed.json index 4dc8d4b9..daa2e5cf 100644 --- a/etc/scripts/testdata/json2csv/license_info_added_copyright_info_removed.json +++ b/etc/scripts/testdata/json2csv/license_info_added_copyright_info_removed.json @@ -1,8 +1,8 @@ { "deltacode_notice": "Generated with DeltaCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nDeltaCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nDeltaCode is a free software codebase-comparison tool from nexB Inc. and others.\nVisit https://github.com/nexB/deltacode/ for support and download.", "deltacode_options": { - "new_scan_path": "C:/code/nexb/dev/deltacode/tests/data/cli/license_info_added_copyright_info_removed_new.json", - "old_scan_path": "C:/code/nexb/dev/deltacode/tests/data/cli/license_info_added_copyright_info_removed_old.json", + "--new": "C:/code/nexb/dev/deltacode/tests/data/cli/license_info_added_copyright_info_removed_new.json", + "--old": "C:/code/nexb/dev/deltacode/tests/data/cli/license_info_added_copyright_info_removed_old.json", "--all-delta-types": false }, "deltacode_version": "1.0.0.post37.cba847f.dirty.20180402221516", diff --git a/etc/scripts/testdata/json2csv/new_license_added.csv b/etc/scripts/testdata/json2csv/new_license_added.csv index 17862de2..7dfd7ae9 100644 --- a/etc/scripts/testdata/json2csv/new_license_added.csv +++ b/etc/scripts/testdata/json2csv/new_license_added.csv @@ -1,4 +1,4 @@ Score,Factors,Path,Name,Type,Size,Old Path +50,modified license change,some/path/a/a1.py,a1.py,file,300, 20,modified,some/path/c/c1.py,c1.py,file,300, 30,modified license change,some/path/b/b1.py,b1.py,file,300, -50,modified license change copyleft added,some/path/a/a1.py,a1.py,file,300, diff --git a/etc/scripts/testdata/json2csv/new_license_added.json b/etc/scripts/testdata/json2csv/new_license_added.json index 173c5343..4ad2c8f5 100644 --- a/etc/scripts/testdata/json2csv/new_license_added.json +++ b/etc/scripts/testdata/json2csv/new_license_added.json @@ -1,8 +1,8 @@ { "deltacode_notice": "Generated with DeltaCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nDeltaCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nDeltaCode is a free software codebase-comparison tool from nexB Inc. and others.\nVisit https://github.com/nexB/deltacode/ for support and download.", "deltacode_options": { - "new_scan_path": "C:/code/nexb/dev/deltacode/tests/data/cli/scan_modified_new_license_added.json", - "old_scan_path": "C:/code/nexb/dev/deltacode/tests/data/cli/scan_modified_old_license_added.json", + "--new": "C:/code/nexb/dev/deltacode/tests/data/cli/scan_modified_new_license_added.json", + "--old": "C:/code/nexb/dev/deltacode/tests/data/cli/scan_modified_old_license_added.json", "--all-delta-types": false }, "deltacode_version": "1.0.0.post37.cba847f.dirty.20180402221516", @@ -10,17 +10,39 @@ "deltas": [ { "factors": [ - "modified" + "modified", + "license change" ], - "score": 20, + "score": 50, "new": { - "path": "some/path/c/c1.py", + "path": "some/path/a/a1.py", "type": "file", - "name": "c1.py", + "name": "a1.py", "size": 300, "sha1": "333647771481d39dd3a53f6dc210c26abac37748", - "original_path": "some/path/c/c1.py", + "original_path": "some/path/a/a1.py", "licenses": [ + { + "key": "apache-2.0", + "score": 80.0, + "short_name": "Apache 2.0", + "category": "Permissive", + "owner": null + }, + { + "key": "agpl-2.0", + "score": 70.0, + "short_name": "AGPL 2.0", + "category": "Copyleft", + "owner": null + }, + { + "key": "bsd-simplified", + "score": 100.0, + "short_name": "BSD-Simplified", + "category": "Permissive", + "owner": null + }, { "key": "mit", "score": 100.0, @@ -32,17 +54,30 @@ "copyrights": [] }, "old": { - "path": "some/path/c/c1.py", + "path": "some/path/a/a1.py", "type": "file", - "name": "c1.py", + "name": "a1.py", "size": 300, "sha1": "222647771481d39dd3a53f6dc210c26abac37748", - "original_path": "some/path/c/c1.py", + "original_path": "some/path/a/a1.py", "licenses": [ + {"key": "apache-2.0", + "score": 80.0, + "short_name": "Apache 2.0", + "category": "Permissive", + "owner": null + }, { - "key": "mit", + "key": "public-domain", + "score": 10.0, + "short_name": "Public Domain", + "category": "Public Domain", + "owner": null + }, + { + "key": "bsd-simplified", "score": 100.0, - "short_name": "MIT License", + "short_name": "BSD-Simplified", "category": "Permissive", "owner": null } @@ -52,8 +87,7 @@ }, { "factors": [ - "modified", - "license change" + "modified" ], "score": 30, "new": { @@ -64,27 +98,6 @@ "sha1": "111647771481d39dd3a53f6dc210c26abac37748", "original_path": "some/path/b/b1.py", "licenses": [ - { - "key": "apache-2.0", - "score": 80.0, - "short_name": "Apache 2.0", - "category": "Permissive", - "owner": null - }, - { - "key": "gpl-2.0", - "score": 60.0, - "short_name": "GPL 2.0", - "category": "Copyleft", - "owner": null - }, - { - "key": "bsd-simplified", - "score": 100.0, - "short_name": "BSD-Simplified", - "category": "Permissive", - "owner": null - }, { "key": "mit", "score": 100.0, @@ -104,23 +117,9 @@ "original_path": "some/path/b/b1.py", "licenses": [ { - "key": "mpl-2.0", - "score": 90.0, - "short_name": "MPL 2.0", - "category": "Copyleft Limited", - "owner": null - }, - { - "key": "public-domain", - "score": 10.0, - "short_name": "Public Domain", - "category": "Public Domain", - "owner": null - }, - { - "key": "bsd-simplified", + "key": "mit", "score": 100.0, - "short_name": "BSD-Simplified", + "short_name": "MIT-License", "category": "Permissive", "owner": null } @@ -136,12 +135,12 @@ ], "score": 50, "new": { - "path": "some/path/a/a1.py", + "path": "some/path/c/c1.py", "type": "file", - "name": "a1.py", + "name": "c1.py", "size": 300, "sha1": "000647771481d39dd3a53f6dc210c26abac37748", - "original_path": "some/path/a/a1.py", + "original_path": "some/path/c/c1.py", "licenses": [ { "key": "apache-2.0", @@ -175,12 +174,12 @@ "copyrights": [] }, "old": { - "path": "some/path/a/a1.py", + "path": "some/path/c/c1.py", "type": "file", - "name": "a1.py", + "name": "c1.py", "size": 200, "sha1": "84b647771481d39dd3a53f6dc210c26abac37748", - "original_path": "some/path/a/a1.py", + "original_path": "some/path/c/c1.py", "licenses": [ { "key": "apache-2.0", diff --git a/src/deltacode/utils.py b/src/deltacode/utils.py index 2e6e5073..7b83a5da 100644 --- a/src/deltacode/utils.py +++ b/src/deltacode/utils.py @@ -35,9 +35,9 @@ def update_from_license_info(delta, unique_categories): """ - Increase an 'added' or 'modified' Delta object's 'score' attribute and add - one or more appropriate categories to its 'factors' attribute if there has - been a license change and depending on the nature of that change. + Increase an 'added' or 'modified' Delta object's 'score' attribute and + annotate its 'factors' attribute if there has been a license change and + depending on the nature of that change. """ if delta.is_added(): update_added_from_license_info(delta, unique_categories) @@ -48,70 +48,47 @@ def update_from_license_info(delta, unique_categories): def update_added_from_license_info(delta, unique_categories): """ - Increase an 'added' Delta object's 'score' attribute and add - one or more categories to its 'factors' attribute if there has - been a license change. + Increase an 'added' Delta object's 'score' attribute and annotate its + 'factors' attribute if there has been a license change. """ new_licenses = delta.new_file.licenses or [] new_categories = set(license.category for license in new_licenses) if delta.new_file.has_licenses(): - delta.update(20, 'license info added') - - for category in new_categories: - # no license ==> 'Copyleft Limited'or higher - if category in unique_categories: - delta.update(20, category.lower() + ' added') - # no license ==> 'Permissive' or 'Public Domain' - else: - delta.update(0, category.lower() + ' added') + # delta.update(20, 'license info added') + # + # for category in new_categories: + # # no license ==> 'Copyleft Limited'or higher + # if category in unique_categories: + # delta.update(20, category.lower() + ' added') + # # no license ==> 'Permissive' or 'Public Domain' + # else: + # delta.update(0, category.lower() + ' added') + delta.update(score=20, factor='license info added') return def update_modified_from_license_info(delta, unique_categories): """ - Increase a 'modified' Delta object's 'score' attribute and add - one or more categories to its 'factors' attribute if there has - been a license change. + Increase a 'modified' Delta object's 'score' attribute and annotate its + 'factors' attribute if there has been a license change. """ if not delta.new_file.has_licenses() and delta.old_file.has_licenses(): - delta.update(15, 'license info removed') + delta.update(score=15, factor='license info removed') return new_licenses = delta.new_file.licenses or [] old_licenses = delta.old_file.licenses or [] - new_categories = set(license.category for license in new_licenses) - old_categories = set(license.category for license in old_licenses) - if delta.new_file.has_licenses() and not delta.old_file.has_licenses(): - delta.update(20, 'license info added') - - for category in new_categories: - # no license ==> 'Copyleft Limited'or higher - if category in unique_categories: - delta.update(20, category.lower() + ' added') - # no license ==> 'Permissive' or 'Public Domain' - else: - delta.update(0, category.lower() + ' added') - return + delta.update(score=20, factor='license info added') + return new_keys = set(license.key for license in new_licenses) old_keys = set(license.key for license in old_licenses) if new_keys != old_keys: - delta.update(10, 'license change') - for category in new_categories - old_categories: - unique_categories_in_old_file = len(old_categories & unique_categories) - # 'Permissive' or 'Public Domain' ==> 'Copyleft Limited' or higher - if unique_categories_in_old_file == 0 and category in unique_categories: - delta.update(20, category.lower() + ' added') - # at least 1 category in the old file was 'Copyleft Limited' or higher ==> 'Copyleft Limited' or higher - elif unique_categories_in_old_file != 0 and category in unique_categories: - delta.update(10, category.lower() + ' added') - # 'Permissive' or 'Public Domain' ==> 'Permissive' or 'Public Domain' if not in old_categories - elif category not in unique_categories: - delta.update(0, category.lower() + ' added') + delta.update(score=10, factor='license change') def update_from_copyright_info(delta): diff --git a/tests/test_deltacode.py b/tests/test_deltacode.py index 59f4d7bd..2214c671 100644 --- a/tests/test_deltacode.py +++ b/tests/test_deltacode.py @@ -263,8 +263,8 @@ def test_DeltaCode_license_modified(self): assert [d.score for d in deltas if d.new_file.path == 'some/path/b/b1.py'] == [40] assert [d.score for d in deltas if d.new_file.path == 'some/path/c/c1.py'] == [20] - assert [d.factors for d in deltas if d.new_file.path == 'some/path/a/a1.py'].pop() == ['modified', 'license change', 'copyleft added'] - assert [d.factors for d in deltas if d.new_file.path == 'some/path/b/b1.py'].pop() == ['modified', 'license change', 'copyleft added'] + assert [d.factors for d in deltas if d.new_file.path == 'some/path/a/a1.py'].pop() == ['modified', 'license change'] + assert [d.factors for d in deltas if d.new_file.path == 'some/path/b/b1.py'].pop() == ['modified', 'license change'] assert [d.factors for d in deltas if d.new_file.path == 'some/path/c/c1.py'].pop() == ['modified'] def test_DeltaCode_errors_empty(self): @@ -612,7 +612,7 @@ def test_score_old_no_lic_info(self): assert [d.new_file.sha1 for d in deltas_object if d.new_file.path == 'path.txt'] == ['b_modified'] assert [d.score for d in deltas_object if d.new_file.path == 'path.txt'] == [40] - assert [d.factors for d in deltas_object if d.new_file.path == 'path.txt'].pop() == ['modified', 'license info added', 'permissive added'] + assert [d.factors for d in deltas_object if d.new_file.path == 'path.txt'].pop() == ['modified', 'license info added'] assert [d.to_dict().get('old').get('licenses') for d in deltas_object if d.new_file.path == 'path.txt'].pop() == [] assert [d.to_dict().get('new').get('licenses') for d in deltas_object if d.new_file.path == 'path.txt'].pop() == [ OrderedDict([ @@ -640,7 +640,7 @@ def test_score_multiple_lic_keys(self): assert [d.new_file.sha1 for d in deltas_object if d.new_file.path == 'path.txt'] == ['b_modified'] assert [d.score for d in deltas_object if d.new_file.path == 'path.txt'] == [50] - assert [d.factors for d in deltas_object if d.new_file.path == 'path.txt'].pop() == ['modified', 'license change', 'copyleft added'] + assert [d.factors for d in deltas_object if d.new_file.path == 'path.txt'].pop() == ['modified', 'license change'] assert [d.to_dict().get('old').get('licenses') for d in deltas_object if d.new_file.path == 'path.txt'].pop() == [ OrderedDict([ ('key', 'mit'), @@ -932,7 +932,7 @@ def test_score_copyright_and_license_info_added(self): assert [d.new_file.sha1 for d in deltas_object if d.new_file.path == 'path.txt'] == ['b_modified'] assert [d.score for d in deltas_object if d.new_file.path == 'path.txt'] == [70] - assert [d.factors for d in deltas_object if d.new_file.path == 'path.txt'].pop() == ['modified', 'license info added', 'copyleft added', 'copyright info added'] + assert [d.factors for d in deltas_object if d.new_file.path == 'path.txt'].pop() == ['modified', 'license info added', 'copyright info added'] assert [d.to_dict().get('old').get('copyrights') for d in deltas_object if d.new_file.path == 'path.txt'].pop() == [] assert [d.to_dict().get('new').get('copyrights') for d in deltas_object if d.new_file.path == 'path.txt'].pop() == [ OrderedDict([ @@ -1053,7 +1053,7 @@ def test_score_license_info_added_copyright_info_removed(self): assert [d.new_file.sha1 for d in deltas_object if d.new_file.path == 'path.txt'] == ['b_modified'] assert [d.score for d in deltas_object if d.new_file.path == 'path.txt'] == [70] - assert [d.factors for d in deltas_object if d.new_file.path == 'path.txt'].pop() == ['modified', 'license info added', 'copyleft added', 'copyright info removed'] + assert [d.factors for d in deltas_object if d.new_file.path == 'path.txt'].pop() == ['modified', 'license info added', 'copyright info removed'] assert [d.to_dict().get('old').get('copyrights') for d in deltas_object if d.new_file.path == 'path.txt'].pop() == [ OrderedDict([ ('statements', ['Copyright (c) 2016 Mark Adler']), @@ -1432,7 +1432,7 @@ def test_Delta_to_dict_Copyright_unusual_characters(self): deltas_object = deltacode_object.deltas - assert [d.factors for d in deltas_object if d.new_file.path == 'a1.py'].pop() == ['modified', 'license change', 'copyleft added', 'copyright change'] + assert [d.factors for d in deltas_object if d.new_file.path == 'a1.py'].pop() == ['modified', 'license change', 'copyright change'] holders_list = [c.holders.pop() for d in deltas_object if d.new_file.path == 'a1.py' for c in d.new_file.copyrights] @@ -1464,7 +1464,7 @@ def test_DeltaCode_sort_order(self): deltas_object = deltacode_object.deltas expected = [ - ['added', 'license info added', 'permissive added', 'copyright info added'], + ['added', 'license info added', 'copyright info added'], ['modified'], ['moved'], ['removed'], @@ -1503,7 +1503,7 @@ def test_DeltaCode_no_lic_to_all_notable_lic(self): assert [d.score for d in deltas_object if d.new_file.path == 'a1.py'] == [170] assert [d.score for d in deltas_object if d.new_file.path == 'a2.py'] == [0] - assert sorted([d.factors for d in deltas_object if d.new_file.path == 'a1.py'].pop()) == sorted(['modified', 'license info added', 'commercial added', 'copyleft added', 'copyleft limited added', 'free restricted added', 'patent license added', 'permissive added', 'proprietary free added', 'copyright info added']) + assert sorted([d.factors for d in deltas_object if d.new_file.path == 'a1.py'].pop()) == sorted(['modified', 'license info added', 'copyright info added']) assert [d.factors for d in deltas_object if d.new_file.path == 'a2.py'].pop() == ['unmodified'] def test_DeltaCode_apache_to_all_notable_lic(self): @@ -1521,7 +1521,7 @@ def test_DeltaCode_apache_to_all_notable_lic(self): assert [d.score for d in deltas_object if d.new_file.path == 'a1.py'] == [155] assert [d.score for d in deltas_object if d.new_file.path == 'a2.py'] == [0] - assert sorted([d.factors for d in deltas_object if d.new_file.path == 'a1.py'].pop()) == sorted(['modified', 'license change', 'commercial added', 'copyleft added', 'copyleft limited added', 'free restricted added', 'patent license added', 'proprietary free added', 'copyright change']) + assert sorted([d.factors for d in deltas_object if d.new_file.path == 'a1.py'].pop()) == sorted(['modified', 'license change', 'copyright change']) assert [d.factors for d in deltas_object if d.new_file.path == 'a2.py'].pop() == ['unmodified'] def test_DeltaCode_copyleft_etc_to_prop_free_and_commercial(self): @@ -1539,7 +1539,7 @@ def test_DeltaCode_copyleft_etc_to_prop_free_and_commercial(self): assert [d.score for d in deltas_object if d.new_file.path == 'a1.py'] == [50] assert [d.score for d in deltas_object if d.new_file.path == 'a2.py'] == [0] - assert [d.factors for d in deltas_object if d.new_file.path == 'a1.py'].pop() == ['modified', 'license change', 'commercial added', 'proprietary free added'] + assert [d.factors for d in deltas_object if d.new_file.path == 'a1.py'].pop() == ['modified', 'license change'] assert [d.factors for d in deltas_object if d.new_file.path == 'a2.py'].pop() == ['unmodified'] def test_DeltaCode_permissive_add_public_domain(self): @@ -1557,5 +1557,5 @@ def test_DeltaCode_permissive_add_public_domain(self): assert [d.score for d in deltas_object if d.new_file.path == 'a1.py'] == [30] assert [d.score for d in deltas_object if d.new_file.path == 'a2.py'] == [0] - assert [d.factors for d in deltas_object if d.new_file.path == 'a1.py'].pop() == ['modified', 'license change', 'public domain added'] + assert [d.factors for d in deltas_object if d.new_file.path == 'a1.py'].pop() == ['modified', 'license change'] assert [d.factors for d in deltas_object if d.new_file.path == 'a2.py'].pop() == ['unmodified'] diff --git a/tests/test_utils.py b/tests/test_utils.py index f064b3a0..46abfbe1 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -163,15 +163,9 @@ def test_update_from_license_info_single_license_change(self): utils.update_modified_from_license_info(test_delta, unique_categories) - expected_factors = [ - 'license change', - 'copyleft added' - ] - assert test_delta.score == 50 assert len(test_delta.factors) == 2 - for factor in expected_factors: - assert factor in test_delta.factors + assert 'license change' in test_delta.factors def test_update_from_license_info_copyleft_license_info_added(self): test_file_new = models.File({ @@ -200,15 +194,9 @@ def test_update_from_license_info_copyleft_license_info_added(self): utils.update_modified_from_license_info(test_delta, unique_categories) - expected_factors = [ - 'license info added', - 'copyleft added' - ] - assert test_delta.score == 60 assert len(test_delta.factors) == 2 - for factor in expected_factors: - assert factor in test_delta.factors + assert 'license info added' in test_delta.factors def test_update_from_license_info_permissive_license_info_added(self): test_file_new = models.File({ @@ -240,7 +228,6 @@ def test_update_from_license_info_permissive_license_info_added(self): assert test_delta.score == 40 assert len(test_delta.factors) == 2 assert 'license info added' in test_delta.factors - assert 'permissive added' in test_delta.factors def test_update_from_license_info_permissive_license_info_removed(self): test_file_new = models.File({ @@ -344,15 +331,9 @@ def test_update_from_license_info_one_license_added(self): utils.update_modified_from_license_info(test_delta, unique_categories) - expected_factors = [ - 'license change', - 'copyleft added' - ] - assert test_delta.score == 50 assert len(test_delta.factors) == 2 - for factor in expected_factors: - assert factor in test_delta.factors + assert 'license change' in test_delta.factors def test_update_from_license_info_one_license_removed(self): test_file_new = models.File({ @@ -564,19 +545,7 @@ def test_update_from_license_info_one_permissive_to_six_copyleft_or_higher(self) assert test_delta.score == 150 assert len(test_delta.factors) == 7 - - expected_factors = [ - 'license change', - 'commercial added', - 'copyleft added', - 'copyleft limited added', - 'free restricted added', - 'patent license added', - 'proprietary free added' - ] - - for factor in expected_factors: - assert factor in test_delta.factors + assert 'license change' in test_delta.factors def test_update_from_license_info_copyleft_to_different_copyleft(self): test_file_new = models.File({ @@ -654,8 +623,6 @@ def test_update_from_license_info_copyleft_to_copyleft_limited(self): assert test_delta.score == 40 assert len(test_delta.factors) == 2 assert 'license change' in test_delta.factors - assert 'copyleft limited added' in test_delta.factors - def test_update_from_license_info_file_added_permissive_license(self): test_file_new = models.File({ @@ -679,9 +646,7 @@ def test_update_from_license_info_file_added_permissive_license(self): assert test_delta.score == 120 assert len(test_delta.factors) == 2 - assert 'license info added' in test_delta.factors - assert 'permissive added' in test_delta.factors def test_update_from_license_info_file_added_commercial_and_copyleft_licenses(self): test_file_new = models.File({ @@ -716,15 +681,6 @@ def test_update_from_license_info_file_added_commercial_and_copyleft_licenses(se assert 'license info added' in test_delta.factors - expected_factors = [ - 'license info added', - 'commercial added', - 'copyleft added' - ] - - for factor in expected_factors: - assert factor in test_delta.factors - def test_update_from_copyright_info_empty(self): test_delta = deltacode.Delta() @@ -1154,7 +1110,6 @@ def test_update_from_lic_copy_info_copyright_and_license_info_added(self): expected_factors = [ 'license info added', - 'copyleft added', 'copyright info added' ] @@ -1302,7 +1257,6 @@ def test_update_from_lic_copy_info_license_info_added_copyright_info_removed(sel expected_factors = [ 'license info added', - 'copyleft added', 'copyright info removed' ] @@ -1439,15 +1393,9 @@ def test_update_from_lic_copy_info_license_change_no_copyright_change(self): utils.update_modified_from_license_info(test_delta, unique_categories) utils.update_modified_from_copyright_info(test_delta) - expected_factors = [ - 'license change', - 'copyleft added' - ] - assert test_delta.score == 50 assert len(test_delta.factors) == 2 - for factor in expected_factors: - assert factor in test_delta.factors + assert 'license change' in test_delta.factors def test_update_from_lic_copy_info_file_added_copyright_and_permissive_license(self): test_file_new = models.File({ @@ -1482,7 +1430,6 @@ def test_update_from_lic_copy_info_file_added_copyright_and_permissive_license(s expected_factors = [ 'license info added', - 'permissive added', 'copyright info added' ] @@ -1532,8 +1479,6 @@ def test_update_from_lic_copy_info_file_added_copyright_and_commercial_and_copyl expected_factors = [ 'license info added', - 'commercial added', - 'copyleft added', 'copyright info added' ]