1"""Tests for google3.tools.build_defs.license.tests.hello_licenses.""" 2 3import codecs 4import os 5 6import unittest 7from tests import license_test_utils 8 9 10class HelloLicensesTest(unittest.TestCase): 11 12 def test_has_expected_licenses(self): 13 licenses_info = license_test_utils.load_licenses_info( 14 os.path.join(os.path.dirname(__file__), "hello_licenses.json")) 15 16 expected = { 17 "/tests:hello": [ 18 "/tests:license", 19 ], 20 "/tests:c_bar": [ 21 "/tests:license", 22 "/tests:license_for_extra_feature", 23 ], 24 } 25 license_test_utils.check_licenses_of_dependencies( 26 self, licenses_info, expected) 27 28 def test_has_expected_copyrights(self): 29 copyrights_file = os.path.join(os.path.dirname(__file__), 30 "hello_cc_copyrights.txt") 31 with codecs.open(copyrights_file, encoding="utf-8") as inp: 32 copyrights = inp.read().split('\n') 33 self.assertIn( 34 "package(A test case package/0.0.4), copyright(Copyright © 2019 Uncle Toasty)", 35 copyrights) 36 self.assertIn( 37 "package(A test case package), copyright()", 38 copyrights) 39 40 41if __name__ == "__main__": 42 unittest.main() 43