import os
import tempfile
import pytest

def test_heuristic_detector_import():
    from ayn_antivirus.detectors.heuristic_detector import HeuristicDetector
    detector = HeuristicDetector()
    assert detector is not None

def test_heuristic_suspicious_strings(tmp_path):
    from ayn_antivirus.detectors.heuristic_detector import HeuristicDetector
    malicious = tmp_path / "evil.php"
    malicious.write_text("<?php eval(base64_decode('ZXZpbCBjb2Rl')); ?>")
    detector = HeuristicDetector()
    results = detector.detect(str(malicious))
    assert len(results) > 0

def test_cryptominer_detector_import():
    from ayn_antivirus.detectors.cryptominer_detector import CryptominerDetector
    detector = CryptominerDetector()
    assert detector is not None

def test_cryptominer_stratum_detection(tmp_path):
    from ayn_antivirus.detectors.cryptominer_detector import CryptominerDetector
    miner_config = tmp_path / "config.json"
    miner_config.write_text('{"url": "stratum+tcp://pool.minexmr.com:4444", "user": "wallet123"}')
    detector = CryptominerDetector()
    results = detector.detect(str(miner_config))
    assert len(results) > 0

def test_spyware_detector_import():
    from ayn_antivirus.detectors.spyware_detector import SpywareDetector
    detector = SpywareDetector()
    assert detector is not None

def test_rootkit_detector_import():
    from ayn_antivirus.detectors.rootkit_detector import RootkitDetector
    detector = RootkitDetector()
    assert detector is not None

def test_signature_detector_import():
    from ayn_antivirus.detectors.signature_detector import SignatureDetector
    assert SignatureDetector is not None

def test_yara_detector_graceful():
    from ayn_antivirus.detectors.yara_detector import YaraDetector
    detector = YaraDetector()
    assert detector is not None
