mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
diff checker for pashub trigger 🟥
This commit is contained in:
parent
21ca0d7649
commit
39f37f1668
1 changed files with 424 additions and 0 deletions
|
|
@ -0,0 +1,424 @@
|
||||||
|
from datetime import datetime
|
||||||
|
from typing import Dict
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from backend.app.db.models.organisation import HubspotDealData
|
||||||
|
from backend.hubspot_trigger_orchestrator.hubspot_deal_differ import HubspotDealDiffer
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__outcome_note_added__returns_false() -> None:
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"outcome_notes": "test note",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = False
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__pashub_link_changed__returns_true() -> None:
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
pashub_link="www.google.co.uk",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"pashub_link": "www.bbc.co.uk",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = True
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__coordination_completed_and_pashub_link_set__returns_true() -> (
|
||||||
|
None
|
||||||
|
):
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
pashub_link="www.google.co.uk",
|
||||||
|
coordination_status="random",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"coordination_status": "v1 ioe/mtp complete",
|
||||||
|
"pashub_link": "www.google.co.uk",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = True
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__coordination_completed_and_pashub_link_set__returns_true_2() -> (
|
||||||
|
None
|
||||||
|
):
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
pashub_link="www.google.co.uk",
|
||||||
|
coordination_status="random",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"coordination_status": "v2 ioe/mtp complete",
|
||||||
|
"pashub_link": "www.google.co.uk",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = True
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__coordination_completed_and_pashub_link_not_set__returns_false() -> (
|
||||||
|
None
|
||||||
|
):
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
coordination_status="random",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"coordination_status": "v2 ioe/mtp complete",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = False
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__coordination_status_not_completed_and_pashub_link_set__returns_false() -> (
|
||||||
|
None
|
||||||
|
):
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
pashub_link="www.google.co.uk",
|
||||||
|
coordination_status="random",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"coordination_status": "not complete",
|
||||||
|
"pashub_link": "www.google.co.uk",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = False
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__design_completed_and_pashub_link_set__returns_true() -> None:
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
pashub_link="www.google.co.uk",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"pashub_link": "www.google.co.uk",
|
||||||
|
"design_status": "uploaded",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = True
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__design_completed_and_pashub_link_not_set__returns_false() -> (
|
||||||
|
None
|
||||||
|
):
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"design_status": "uploaded",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = False
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__design_not_completed_and_pashub_link_set__returns_false() -> (
|
||||||
|
None
|
||||||
|
):
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
pashub_link="www.google.co.uk",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"pashub_link": "www.google.co.uk",
|
||||||
|
"design_status": "not uploaded",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = False
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__lodgement_completed_and_pashub_link_set__returns_true() -> (
|
||||||
|
None
|
||||||
|
):
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
pashub_link="www.google.co.uk",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"pashub_link": "www.google.co.uk",
|
||||||
|
"lodgement_status": "lodgement complete",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = True
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__lodgement_completed_and_pashub_link_set__returns_true_2() -> (
|
||||||
|
None
|
||||||
|
):
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
pashub_link="www.google.co.uk",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"pashub_link": "www.google.co.uk",
|
||||||
|
"lodgement_status": "measures lodged",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = True
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__lodgement_completed_and_pashub_link_not_set__returns_false() -> (
|
||||||
|
None
|
||||||
|
):
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"design_status": "lodgement complete",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = False
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pashub_trigger__lodgement_not_completed_and_pashub_link_set__returns_false() -> (
|
||||||
|
None
|
||||||
|
):
|
||||||
|
# arrange
|
||||||
|
deal_id = uuid.uuid4()
|
||||||
|
|
||||||
|
old_deal = HubspotDealData(
|
||||||
|
id=deal_id,
|
||||||
|
deal_id="1",
|
||||||
|
pashub_link="www.google.co.uk",
|
||||||
|
created_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
updated_at=datetime(2025, 12, 1, 12, 0, 0),
|
||||||
|
)
|
||||||
|
new_deal: Dict[str, str] = {
|
||||||
|
"id": str(deal_id),
|
||||||
|
"deal_id": "1",
|
||||||
|
"pashub_link": "www.google.co.uk",
|
||||||
|
"lodgement_status": "lodgement not complete",
|
||||||
|
"created_at": datetime(2025, 12, 1, 12, 0, 0).isoformat(),
|
||||||
|
"updated_at": datetime(2025, 12, 1, 12, 30, 0).isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_output = False
|
||||||
|
|
||||||
|
# act
|
||||||
|
actual_output: bool = HubspotDealDiffer.check_for_pashub_trigger(
|
||||||
|
new_deal=new_deal, old_deal=old_deal
|
||||||
|
)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert actual_output == expected_output
|
||||||
Loading…
Add table
Reference in a new issue