Skip to content

Commit f9bccf9

Browse files
committed
tests: Add unit tests for annotations.get_known_future_tags()
1 parent b39d1de commit f9bccf9

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

tests/data/project7/file1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# TIMEBOMB: FEWTURE-BOOM1
2+
# FEWTURE-DO-NOT-REPORT: do not report, it's not within an annotation

tests/data/project7/file2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TIMEBOMB: FEWTURE-BOOM2

tests/test_annotations.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from check_oldies import annotations
55

6+
from . import base
7+
68

79
FAKE_GIT_BLAME_OUTPUT = """c106813f91ff43b8fc6e231c263bdaa344866157 136 136 1
810
some value
@@ -65,3 +67,26 @@ def test_get_login_from_committer_email():
6567
assert login == "<@example.com>" # should not be the empty string
6668
login = annotations.get_login_from_committer_email("John Smith")
6769
assert login == "John Smith"
70+
71+
72+
73+
class TestGetKnownFutureTag:
74+
test_data_path = base.TEST_DIR_PATH / "data/project7"
75+
76+
def test_basics(self):
77+
tags = annotations.get_known_future_tags(
78+
directory=self.test_data_path,
79+
annotation_regex=base.TESTING_ANNOTATIONS[0],
80+
future_tag_regex=base.TESTING_FUTURE_TAG,
81+
whitelist=(),
82+
)
83+
assert tags == {"FEWTURE-BOOM1", "FEWTURE-BOOM2"}
84+
85+
def test_whitelist(self):
86+
tags = annotations.get_known_future_tags(
87+
directory=self.test_data_path,
88+
annotation_regex=base.TESTING_ANNOTATIONS[0],
89+
future_tag_regex=base.TESTING_FUTURE_TAG,
90+
whitelist=["file2.py"],
91+
)
92+
assert tags == {"FEWTURE-BOOM1"}

0 commit comments

Comments
 (0)