Files
orion/app/modules/prospecting/tests/unit/test_interaction_service.py
Samir Boulahtit 6d6eba75bf
Some checks failed
CI / pytest (push) Failing after 48m31s
CI / docs (push) Has been skipped
CI / deploy (push) Has been skipped
CI / ruff (push) Successful in 11s
CI / validate (push) Successful in 23s
CI / dependency-scanning (push) Successful in 28s
feat(prospecting): add complete prospecting module for lead discovery and scoring
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>
2026-02-28 00:59:47 +01:00

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