Some checks failed
Migrates scanning pipeline from marketing-.lu-domains app into Orion module. Supports digital (domain scan) and offline (manual capture) lead channels with enrichment, scoring, campaign management, and interaction tracking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
78 lines
2.5 KiB
Python
78 lines
2.5 KiB
Python
# app/modules/prospecting/tests/unit/test_interaction_service.py
|
|
"""
|
|
Unit tests for InteractionService.
|
|
"""
|
|
|
|
from datetime import date, timedelta
|
|
|
|
import pytest
|
|
|
|
from app.modules.prospecting.services.interaction_service import InteractionService
|
|
|
|
|
|
@pytest.mark.unit
|
|
@pytest.mark.prospecting
|
|
class TestInteractionService:
|
|
"""Tests for InteractionService."""
|
|
|
|
def setup_method(self):
|
|
self.service = InteractionService()
|
|
|
|
def test_create_interaction(self, db, digital_prospect):
|
|
"""Test creating an interaction."""
|
|
interaction = self.service.create(
|
|
db,
|
|
prospect_id=digital_prospect.id,
|
|
user_id=1,
|
|
data={
|
|
"interaction_type": "call",
|
|
"subject": "Initial call",
|
|
"notes": "Discussed website needs",
|
|
"outcome": "positive",
|
|
},
|
|
)
|
|
|
|
assert interaction.id is not None
|
|
assert interaction.interaction_type.value == "call"
|
|
assert interaction.outcome.value == "positive"
|
|
|
|
def test_create_interaction_with_follow_up(self, db, digital_prospect):
|
|
"""Test creating an interaction with follow-up action."""
|
|
follow_up_date = date.today() + timedelta(days=7)
|
|
interaction = self.service.create(
|
|
db,
|
|
prospect_id=digital_prospect.id,
|
|
user_id=1,
|
|
data={
|
|
"interaction_type": "meeting",
|
|
"subject": "Office visit",
|
|
"next_action": "Send proposal",
|
|
"next_action_date": str(follow_up_date),
|
|
},
|
|
)
|
|
|
|
assert interaction.next_action == "Send proposal"
|
|
|
|
def test_get_for_prospect(self, db, digital_prospect, interaction):
|
|
"""Test getting interactions for a prospect."""
|
|
interactions = self.service.get_for_prospect(db, digital_prospect.id)
|
|
assert len(interactions) >= 1
|
|
assert interactions[0].prospect_id == digital_prospect.id
|
|
|
|
def test_get_upcoming_actions(self, db, digital_prospect):
|
|
"""Test getting upcoming follow-up actions."""
|
|
follow_up_date = date.today() + timedelta(days=3)
|
|
self.service.create(
|
|
db,
|
|
prospect_id=digital_prospect.id,
|
|
user_id=1,
|
|
data={
|
|
"interaction_type": "call",
|
|
"next_action": "Follow up",
|
|
"next_action_date": str(follow_up_date),
|
|
},
|
|
)
|
|
|
|
upcoming = self.service.get_upcoming_actions(db)
|
|
assert len(upcoming) >= 1
|