diff --git a/tests/updateheader/test_header.py b/tests/updateheader/test_header.py index 44f0753a4..9bc3b41f8 100644 --- a/tests/updateheader/test_header.py +++ b/tests/updateheader/test_header.py @@ -173,6 +173,8 @@ def test_add_header_license_not_found(self): class UpdateFileTestCase(TestCase): + maxDiff = None + def setUp(self): self.company = "Greenbone AG" @@ -374,6 +376,46 @@ def test_cleanup_file(self): import foo import bar +foo.baz(bar.boing) +""" # noqa: E501 + + company = "Greenbone AG" + year = str(datetime.datetime.now().year) + license_id = "GPL-3.0-or-later" + + with temp_file(content=test_content, name="foo.py") as tmp: + + update_file( + tmp, + year, + license_id, + company, + cleanup=True, + ) + + new_content = tmp.read_text(encoding="utf-8") + self.assertEqual(expected_content, new_content) + + def test_cleanup_file_spdx_header(self): + test_content = """ +# SPDX-FileCopyrightText: 2021 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later + +import foo +import bar + +foo.baz(bar.boing) +""" # noqa: E501 + + expected_content = f""" +# SPDX-FileCopyrightText: 2021-{str(datetime.datetime.now().year)} Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later + +import foo +import bar + foo.baz(bar.boing) """ # noqa: E501