Comprehensive test coverage for WebHooks module improvements.
Focus: Credential management and Infisical integration
Tests: 50+ tests
Coverage:
Run:
pytest resource.test/pytests/factory.web/test_WebHooks.py -v
Focus: Output validation system and improvements
Tests: 60+ tests across 10 test classes
Coverage:
Test Classes:
TestConstants - WebHookConstants verificationTestOutputValidationRequired - Required params layerTestOutputValidationTypes - Type validation layerTestOutputValidationCustomSQL - Custom SQL validationTestSQLInjectionPrevention - Security testingTestYAMLQueryLoading - YAML integrationTestPerformanceN1Fix - Batch query optimizationTestIntegrationScenarios - Complete flowsTestEdgeCases - Edge case handlingTestTypeHints - Type annotation verificationRun:
pytest resource.test/pytests/factory.web/test_WebHooks_validation.py -v
Focus: Performance benchmarks and N+1 fix verification
Tests: 10+ performance benchmark tests
Coverage:
Test Classes:
TestBatchQueryPerformance - N+1 fix benchmarksTestMemoryUsage - Memory consumption testsTestQueryCount - Query count verificationTestRealWorldScenarios - Production simulationsRun:
# Run all performance tests
pytest resource.test/pytests/factory.web/test_WebHooks_performance.py \
-v -m performance
# Run only slow/comprehensive tests
pytest resource.test/pytests/factory.web/test_WebHooks_performance.py \
-v -m slow
Benchmark Results (Expected):
Bulk Query (new): ~1 second for 10,000 records
Individual (old): ~100 seconds for 10,000 records
Improvement: 100x faster
Query reduction: 10,001 → 1 queries
Focus: SQL injection and security hardening
Tests: 30+ security-focused tests
Coverage:
Test Classes:
TestSQLInjectionPrevention - Injection attack testingTestInputSanitization - Input cleaningTestYAMLQuerySafety - YAML securityTestDatabaseTables - Table protectionTestErrorHandling - Information leakage preventionTestSecurityBestPractices - Code pattern verificationSQL Injection Vectors Tested:
'; DROP TABLE users; --' OR '1'='1admin'--' UNION SELECT * FROM sys_User--Run:
pytest resource.test/pytests/factory.web/test_WebHooks_security.py -v
pytest resource.test/pytests/factory.web/test_WebHooks*.py -v
Quick tests only (skip slow):
pytest resource.test/pytests/factory.web/test_WebHooks*.py \
-v -m "not slow"
Performance benchmarks:
pytest resource.test/pytests/factory.web/ \
-v -m performance
Security tests:
pytest resource.test/pytests/factory.web/test_WebHooks_security.py -v
Integration tests:
pytest resource.test/pytests/factory.web/ \
-v -m integration
pytest resource.test/pytests/factory.web/test_WebHooks*.py \
--cov=factory.web.WebHooks \
--cov-report=html \
--cov-report=term
pytest resource.test/pytests/factory.web/test_WebHooks*.py \
-v -n auto # Uses all CPU cores
Tests use pytest markers for categorization:
@pytest.mark.slow - Long-running tests (>1 second)@pytest.mark.performance - Performance benchmarks@pytest.mark.integration - Integration tests (require DB)@pytest.mark.security - Security-focused testsConfigure in pytest.ini:
[pytest]
markers =
slow: marks tests as slow (deselect with '-m "not slow"')
performance: performance benchmark tests
integration: integration tests requiring external services
security: security-focused tests
pytest --cov to measure| Feature | Tests | Status |
|---|---|---|
| Constants | 7 | ✅ Complete |
| Required validation | 7 | ✅ Complete |
| Type validation | 12 | ✅ Complete |
| Custom SQL validation | 3 | ✅ Complete |
| SQL injection prevention | 6 | ✅ Complete |
| YAML query loading | 2 | ✅ Complete |
| N+1 performance fix | 6 | ✅ Complete |
| Batch processing | 5 | ✅ Complete |
| Security hardening | 8 | ✅ Complete |
| Edge cases | 5 | ✅ Complete |
| Type hints | 2 | ✅ Complete |
| Total | 63+ | ✅ |
test_WebHooks.py ............................ [ 40%]
test_WebHooks_validation.py ................ [ 70%]
test_WebHooks_performance.py ............... [ 85%]
test_WebHooks_security.py .................. [100%]
===================== 150+ passed in X.XXs =====================
Benchmark Results (1000 records):
Individual queries: 10.0000s
Bulk query: 0.1000s
Improvement: 100.00x faster
Query count for 1000 records: 1
✓ 100x+ faster than old N+1 method (500s → 0.50s)
# Run quick tests before commit
pytest resource.test/pytests/factory.web/test_WebHooks*.py \
-v -m "not slow" --tb=short
# .github/workflows/test.yml or Bitbucket Pipelines
- name: Run WebHooks Tests
run: |
pytest resource.test/pytests/factory.web/test_WebHooks*.py \
-v \
--cov=factory.web.WebHooks \
--cov-report=xml \
--junitxml=test-results.xml
- name: Run Performance Tests
run: |
pytest resource.test/pytests/factory.web/ \
-v -m performance \
--benchmark-only
def_webhookdef_webhook_parametersdef_webhook_validationsdef_webhook_output_validationsdef_webhook_reflectionsdef_webhook_batchsys_UserTests use mocking for most database operations, so actual data is not
required. Integration tests (marked @pytest.mark.integration) may
require real database entries.
All tests include mock data for:
pytest resource.test/pytests/factory.web/test_WebHooks*.py \
-vv --tb=long
pytest resource.test/pytests/factory.web/test_WebHooks_validation.py \
-k test_int_type_validation_success \
-vv
pytest resource.test/pytests/factory.web/test_WebHooks*.py \
-vv --pdb # Drop into debugger on failure
pytest resource.test/pytests/factory.web/test_WebHooks*.py \
-v -s # Show stdout/stderr
class TestNewFeature:
"""Test description."""
def test_feature_works(self, webhook_instance):
"""Test specific behavior."""
# Arrange
webhook_instance.setup_data = "test"
# Act
result = webhook_instance.new_feature()
# Assert
assert result is True
assert webhook_instance.state == "expected"
test_validates_empty_string)WEBHOOKS_SQL_REFACTORING.md - SQL migration detailsWEBHOOKS_N+1_FIX.md - Performance fix explanationWEBHOOKS_CONSTANTS_TYPEHINTS.md - Constants and type hintsSQL_TO_YAML_PROGRESS.md - Migration progressWebHooks.md - Module documentationCreated: 2026-02-19
Branch: feat/webhook_validate