From f9bccf9bd45f9e0f698f847e25e9a51935aebb34 Mon Sep 17 00:00:00 2001 From: Damien Baty Date: Wed, 15 May 2024 09:12:59 +0200 Subject: [PATCH] tests: Add unit tests for `annotations.get_known_future_tags()` --- tests/data/project7/file1.py | 2 ++ tests/data/project7/file2.py | 1 + tests/test_annotations.py | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 tests/data/project7/file1.py create mode 100644 tests/data/project7/file2.py diff --git a/tests/data/project7/file1.py b/tests/data/project7/file1.py new file mode 100644 index 0000000..e6169b7 --- /dev/null +++ b/tests/data/project7/file1.py @@ -0,0 +1,2 @@ +# TIMEBOMB: FEWTURE-BOOM1 +# FEWTURE-DO-NOT-REPORT: do not report, it's not within an annotation diff --git a/tests/data/project7/file2.py b/tests/data/project7/file2.py new file mode 100644 index 0000000..83563d0 --- /dev/null +++ b/tests/data/project7/file2.py @@ -0,0 +1 @@ +# TIMEBOMB: FEWTURE-BOOM2 diff --git a/tests/test_annotations.py b/tests/test_annotations.py index adca546..01341b4 100644 --- a/tests/test_annotations.py +++ b/tests/test_annotations.py @@ -3,6 +3,8 @@ from check_oldies import annotations +from . import base + FAKE_GIT_BLAME_OUTPUT = """c106813f91ff43b8fc6e231c263bdaa344866157 136 136 1 some value @@ -65,3 +67,26 @@ def test_get_login_from_committer_email(): assert login == "<@example.com>" # should not be the empty string login = annotations.get_login_from_committer_email("John Smith") assert login == "John Smith" + + + +class TestGetKnownFutureTag: + test_data_path = base.TEST_DIR_PATH / "data/project7" + + def test_basics(self): + tags = annotations.get_known_future_tags( + directory=self.test_data_path, + annotation_regex=base.TESTING_ANNOTATIONS[0], + future_tag_regex=base.TESTING_FUTURE_TAG, + whitelist=(), + ) + assert tags == {"FEWTURE-BOOM1", "FEWTURE-BOOM2"} + + def test_whitelist(self): + tags = annotations.get_known_future_tags( + directory=self.test_data_path, + annotation_regex=base.TESTING_ANNOTATIONS[0], + future_tag_regex=base.TESTING_FUTURE_TAG, + whitelist=["file2.py"], + ) + assert tags == {"FEWTURE-BOOM1"}