|
2 | 2 | # -*- coding: utf8 -*- |
3 | 3 |
|
4 | 4 | # ============================================================================ |
5 | | -# Copyright (c) 2014-2019 nexB Inc. http://www.nexb.com/ - All rights reserved. |
| 5 | +# Copyright (c) 2014-2020 nexB Inc. http://www.nexb.com/ - All rights reserved. |
6 | 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | # you may not use this file except in compliance with the License. |
8 | 8 | # You may obtain a copy of the License at |
|
21 | 21 | from collections import OrderedDict |
22 | 22 | import io |
23 | 23 | import json |
| 24 | +import os |
24 | 25 | import posixpath |
25 | 26 | import shutil |
26 | 27 | import unittest |
|
40 | 41 | from attributecode.util import replace_tab_with_spaces |
41 | 42 |
|
42 | 43 | from testing_utils import extract_test_loc |
| 44 | +from testing_utils import get_temp_dir |
43 | 45 | from testing_utils import get_temp_file |
44 | 46 | from testing_utils import get_test_loc |
45 | 47 |
|
@@ -940,6 +942,41 @@ def test_write_output_json(self): |
940 | 942 | expected = get_test_loc('test_model/expected.json') |
941 | 943 | check_json(expected, result) |
942 | 944 |
|
| 945 | + def test_android_module_license(self): |
| 946 | + path = 'test_model/android/single_license.c.ABOUT' |
| 947 | + test_file = get_test_loc(path) |
| 948 | + abouts = model.About(location=test_file, about_file_path=path) |
| 949 | + |
| 950 | + parent_dir = get_temp_dir() |
| 951 | + abouts.android_module_license(parent_dir) |
| 952 | + assert os.path.exists(os.path.join(parent_dir, 'MODULE_LICENSE_PUBLIC_DOMAIN')) |
| 953 | + |
| 954 | + def test_android_module_multi_licenses(self): |
| 955 | + path = 'test_model/android/multi_license.c.ABOUT' |
| 956 | + test_file = get_test_loc(path) |
| 957 | + abouts = model.About(location=test_file, about_file_path=path) |
| 958 | + |
| 959 | + parent_dir = get_temp_dir() |
| 960 | + abouts.android_module_license(parent_dir) |
| 961 | + assert os.path.exists(os.path.join(parent_dir, 'MODULE_LICENSE_BSD_NEW')) |
| 962 | + assert os.path.exists(os.path.join(parent_dir, 'MODULE_LICENSE_BSD_SIMPLIFIED')) |
| 963 | + |
| 964 | + def test_android_notice(self): |
| 965 | + path = 'test_model/android/single_license.c.ABOUT' |
| 966 | + test_file = get_test_loc(path) |
| 967 | + abouts = model.About(location=test_file, about_file_path=path) |
| 968 | + |
| 969 | + parent_dir = get_temp_dir() |
| 970 | + notice_path, notice_context = abouts.android_notice(parent_dir) |
| 971 | + expected_path = os.path.join(parent_dir, 'NOTICE') |
| 972 | + assert os.path.normpath(notice_path) == expected_path |
| 973 | + |
| 974 | + expected_notice = '''Copyright (c) xyz |
| 975 | +
|
| 976 | +This component is released to the public domain by the author. |
| 977 | +
|
| 978 | +''' |
| 979 | + assert notice_context == expected_notice |
943 | 980 |
|
944 | 981 | class CollectorTest(unittest.TestCase): |
945 | 982 |
|
|
0 commit comments