forked from py-cov-action/python-coverage-comment-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_activity.py
More file actions
50 lines (42 loc) · 1.58 KB
/
test_activity.py
File metadata and controls
50 lines (42 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from __future__ import annotations
import pytest
from coverage_comment import activity
@pytest.mark.parametrize(
"event_name, is_default_branch, event_type, is_pr_merged, expected_activity",
[
("workflow_run", True, None, False, "post_comment"),
("push", True, None, False, "save_coverage_data_files"),
("push", False, None, False, "process_pr"),
("pull_request", True, "closed", True, "save_coverage_data_files"),
("pull_request", True, None, False, "process_pr"),
("pull_request", False, None, False, "process_pr"),
("schedule", False, None, False, "save_coverage_data_files"),
("merge_group", False, None, False, "save_coverage_data_files"),
],
)
def test_find_activity(
event_name, is_default_branch, event_type, is_pr_merged, expected_activity
):
result = activity.find_activity(
event_name=event_name,
is_default_branch=is_default_branch,
event_type=event_type,
is_pr_merged=is_pr_merged,
)
assert result == expected_activity
def test_find_activity_not_found():
with pytest.raises(activity.ActivityNotFound):
activity.find_activity(
event_name="not_found",
is_default_branch=False,
event_type="not_found",
is_pr_merged=False,
)
def test_find_activity_pr_closed_not_merged():
with pytest.raises(activity.ActivityNotFound):
activity.find_activity(
event_name="pull_request",
is_default_branch=False,
event_type="closed",
is_pr_merged=False,
)