pryscraper/tests/test_crm_sync.py
cryptorugmunch 8d25702eca chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth)
Squashed from chore/license-relicense. Full message preserved in the
original branch commit bb77eb5. See ADR-0002 for the decision rationale.

Refs: ADR-0002, commit bb77eb5
2026-07-02 19:59:18 +02:00

62 lines
1.8 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 CRM reverse ETL."""
from crm_sync import (
_map_to_hubspot,
_map_to_salesforce,
sync_to_close,
sync_to_hubspot,
sync_to_pipedrive,
sync_to_salesforce,
)
def test_sync_salesforce_no_creds() -> None:
import asyncio
result = asyncio.run(
sync_to_salesforce([{"name": "Test Lead", "email": "test@test.com"}], "Lead", "", "")
)
assert result["success"] is False
assert result["synced"] == 0
def test_sync_hubspot_no_creds() -> None:
import asyncio
result = asyncio.run(sync_to_hubspot([{"email": "test@test.com"}], "contacts", ""))
assert result["success"] is False
def test_sync_pipedrive_no_creds() -> None:
import asyncio
result = asyncio.run(sync_to_pipedrive([{"name": "Test"}], "person", "", ""))
assert result["success"] is False
def test_sync_close_no_creds() -> None:
import asyncio
result = asyncio.run(sync_to_close([{"name": "Test"}], "lead", ""))
assert result["success"] is False
def test_map_to_salesforce_lead() -> None:
data = {"name": "John Doe", "email": "john@test.com", "company": "Acme Inc"}
mapped = _map_to_salesforce(data, "Lead")
assert mapped.get("LastName") == "John Doe"
assert mapped.get("Email") == "john@test.com"
assert mapped.get("Company") == "Acme Inc"
def test_map_to_hubspot_contact() -> None:
data = {"email": "jane@test.com", "first_name": "Jane", "phone": "555-0100"}
mapped = _map_to_hubspot(data, "contacts")
assert mapped.get("email") == "jane@test.com"
assert mapped.get("firstname") == "Jane"
assert mapped.get("phone") == "555-0100"