"""Tests pour mql5_linter.py"""
import pytest
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).parent.parent.parent))


class TestMQL5Linter:
    """Tests pour le linter MQL5"""
    
    def test_import(self):
        """Test que le module s'importe correctement"""
        from pipeline.scripts.mql5_linter import MQL5Linter, Severity
        linter = MQL5Linter()
        assert linter is not None
    
    def test_severity_enum(self):
        """Test l'enum Severity"""
        from pipeline.scripts.mql5_linter import Severity
        assert Severity.ERROR.value == "ERROR"
        assert Severity.WARNING.value == "WARNING"
    
    def test_line_too_long(self):
        """Test détection ligne trop longue"""
        from pipeline.scripts.mql5_linter import MQL5Linter
        linter = MQL5Linter()
        
        # Simuler une vérification
        long_line = "x" * 130
        issues = linter._check_line(Path("test.mqh"), 1, long_line)
        
        # Devrait trouver une issue S003
        assert any(i.rule == "S003" for i in issues)
    
    def test_todo_detection(self):
        """Test détection TODO/FIXME"""
        from pipeline.scripts.mql5_linter import MQL5Linter
        linter = MQL5Linter()
        
        line = "// TODO: Fix this later"
        issues = linter._check_line(Path("test.mqh"), 1, line)
        
        assert any(i.rule == "W005" for i in issues)
