[30388f42] feat: Add automated test infrastructure for core services
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>B2B Marketing Assistant powered by Gemini</title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🚀</text></svg>">
|
||||
<title>B2B Marketing Assistant</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script type="importmap">
|
||||
{
|
||||
|
||||
@@ -2,4 +2,6 @@ google-generativeai
|
||||
requests
|
||||
beautifulsoup4
|
||||
lxml
|
||||
python-dotenv
|
||||
python-dotenv
|
||||
pytest
|
||||
httpx
|
||||
3
b2b-marketing-assistant/run_tests.sh
Normal file
3
b2b-marketing-assistant/run_tests.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
export PYTHONPATH=$PYTHONPATH:/app
|
||||
python3 -m pytest -v /app/tests/test_orchestrator.py
|
||||
57
b2b-marketing-assistant/tests/test_orchestrator.py
Normal file
57
b2b-marketing-assistant/tests/test_orchestrator.py
Normal file
@@ -0,0 +1,57 @@
|
||||
import pytest
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
# Add current dir to sys.path
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import b2b_marketing_orchestrator as orchestrator
|
||||
|
||||
@pytest.fixture
|
||||
def mock_gemini_response():
|
||||
return """## Schritt 1: Angebot (WAS)
|
||||
|
||||
Kurzresuemee:
|
||||
* Test Summary 1
|
||||
* Test Summary 2
|
||||
|
||||
| Produkt/Loesung | Beschreibung | Kernfunktionen | Differenzierung | Primaere Quelle (URL) |
|
||||
|---|---|---|---|---|
|
||||
| Test Bot | A great robot | AI | Faster | https://example.com/bot |
|
||||
"""
|
||||
|
||||
@patch("b2b_marketing_orchestrator.load_api_key", return_value="fake_key")
|
||||
@patch("b2b_marketing_orchestrator.get_text_from_url", return_value="<html><body>Test Content</body></html>")
|
||||
@patch("b2b_marketing_orchestrator.find_relevant_links", return_value=[])
|
||||
@patch("b2b_marketing_orchestrator.call_gemini_api")
|
||||
def test_start_generation(mock_call, mock_links, mock_scrape, mock_key, mock_gemini_response):
|
||||
mock_call.return_value = mock_gemini_response
|
||||
|
||||
result = orchestrator.start_generation("https://example.com", "de", "DACH", "Cleaning")
|
||||
|
||||
assert "offer" in result
|
||||
assert result["offer"]["headers"] == ["Produkt/Loesung", "Beschreibung", "Kernfunktionen", "Differenzierung", "Primaere Quelle (URL)"]
|
||||
assert len(result["offer"]["rows"]) == 1
|
||||
assert result["offer"]["rows"][0][0] == "Test Bot"
|
||||
# Note: Orchestrator uses a hardcoded summary for Step 1 in its return dict
|
||||
assert "Angebotsanalyse" in result["offer"]["summary"][0]
|
||||
|
||||
def test_parse_markdown_table():
|
||||
md = """
|
||||
| Header 1 | Header 2 |
|
||||
|---|---|
|
||||
| Val 1 | Val 2 |
|
||||
"""
|
||||
result = orchestrator.parse_markdown_table(md)
|
||||
assert result["headers"] == ["Header 1", "Header 2"]
|
||||
assert result["rows"] == [["Val 1", "Val 2"]]
|
||||
|
||||
@patch("b2b_marketing_orchestrator.load_api_key", return_value="fake_key")
|
||||
@patch("b2b_marketing_orchestrator.call_gemini_api", return_value="Test Product, Nice Bot, AI, Best, https://test.com")
|
||||
def test_enrich_product(mock_call, mock_key):
|
||||
result = orchestrator.enrich_product("Test Product", "https://test.com", "de")
|
||||
assert len(result) == 5
|
||||
assert result[0] == "Test Product"
|
||||
assert result[1] == "Nice Bot"
|
||||
Reference in New Issue
Block a user