Skip to main content

CODITECT Hook Validation Test Suite

Comprehensive tests to verify all 41 hooks have correct configuration, valid structure, and proper documentation.

Run: python3 scripts/tests/test_hooks.py python3 scripts/tests/test_hooks.py -v # Verbose python3 scripts/tests/test_hooks.py --hook pre-commit # Single hook

Author: CODITECT Team Version: 1.0.0 Created: 2025-12-22

File: test_hooks.py

Classes

Colors

No description

TestResult

No description

HookValidation

No description

HookTestSuite

Comprehensive test suite for CODITECT hooks

Functions

get_framework_root()

Get framework root directory

main()

No description

get_all_hooks()

Get all hook files with their types

parse_frontmatter(content)

Parse YAML frontmatter from markdown content

test_file_exists(hook_path, hook_name)

Test that hook file exists

test_has_documentation(content, hook_name, hook_type)

Test that hook has documentation

test_valid_event_type(hook_path, hook_name, hook_type)

Test that hook name indicates a valid event type

test_shell_syntax(hook_path, hook_name)

Test shell hook syntax

test_python_syntax(hook_path, hook_name)

Test Python hook syntax

test_has_shebang(hook_path, hook_name, hook_type)

Test that executable hooks have shebang

test_no_dangerous_commands(hook_path, hook_name)

Test that hook doesn't contain dangerous commands

test_minimum_content(hook_path, hook_name)

Test that hook has minimum content

validate_hook(hook_path, hook_type)

Run all validation tests on a hook

run_all(specific_hook)

Run validation on all hooks

Usage

python test_hooks.py