-
Notifications
You must be signed in to change notification settings - Fork 54.3k
Expand file tree
/
Copy pathtest_issue_templates.py
More file actions
57 lines (43 loc) · 1.66 KB
/
Copy pathtest_issue_templates.py
File metadata and controls
57 lines (43 loc) · 1.66 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
51
52
53
54
55
56
57
from pathlib import Path
import yaml
ROOT = Path(__file__).resolve().parents[1]
ISSUE_TEMPLATE_DIR = ROOT / ".github" / "ISSUE_TEMPLATE"
BUG_REPORT_FORM = ISSUE_TEMPLATE_DIR / "bug_report.yml"
BUG_REPORT_MARKDOWN = ISSUE_TEMPLATE_DIR / "bug_report.md"
ISSUE_TEMPLATE_CONFIG = ISSUE_TEMPLATE_DIR / "config.yml"
def _body_item(form, item_id):
for item in form["body"]:
if item.get("id") == item_id:
return item
raise AssertionError(f"Missing issue form item: {item_id}")
def test_bug_report_uses_single_required_issue_form():
assert BUG_REPORT_FORM.exists()
assert not BUG_REPORT_MARKDOWN.exists()
assert ISSUE_TEMPLATE_CONFIG.exists()
form = yaml.safe_load(BUG_REPORT_FORM.read_text(encoding="utf-8"))
config = yaml.safe_load(ISSUE_TEMPLATE_CONFIG.read_text(encoding="utf-8"))
assert config["blank_issues_enabled"] is False
assert form["title"] == "[Bug] "
assert "bug" in form["labels"]
assert isinstance(form["body"], list)
def test_bug_report_requires_reproducible_bug_context():
form = yaml.safe_load(BUG_REPORT_FORM.read_text(encoding="utf-8"))
required_text_fields = {
"local_commit",
"actions_commit",
"problem",
"steps",
"expected",
"actual",
"logs",
"os",
"python_version",
"run_mode",
"config",
}
for item_id in required_text_fields:
item = _body_item(form, item_id)
assert item.get("validations", {}).get("required") is True
latest_code = _body_item(form, "latest_code")
assert latest_code["type"] == "checkboxes"
assert latest_code["attributes"]["options"][0]["required"] is True