1# Copyright 2022 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15import os 16 17import unittest 18from tests import license_test_utils 19 20 21class AnAppLicensesTest(unittest.TestCase): 22 23 def test_has_expected_licenses(self): 24 package_base = license_test_utils.LICENSE_PACKAGE_BASE 25 licenses_info = license_test_utils.load_licenses_info( 26 os.path.join(os.path.dirname(__file__), "an_app_licenses.json")) 27 licenses_info = license_test_utils.filter_dependencies( 28 licenses_info, 29 target_filter=lambda targ: targ.startswith(package_base), 30 licenses_filter=lambda lic: lic.startswith(package_base)) 31 32 expected = { 33 "/tests/thrdparty:new_style_lib": [ 34 "/tests/thrdparty:license", 35 ], 36 } 37 license_test_utils.check_licenses_of_dependencies( 38 self, licenses_info, expected) 39 40 41if __name__ == "__main__": 42 unittest.main() 43