tests: update licenses test
The license checker now accepts files licensed in 2018 and 2019.
@@ -6,8 +6,9 @@ import os
import pytest
+AMAZON_COPYRIGHT_YEARS = (2018, 2019)
AMAZON_COPYRIGHT = (
- "Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved."
+ "Copyright {} Amazon.com, Inc. or its affiliates. All Rights Reserved."
)
AMAZON_LICENSE = (
"SPDX-License-Identifier: Apache-2.0"
@@ -28,7 +29,14 @@ TUNTAP_LICENSE = (
EXCLUDED_DIRECTORIES = ((os.path.join(os.getcwd(), 'build')))
-def validate_license(filename):
+def _has_amazon_copyright(string):
+ for year in AMAZON_COPYRIGHT_YEARS:
+ if AMAZON_COPYRIGHT.format(year) in string:
+ return True
+ return False
+
+
+def _validate_license(filename):
"""Validate licenses in all .rs, .py. and .sh file.
Python and Rust files should have the licenses on the first 2 lines
@@ -45,7 +53,7 @@ def validate_license(filename):
copy = file.readline()
local_license = file.readline()
has_amazon_copyright = (
- AMAZON_COPYRIGHT in copy and
+ _has_amazon_copyright(copy) and
AMAZON_LICENSE in local_license
)
has_chromium_copyright = (
@@ -70,5 +78,5 @@ def test_for_valid_licenses():
for subdir, _, files in os.walk(os.getcwd()):
for file in files:
filepath = os.path.join(subdir, file)
- assert validate_license(filepath) is True, \
+ assert _validate_license(filepath) is True, \
"%s has invalid license" % filepath
