from qz.fact_checker import FactChecker


def test_fact_checker_initialization():
    checker = FactChecker()
    assert isinstance(checker, FactChecker)
    assert checker.model_name == "deepseek-coder"


def test_validate_question(mock_ollama):
    checker = FactChecker()
    question = "What is testing?"
    context = "Testing is a process of evaluating software."
    result = checker.validate_question(question, context)
    assert isinstance(result, bool)
    mock_ollama.assert_called_once()


def test_fact_check(mock_ollama):
    checker = FactChecker()
    result = checker.fact_check(
        question="What is testing?",
        answer="A process of evaluating software",
        context="Testing is a process of evaluating software.",
    )
    assert isinstance(result, bool)
    mock_ollama.assert_called_once()


def test_ollama_error_handling():
    checker = FactChecker(model_name="nonexistent-model")
    # Should return False when Ollama fails
    assert not checker.validate_question("test?", "test.")
    assert not checker.fact_check("test?", "test", "test.")


def test_default_model_name():
    checker = FactChecker()
    assert checker.model_name == "deepseek-coder"
