pryscraper/tests/test_enrichment.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

75 lines
2.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 data.enrichment pipeline."""
from pry_enrichment import (
TECH_PATTERNS,
detect_tech_stack,
extract_company_info,
extract_social_profiles,
)
def test_detect_tech_wordpress() -> None:
html = '<html><head><link rel="stylesheet" href="/wp-content/themes/style.css"></head></html>'
result = detect_tech_stack(html)
assert "wordpress" in result["detected"]
def test_detect_tech_shopify() -> None:
html = '<html><body><script src="https://cdn.shopify.com/s/files/1/0000/0000/files/script.js"></script></body></html>'
result = detect_tech_stack(html)
assert "shopify" in result["detected"]
def test_detect_tech_nextjs() -> None:
html = "<html><head><script>window.__NEXT_DATA__ = {}</script></head></html>"
result = detect_tech_stack(html)
assert "nextjs" in result["detected"]
def test_detect_tech_cloudflare() -> None:
html = "<html></html>"
result = detect_tech_stack(html, {"server": "cloudflare"})
assert "cloudflare" in result["detected"]
def test_detect_tech_empty() -> None:
result = detect_tech_stack("", {})
assert result["count"] == 0
def test_extract_social_twitter() -> None:
html = 'Follow us on <a href="https://twitter.com/pry_scraper">Twitter</a>'
result = extract_social_profiles(html)
assert "pry_scraper" in str(result["profiles"])
def test_extract_social_linkedin() -> None:
html = 'Connect on <a href="https://linkedin.com/company/pry-inc">LinkedIn</a>'
result = extract_social_profiles(html)
assert "pry-inc" in str(result["profiles"])
def test_extract_company_email() -> None:
html = "Contact us at info@example.com for inquiries"
result = extract_company_info(html)
assert len(result.get("emails", [])) >= 1
assert "info@example.com" in result["emails"]
def test_extract_company_founded() -> None:
html = "Founded in 2020, we have been growing ever since."
result = extract_company_info(html)
assert result.get("founded_year") == "2020"
def test_tech_patterns_exist() -> None:
assert "wordpress" in TECH_PATTERNS
assert "shopify" in TECH_PATTERNS
assert "nextjs" in TECH_PATTERNS
assert "cloudflare" in TECH_PATTERNS
assert "stripe" in TECH_PATTERNS