Skip to content

Commit 9777483

Browse files
Alexandra Iordachealxiord
Alexandra Iordache
authored andcommitted
tests: update licenses test
The license checker now accepts files licensed in 2018 and 2019. Signed-off-by: Alexandra Iordache <[email protected]>
1 parent 3abdadd commit 9777483

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tests/integration_tests/build/test_licenses.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
import pytest
88

9+
AMAZON_COPYRIGHT_YEARS = (2018, 2019)
910
AMAZON_COPYRIGHT = (
10-
"Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved."
11+
"Copyright {} Amazon.com, Inc. or its affiliates. All Rights Reserved."
1112
)
1213
AMAZON_LICENSE = (
1314
"SPDX-License-Identifier: Apache-2.0"
@@ -28,7 +29,14 @@
2829
EXCLUDED_DIRECTORIES = ((os.path.join(os.getcwd(), 'build')))
2930

3031

31-
def validate_license(filename):
32+
def _has_amazon_copyright(string):
33+
for year in AMAZON_COPYRIGHT_YEARS:
34+
if AMAZON_COPYRIGHT.format(year) in string:
35+
return True
36+
return False
37+
38+
39+
def _validate_license(filename):
3240
"""Validate licenses in all .rs, .py. and .sh file.
3341
3442
Python and Rust files should have the licenses on the first 2 lines
@@ -45,7 +53,7 @@ def validate_license(filename):
4553
copy = file.readline()
4654
local_license = file.readline()
4755
has_amazon_copyright = (
48-
AMAZON_COPYRIGHT in copy and
56+
_has_amazon_copyright(copy) and
4957
AMAZON_LICENSE in local_license
5058
)
5159
has_chromium_copyright = (
@@ -70,5 +78,5 @@ def test_for_valid_licenses():
7078
for subdir, _, files in os.walk(os.getcwd()):
7179
for file in files:
7280
filepath = os.path.join(subdir, file)
73-
assert validate_license(filepath) is True, \
81+
assert _validate_license(filepath) is True, \
7482
"%s has invalid license" % filepath

0 commit comments

Comments
 (0)