test: lock delivery chain source shape
This commit is contained in:
@@ -150,6 +150,7 @@ TRAINING_M41_RELEASE_INDEX_GUARD_TEST_INVENTORY = (
|
||||
"test_training_m87_release_index_final_closure_delivery_index_guard_self_lock",
|
||||
"test_training_m88_release_index_final_closure_delivery_guard_source_self_lock",
|
||||
"test_training_m89_release_index_final_closure_delivery_guard_source_chain_self_lock",
|
||||
"test_training_m90_release_index_final_closure_delivery_guard_source_chain_source_shape_self_lock",
|
||||
"test_training_m53_release_index_doc_category_coverage_is_exact",
|
||||
"test_training_case_product_doc_reflects_current_m40_maturity",
|
||||
)
|
||||
@@ -721,6 +722,9 @@ class DocumentationConsistencyTests(unittest.TestCase):
|
||||
"release_index_final_closure_delivery_guard_source_chain_self_lock": (
|
||||
"test_training_m89_release_index_final_closure_delivery_guard_source_chain_self_lock"
|
||||
),
|
||||
"release_index_final_closure_delivery_guard_source_chain_source_shape_self_lock": (
|
||||
"test_training_m90_release_index_final_closure_delivery_guard_source_chain_source_shape_self_lock"
|
||||
),
|
||||
"per_doc_helper_exact_category_coverage": (
|
||||
"test_training_m53_release_index_doc_category_coverage_is_exact"
|
||||
),
|
||||
@@ -905,6 +909,7 @@ class DocumentationConsistencyTests(unittest.TestCase):
|
||||
"test_training_m87_release_index_final_closure_delivery_index_guard_self_lock",
|
||||
"test_training_m88_release_index_final_closure_delivery_guard_source_self_lock",
|
||||
"test_training_m89_release_index_final_closure_delivery_guard_source_chain_self_lock",
|
||||
"test_training_m90_release_index_final_closure_delivery_guard_source_chain_source_shape_self_lock",
|
||||
"test_training_m53_release_index_doc_category_coverage_is_exact",
|
||||
"test_training_case_product_doc_reflects_current_m40_maturity",
|
||||
)
|
||||
@@ -3374,6 +3379,122 @@ class DocumentationConsistencyTests(unittest.TestCase):
|
||||
1,
|
||||
)
|
||||
|
||||
def test_training_m90_release_index_final_closure_delivery_guard_source_chain_source_shape_self_lock(
|
||||
self,
|
||||
) -> None:
|
||||
guard_name = (
|
||||
"test_training_m90_release_index_final_closure_delivery_guard_source_chain_source_shape_self_lock"
|
||||
)
|
||||
guarded_method_name = (
|
||||
"test_training_m89_release_index_final_closure_delivery_guard_source_chain_self_lock"
|
||||
)
|
||||
expected_guard_chain_names = (
|
||||
"test_training_m86_release_index_final_closure_delivery_index_self_lock",
|
||||
"test_training_m87_release_index_final_closure_delivery_index_guard_self_lock",
|
||||
"test_training_m88_release_index_final_closure_delivery_guard_source_self_lock",
|
||||
guarded_method_name,
|
||||
)
|
||||
module_source = Path(__file__).read_text(encoding="utf-8")
|
||||
module_tree = ast.parse(module_source)
|
||||
functions_by_name = {
|
||||
node.name: node
|
||||
for node in ast.walk(module_tree)
|
||||
if isinstance(node, ast.FunctionDef)
|
||||
}
|
||||
|
||||
def local_assignment_node(method_name: str, local_name: str) -> ast.AST:
|
||||
self.assertIn(method_name, functions_by_name)
|
||||
assignments = tuple(
|
||||
node.value
|
||||
for node in ast.walk(functions_by_name[method_name])
|
||||
if (
|
||||
isinstance(node, ast.Assign)
|
||||
and len(node.targets) == 1
|
||||
and isinstance(node.targets[0], ast.Name)
|
||||
and node.targets[0].id == local_name
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(len(assignments), 1)
|
||||
return assignments[0]
|
||||
|
||||
role_mapping = ast.literal_eval(
|
||||
local_assignment_node(
|
||||
"test_training_m41_release_index_guard_inventory_is_current",
|
||||
"required_guard_tests_by_role",
|
||||
)
|
||||
)
|
||||
role_methods = tuple(role_mapping.values())
|
||||
expected_inventory = ast.literal_eval(
|
||||
local_assignment_node(
|
||||
"test_training_m52_release_index_guard_inventory_order_and_uniqueness_self_lock",
|
||||
"expected_inventory",
|
||||
)
|
||||
)
|
||||
guarded_chain_names = tuple(
|
||||
ast.literal_eval(local_assignment_node(guarded_method_name, local_name))
|
||||
for local_name in (
|
||||
"final_closure_guard_name",
|
||||
"delivery_guard_name",
|
||||
"source_guard_name",
|
||||
"guard_name",
|
||||
)
|
||||
)
|
||||
delivery_chain_node = local_assignment_node(
|
||||
guarded_method_name,
|
||||
"delivery_chain",
|
||||
)
|
||||
chain_methods_node = local_assignment_node(
|
||||
guarded_method_name,
|
||||
"chain_methods",
|
||||
)
|
||||
|
||||
self.assertEqual(guarded_chain_names, expected_guard_chain_names)
|
||||
self.assertIsInstance(delivery_chain_node, ast.Tuple)
|
||||
self.assertEqual(len(delivery_chain_node.elts), 5)
|
||||
self.assertIsInstance(delivery_chain_node.elts[0], ast.Starred)
|
||||
self.assertIsInstance(delivery_chain_node.elts[0].value, ast.Name)
|
||||
self.assertEqual(delivery_chain_node.elts[0].value.id, "closure_methods")
|
||||
self.assertEqual(
|
||||
tuple(
|
||||
node.id
|
||||
for node in delivery_chain_node.elts[1:]
|
||||
if isinstance(node, ast.Name)
|
||||
),
|
||||
(
|
||||
"final_closure_guard_name",
|
||||
"delivery_guard_name",
|
||||
"source_guard_name",
|
||||
"guard_name",
|
||||
),
|
||||
)
|
||||
self.assertIsInstance(chain_methods_node, ast.Subscript)
|
||||
self.assertIsInstance(chain_methods_node.value, ast.Name)
|
||||
self.assertEqual(chain_methods_node.value.id, "delivery_chain")
|
||||
self.assertIsInstance(chain_methods_node.slice, ast.Slice)
|
||||
self.assertIsInstance(chain_methods_node.slice.lower, ast.UnaryOp)
|
||||
self.assertIsInstance(chain_methods_node.slice.lower.op, ast.USub)
|
||||
self.assertIsInstance(chain_methods_node.slice.lower.operand, ast.Constant)
|
||||
self.assertEqual(chain_methods_node.slice.lower.operand.value, 4)
|
||||
self.assertIsNone(chain_methods_node.slice.upper)
|
||||
self.assertIsNone(chain_methods_node.slice.step)
|
||||
|
||||
self.assertEqual(
|
||||
TRAINING_M41_RELEASE_INDEX_GUARD_TEST_INVENTORY.index(guard_name),
|
||||
TRAINING_M41_RELEASE_INDEX_GUARD_TEST_INVENTORY.index(
|
||||
guarded_method_name
|
||||
)
|
||||
+ 1,
|
||||
)
|
||||
self.assertEqual(
|
||||
role_mapping.get(
|
||||
"release_index_final_closure_delivery_guard_source_chain_source_shape_self_lock"
|
||||
),
|
||||
guard_name,
|
||||
)
|
||||
self.assertEqual(role_methods.count(guard_name), 1)
|
||||
self.assertEqual(expected_inventory.count(guard_name), 1)
|
||||
|
||||
def test_training_m47_release_index_per_doc_helper_inventory_self_lock_is_current(self) -> None:
|
||||
helper_name = "_release_index_missing_required_snippets_by_doc"
|
||||
docs_guard_name = "test_training_readmes_expose_m1_m40_release_index_without_raw_test_modules"
|
||||
|
||||
Reference in New Issue
Block a user