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"""Tests for license/examples/src.""" 15 16import os 17 18import unittest 19from tests import license_test_utils 20 21 22class ServerLicensesTest(unittest.TestCase): 23 24 def test_has_expected_licenses(self): 25 package_base = license_test_utils.LICENSE_PACKAGE_BASE 26 licenses_info = license_test_utils.load_licenses_info( 27 os.path.join(os.path.dirname(__file__), "server_licenses.json")) 28 licenses_info = license_test_utils.filter_dependencies( 29 licenses_info, 30 target_filter=lambda targ: targ.startswith(package_base), 31 licenses_filter=lambda lic: lic.startswith(package_base)) 32 33 expected = { 34 "/examples/src:message_src_": [ 35 "/examples/vndor/constant_gen:license_for_emitted_code" 36 ], 37 "/examples/src:message": [ 38 "/examples/vndor/constant_gen:license_for_emitted_code" 39 ], 40 } 41 license_test_utils.check_licenses_of_dependencies( 42 self, licenses_info, expected) 43 44 45if __name__ == "__main__": 46 unittest.main() 47