"""
False Positive Detection Test — Using Real XML Fixtures
========================================================
Ensures is_ad() does not flag normal content as sponsored.
Uses existing, verified fixture files.
"""

import os

from GramAddict.core.utils import is_ad

FIX_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "fixtures")


def test_normal_explore_post_is_not_ad():
    """
    Test: Ensures the ad detector correctly ignores a standard explore grid.
    """
    xml_path = os.path.join(FIX_DIR, "explore_feed_dump.xml")
    with open(xml_path, "r") as f:
        real_xml = f.read()

    assert is_ad(real_xml) is False, "False positive! Normal explore detected as ad!"


def test_dm_inbox_is_not_ad():
    """
    Test: DM inbox should never be classified as an ad.
    """
    xml_path = os.path.join(FIX_DIR, "dm_inbox_dump.xml")
    with open(xml_path, "r") as f:
        real_xml = f.read()

    assert is_ad(real_xml) is False, "False positive! DM inbox detected as ad!"


def test_stories_feed_is_not_ad():
    """
    Test: Stories feed should never be classified as an ad.
    """
    xml_path = os.path.join(FIX_DIR, "stories_feed_dump.xml")
    with open(xml_path, "r") as f:
        real_xml = f.read()

    assert is_ad(real_xml) is False, "False positive! Stories feed detected as ad!"
