pryscraper/tests/test_pipeline.py
cryptorugmunch 0ecc250349 refactor(pry): rename 19 root modules to pry_<name> to remove naming collision with routers/
The duplicate file names (advanced, agency, auth, compliance, costing, etc.) in
both root and routers/ made imports ambiguous. Renamed root modules to
pry_<name>.py so:

  from quality import X     ->  from pry_quality import X
  from routers.quality import router  (unchanged)

Also:
- Renamed x402.py to pry_x402/ package directory
- Fixed 21+ bare imports across api.py, deps.py, routers/, tests/, llm_providers/

Tests: 593 passed, 1 skipped (test_ready_returns_200 fails pre-existing
because Ollama is unreachable from test env, unrelated to this refactor).

Audit item 8.
2026-07-06 10:25:44 +02:00

58 lines
1.4 KiB
Python

# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Rug Munch Media LLC
#
# Part of Pry — https://git.rugmunch.io/RugMunchMedia/pryscraper
# Licensed under MIT. See LICENSE.
"""Tests for pipeline hook system."""
from pry_pipeline import HOOK_POINTS, Pipeline
def test_pipeline_init() -> None:
p = Pipeline()
assert len(p.list_hooks()) == len(HOOK_POINTS)
def test_pipeline_register() -> None:
p = Pipeline()
def my_hook(**kwargs: object) -> dict[str, object]:
return {"custom": "value"}
p.register("before_scrape", my_hook)
hooks = p.list_hooks()
assert "my_hook" in list(hooks["before_scrape"])
def test_pipeline_clear() -> None:
p = Pipeline()
def my_hook(**kwargs: object) -> dict[str, object]:
return {}
p.register("before_scrape", my_hook)
p.clear("before_scrape")
assert len(p.list_hooks()["before_scrape"]) == 0
def test_pipeline_clear_all() -> None:
p = Pipeline()
def my_hook(**kwargs: object) -> dict[str, object]:
return {}
p.register("before_scrape", my_hook)
p.clear()
for point in HOOK_POINTS:
assert len(p.list_hooks()[point]) == 0
def test_pipeline_invalid_hook_point() -> None:
p = Pipeline()
import pytest
def my_hook(**kwargs: object) -> dict[str, object]:
return {}
with pytest.raises(ValueError, match="Unknown hook point"):
p.register("invalid_point", my_hook)