Skip to content

Commit

Permalink
tests: Add unit tests for annotations.get_known_future_tags()
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaty committed May 15, 2024
1 parent b39d1de commit f9bccf9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/data/project7/file1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TIMEBOMB: FEWTURE-BOOM1
# FEWTURE-DO-NOT-REPORT: do not report, it's not within an annotation
1 change: 1 addition & 0 deletions tests/data/project7/file2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TIMEBOMB: FEWTURE-BOOM2
25 changes: 25 additions & 0 deletions tests/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from check_oldies import annotations

from . import base


FAKE_GIT_BLAME_OUTPUT = """c106813f91ff43b8fc6e231c263bdaa344866157 136 136 1
some value
Expand Down Expand Up @@ -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"}

0 comments on commit f9bccf9

Please sign in to comment.