enricher.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. """Legacy test file - tests moved to test_template_enricher.py"""
  2. # This file is kept for backwards compatibility
  3. # All tests have been moved to test_template_enricher.py
  4. # with proper mocking and more comprehensive coverage
  5. from pathlib import Path
  6. import pytest
  7. from flowsint_core.core.template_enricher import TemplateEnricher
  8. from flowsint_core.templates.loader.yaml_loader import YamlLoader
  9. from flowsint_core.templates.types import Template
  10. TEST_DIR = Path(__file__).parent
  11. def test_enricher_init():
  12. """Test basic enricher initialization from YAML template."""
  13. template = YamlLoader.get_template_from_file(str(TEST_DIR / "example.yaml"))
  14. assert isinstance(template, Template)
  15. assert template.name == "ip-api-lookup"
  16. assert template.category == "Ip"
  17. enricher = TemplateEnricher(sketch_id="123", scan_id="123", template=template)
  18. assert enricher.name() == "ip-api-lookup"
  19. assert enricher.category() == "Ip"
  20. assert enricher.key() == "address"
  21. def test_enricher_preprocess():
  22. """Test enricher preprocessing converts strings to typed objects."""
  23. template = YamlLoader.get_template_from_file(str(TEST_DIR / "example.yaml"))
  24. enricher = TemplateEnricher(sketch_id="123", scan_id="123", template=template)
  25. pre = enricher.preprocess(["8.8.8.8"])
  26. assert len(pre) == 1
  27. assert hasattr(pre[0], "address")
  28. assert pre[0].address == "8.8.8.8"