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

Function test_copied_schema

pylint_plugins/api_models_test.py:108–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106
107
108def test_copied_schema():
109 code = """
110 import copy
111
112 class ActionAPI(object):
113 schema = {"properties": {"action": {}}}
114
115 class ActionCreateAPI(object):
116 schema = copy.deepcopy(ActionAPI.schema)
117 schema["properties"]["default_files"] = {}
118 """
119
120 res = parse(code)
121
122 assert isinstance(res, nodes.Module)
123
124 class1_node: nodes.ClassDef = res.body[1]
125 assert isinstance(class1_node, nodes.ClassDef)
126
127 assert "schema" in class1_node.locals
128
129 # action property added but not property from the other class
130 assert "action" in class1_node.locals
131 assert "default_files" not in class1_node.locals
132
133 class2_node: nodes.ClassDef = res.body[2]
134 assert isinstance(class2_node, nodes.ClassDef)
135
136 # action (copied) and default_files (added) properties added
137 assert "schema" in class2_node.locals
138 assert "action" in class2_node.locals
139 assert "default_files" in class2_node.locals
140
141
142def test_copied_imported_schema():

Callers

nothing calls this directly

Calls 1

parseFunction · 0.50

Tested by

no test coverage detected