Skip to content

Commit

Permalink
Add a test for updating a header with spdx copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernricks committed Feb 26, 2024
1 parent c31ef4d commit b3ba4b3
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/updateheader/test_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def test_add_header_license_not_found(self):


class UpdateFileTestCase(TestCase):
maxDiff = None

def setUp(self):
self.company = "Greenbone AG"

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit b3ba4b3

Please sign in to comment.