Skip to content

Commit

Permalink
Rename tallies test files
Browse files Browse the repository at this point in the history
    * Remove all references to summarization in tallies tests

Reference: #2842
Signed-off-by: Jono Yang <jyang@nexb.com>
  • Loading branch information
JonoYang committed Apr 14, 2022
1 parent 7ce3734 commit 523bbe9
Show file tree
Hide file tree
Showing 63 changed files with 30 additions and 33 deletions.
23 changes: 10 additions & 13 deletions src/summarycode/tallies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
# See https://aboutcode.org for more information about nexB OSS projects.
#

import attr
from collections import Counter

from plugincode.post_scan import PostScanPlugin
from plugincode.post_scan import post_scan_impl
from commoncode.cliutils import PluggableCommandLineOption
from commoncode.cliutils import POST_SCAN_GROUP
from summarycode.utils import sorted_counter
from summarycode.utils import get_resource_tallies
from summarycode.utils import set_resource_tallies
import attr
from commoncode.cliutils import POST_SCAN_GROUP, PluggableCommandLineOption
from plugincode.post_scan import PostScanPlugin, post_scan_impl

from summarycode.utils import (get_resource_tallies, set_resource_tallies,
sorted_counter)

# Tracing flags
TRACE = False
Expand Down Expand Up @@ -113,9 +111,9 @@ def compute_codebase_tallies(codebase, keep_details, **kwargs):
If `keep_details` is True, also keep file and directory details in the
`tallies` file attribute for every file and directory.
"""
from summarycode.copyright_tallies import author_tallies
from summarycode.copyright_tallies import copyright_tallies
from summarycode.copyright_tallies import holder_tallies
from summarycode.copyright_tallies import (author_tallies,
copyright_tallies,
holder_tallies)

attrib_summarizers = [
('license_expressions', license_tallies),
Expand Down Expand Up @@ -254,8 +252,7 @@ def tally_values(values, attribute):
"""
if attribute not in TALLYABLE_ATTRS:
return {}
from summarycode.copyright_tallies import tally_copyrights
from summarycode.copyright_tallies import tally_persons
from summarycode.copyright_tallies import tally_copyrights, tally_persons

value_talliers_by_attr = dict(
license_expressions=tally_licenses,
Expand Down
40 changes: 20 additions & 20 deletions tests/summarycode/test_tallies.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,79 +28,79 @@ class TestTallies(FileDrivenTesting):
test_data_dir = path.join(path.dirname(__file__), 'data')

def test_copyright_summary_base(self):
test_dir = self.get_test_loc('tallies/copyright_summary/scan')
test_dir = self.get_test_loc('tallies/copyright_tallies/scan')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('tallies/copyright_summary/summary.expected.json')
expected_file = self.get_test_loc('tallies/copyright_tallies/tallies.expected.json')
run_scan_click(['-c', '--tallies', '--json-pp', result_file, test_dir])
check_json_scan(expected_file, result_file, remove_file_date=True, regen=REGEN_TEST_FIXTURES)

def test_copyright_summary_with_details(self):
test_dir = self.get_test_loc('tallies/copyright_summary/scan')
test_dir = self.get_test_loc('tallies/copyright_tallies/scan')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('tallies/copyright_summary/summary_details.expected.json')
expected_file = self.get_test_loc('tallies/copyright_tallies/tallies_details.expected.json')
run_scan_click(['-c', '--tallies-with-details', '--json-pp', result_file, test_dir])
check_json_scan(expected_file, result_file, remove_file_date=True, regen=REGEN_TEST_FIXTURES)

def test_copyright_summary_with_details_plain_json(self):
test_dir = self.get_test_loc('tallies/copyright_summary/scan')
test_dir = self.get_test_loc('tallies/copyright_tallies/scan')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('tallies/copyright_summary/summary_details.expected2.json')
expected_file = self.get_test_loc('tallies/copyright_tallies/tallies_details.expected2.json')
run_scan_click(['-c', '--tallies-with-details', '--json', result_file, test_dir])
check_json_scan(expected_file, result_file, remove_file_date=True, regen=REGEN_TEST_FIXTURES)

def test_copyright_summary_does_not_crash(self):
test_dir = self.get_test_loc('tallies/copyright_summary/scan2')
test_dir = self.get_test_loc('tallies/copyright_tallies/scan2')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('tallies/copyright_summary/summary2.expected.json')
expected_file = self.get_test_loc('tallies/copyright_tallies/tallies2.expected.json')
run_scan_click(['-c', '--tallies', '--json-pp', result_file, test_dir])
check_json_scan(expected_file, result_file, remove_file_date=True, regen=REGEN_TEST_FIXTURES)

def test_full_summary_base(self):
test_dir = self.get_test_loc('tallies/full_summary/scan')
test_dir = self.get_test_loc('tallies/full_tallies/scan')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('tallies/full_summary/summary.expected.json')
expected_file = self.get_test_loc('tallies/full_tallies/tallies.expected.json')
run_scan_click(['-clip', '--tallies', '--json-pp', result_file, test_dir])
check_json_scan(expected_file, result_file, remove_instance_uuid=True, remove_file_date=True, regen=REGEN_TEST_FIXTURES)

def test_full_summary_with_details(self):
test_dir = self.get_test_loc('tallies/full_summary/scan')
test_dir = self.get_test_loc('tallies/full_tallies/scan')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('tallies/full_summary/summary_details.expected.json')
expected_file = self.get_test_loc('tallies/full_tallies/tallies_details.expected.json')
run_scan_click(['-clip', '--tallies-with-details', '--json-pp', result_file, test_dir])
check_json_scan(expected_file, result_file, remove_instance_uuid=True, remove_file_date=True, regen=REGEN_TEST_FIXTURES)

def test_copyright_summary_key_files(self):
test_dir = self.get_test_loc('tallies/copyright_summary/scan')
test_dir = self.get_test_loc('tallies/copyright_tallies/scan')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('tallies/copyright_summary/summary_key_files.expected.json')
expected_file = self.get_test_loc('tallies/copyright_tallies/tallies_key_files.expected.json')
run_scan_click(
['-c', '-i', '--classify', '--tallies', '--tallies-key-files',
'--json-pp', result_file, test_dir])

check_json_scan(expected_file, result_file, remove_file_date=True, regen=REGEN_TEST_FIXTURES)

def test_full_summary_key_files(self):
test_dir = self.get_test_loc('tallies/full_summary/scan')
test_dir = self.get_test_loc('tallies/full_tallies/scan')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('tallies/full_summary/summary_key_files.expected.json')
expected_file = self.get_test_loc('tallies/full_tallies/tallies_key_files.expected.json')
run_scan_click(
['-cli', '--classify', '--tallies', '--tallies-key-files',
'--json-pp', result_file, test_dir])
check_json_scan(expected_file, result_file, remove_file_date=True, regen=REGEN_TEST_FIXTURES)

def test_full_summary_key_files_json_lines(self):
test_dir = self.get_test_loc('tallies/full_summary/scan')
test_dir = self.get_test_loc('tallies/full_tallies/scan')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('tallies/full_summary/summary_key_files-details.expected.json-lines')
expected_file = self.get_test_loc('tallies/full_tallies/tallies_key_files-details.expected.json-lines')
run_scan_click(
['-cli', '--classify', '--tallies', '--tallies-key-files',
'--json-lines', result_file, test_dir])
check_jsonlines_scan(expected_file, result_file, remove_file_date=True, regen=REGEN_TEST_FIXTURES)

def test_full_summary_by_facet(self):
test_dir = self.get_test_loc('tallies/full_summary/scan')
test_dir = self.get_test_loc('tallies/full_tallies/scan')
result_file = self.get_temp_file('json')
expected_file = self.get_test_loc('tallies/full_summary/summary_by_facet.expected.json')
expected_file = self.get_test_loc('tallies/full_tallies/tallies_by_facet.expected.json')
run_scan_click([
'-clpieu',
'--facet', 'dev=*.java',
Expand Down

0 comments on commit 523bbe9

Please sign in to comment.