def test_find_referenced_resource_does_not_find_based_file_name_suffix(): # Setup: Create a new scan to use for a virtual codebase. This directory has # two test file with the same name suffix which is also a referenced # filename test_dir = test_env.get_test_loc( 'plugin_license/license_reference/scan/scan-ref-dupe-name-suffix', copy=True) scan_loc = test_env.get_temp_file('json') args = [ '--license', '--license-text', '--license-text-diagnostics', test_dir, '--json', scan_loc ] run_scan_click(args) # test proper from commoncode.resource import VirtualCodebase codebase = VirtualCodebase(scan_loc) resource = codebase.get_resource_from_path( 'scan-ref-dupe-name-suffix/license-notice.txt') result = find_referenced_resource(referenced_filename='LICENSE', resource=resource, codebase=codebase) assert result.path == 'scan-ref-dupe-name-suffix/LICENSE'
def test_match_reference_license(): # Setup: Create a new scan to use for a virtual codebase test_dir = test_env.get_test_loc( 'plugin_license/license_reference/scan/scan-ref', copy=True) scan_loc = test_env.get_temp_file('json') args = [ '--license', '--license-text', '--license-text-diagnostics', '--unknown-licenses', '--json', scan_loc, test_dir, ] run_scan_click(args) # test proper from commoncode.resource import VirtualCodebase codebase = VirtualCodebase(scan_loc) resource = codebase.get_resource_from_path('scan-ref/license-notice.txt') assert len(resource.licenses) == 2 result = add_referenced_filenames_license_matches(resource=resource, codebase=codebase) assert len(result.licenses) == 3