Skip to content

Commit

Permalink
test(policy-breaks): test user display mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer committed Jul 5, 2021
1 parent 573faf8 commit 4852859
Showing 1 changed file with 133 additions and 4 deletions.
137 changes: 133 additions & 4 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


@pytest.mark.parametrize(
"matches,lines,is_patch,expected_matches",
["matches", "lines", "is_patch", "expected_matches", "user_display"],
[
pytest.param(
[
Expand Down Expand Up @@ -39,6 +39,7 @@
index_end=55,
)
],
False,
id="files",
),
pytest.param(
Expand All @@ -48,6 +49,8 @@
"GitHub Token",
index_start=40,
index_end=78,
line_start=2,
line_end=2,
)
],
[
Expand All @@ -60,13 +63,13 @@
Line(
category=LineCategory.addition,
pre_index=None,
post_index=1,
post_index=10,
content="GitHub:",
),
Line(
category=LineCategory.addition,
pre_index=None,
post_index=2,
post_index=11,
content="github_token: 368ac3edf9e850d1c0ff9d6c526496f8237ddf91",
),
],
Expand All @@ -81,17 +84,143 @@
index_end=56,
)
],
False,
id="patch",
),
pytest.param(
[
Match(
"368ac3edf9e850d1c0ff9d6c526496f8237ddf91",
"GitHub Token",
index_start=22,
index_end=62,
)
],
[
Line(pre_index=1, content="GutHub:", category=LineCategory.data),
Line(
pre_index=2,
content="github_token: 368ac3edf9e850d1c0ff9d6c526496f8237ddf91",
category=LineCategory.data,
),
Line(pre_index=3, content="", category=LineCategory.data),
],
False,
[
Match(
"368ac3edf9e850d1c0ff9d6c526496f8237ddf91",
"GitHub Token",
line_start=2,
line_end=2,
index_start=14,
index_end=55,
)
],
True,
id="files-user display",
),
pytest.param(
[
Match(
"368ac3edf9e850d1c0ff9d6c526496f8237ddf91",
"GitHub Token",
index_start=40,
index_end=78,
line_start=2,
line_end=2,
)
],
[
Line(
category=LineCategory.empty,
pre_index=None,
post_index=None,
content="@@ -0,0 +1,2 @",
),
Line(
category=LineCategory.addition,
pre_index=None,
post_index=10,
content="GitHub:",
),
Line(
category=LineCategory.addition,
pre_index=None,
post_index=11,
content="github_token: 368ac3edf9e850d1c0ff9d6c526496f8237ddf91",
),
],
False,
[
Match(
"368ac3edf9e850d1c0ff9d6c526496f8237ddf91",
"GitHub Token",
line_start=11,
line_end=11,
index_start=17,
index_end=56,
)
],
True,
id="patch-post_index-user-display",
),
pytest.param(
[
Match(
"368ac3edf9e850d1c0ff9d6c526496f8237ddf91",
"GitHub Token",
index_start=40,
index_end=78,
line_start=2,
line_end=2,
)
],
[
Line(
category=LineCategory.empty,
pre_index=None,
post_index=None,
content="@@ -0,0 +1,2 @",
),
Line(
category=LineCategory.addition,
pre_index=9,
post_index=None,
content="GitHub:",
),
Line(
category=LineCategory.addition,
pre_index=10,
post_index=None,
content="github_token: 368ac3edf9e850d1c0ff9d6c526496f8237ddf91",
),
],
False,
[
Match(
"368ac3edf9e850d1c0ff9d6c526496f8237ddf91",
"GitHub Token",
line_start=10,
line_end=10,
index_start=17,
index_end=56,
)
],
True,
id="patch-pre_index-user-display",
),
],
)
def test_update_policy_break_matches(
matches: List[Match],
lines: List[Line],
is_patch: bool,
expected_matches: List[Match],
user_display: bool,
) -> None:
update_policy_break_matches(matches, lines, is_patch=is_patch)
update_policy_break_matches(
matches, lines, is_patch=is_patch, user_display=user_display
)

for i, match in enumerate(expected_matches):
assert match.index_start == matches[i].index_start
Expand Down

0 comments on commit 4852859

Please sign in to comment.