MCPcopy Create free account
hub / github.com/StackStorm/st2 / write_test_files

Function write_test_files

pants-plugins/pack_metadata/python_rules/conftest.py:74–240  ·  view source on GitHub ↗
(rule_runner: RuleRunner)

Source from the content-addressed store, hash-verified

72
73
74def write_test_files(rule_runner: RuleRunner):
75 for pack in packs:
76 rule_runner.write_files(
77 {
78 f"packs/{pack}/BUILD": dedent(
79 """
80 __defaults__(all=dict(inject_pack_python_path=True))
81 pack_metadata(name="metadata")
82 """
83 ),
84 f"packs/{pack}/pack.yaml": dedent(
85 f"""
86 ---
87 name: {pack}
88 version: 1.0.0
89 author: StackStorm
90 email: info@stackstorm.com
91 """
92 ),
93 f"packs/{pack}/config.schema.yaml": "",
94 f"packs/{pack}/config.yaml.example": "",
95 f"packs/{pack}/icon.png": "",
96 f"packs/{pack}/README.md": f"# Pack {pack} README",
97 }
98 )
99
100 def action_metadata_file(action: str, entry_point: str = "") -> str:
101 entry_point = entry_point or f"{action}.py"
102 return dedent(
103 f"""
104 ---
105 name: {action}
106 runner_type: python-script
107 entry_point: {entry_point}
108 """
109 )
110
111 def test_file(module: str, _object: str) -> str:
112 return dedent(
113 f"""
114 from {module} import {_object}
115 def test_{module.replace(".", "_")}() -> None:
116 pass
117 """
118 )
119
120 rule_runner.write_files(
121 {
122 "packs/foo/actions/BUILD": "python_sources()",
123 "packs/foo/actions/get_bar.yaml": action_metadata_file("get_bar"),
124 "packs/foo/actions/get_bar.py": dedent(
125 """
126 RESPONSE_CONSTANT = "foobar_key"
127 class BarAction:
128 def run(self):
129 return {RESPONSE_CONSTANT: "bar"}
130 """
131 ),

Callers 1

rule_runnerFunction · 0.85

Calls 2

action_metadata_fileFunction · 0.85
test_fileFunction · 0.85

Tested by

no test coverage detected