Skip to content

Commit

Permalink
Add test_get_counterparty_name
Browse files Browse the repository at this point in the history
  • Loading branch information
DjangoCRM committed Nov 11, 2024
1 parent 337228e commit 399713f
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/crm/utils/test_get_counterparty_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from django.test import tag

from crm.models import Contact
from crm.models import Company
from crm.models import CrmEmail
from crm.models import Lead
from crm.utils.counterparty_name import get_counterparty_name
from tests.base_test_classes import BaseTestCase

# manage.py test tests.crm.utils.test_get_counterparty_name --keepdb


@tag('TestCase')
class TesttestGetCounterpartyName(BaseTestCase):

def setUp(self):
print(" Run Test Method:", self._testMethodName)

def test_get_counterparty_name(self):
company = Company.objects.create(
full_name='Test Company',
email='[email protected]'
)
Contact.objects.create(
first_name='Tom',
last_name='Lee',
secondary_email='[email protected]',
company=company
)
Lead.objects.create(
first_name='Lu',
last_name='Lee',
secondary_email='[email protected]'
)
eml = CrmEmail.objects.create(
to='[email protected]',
content="Some text",
sent=True
)
name = get_counterparty_name(eml)
self.assertEqual("Tom Lee <[email protected]>", name)

eml.from_field = '[email protected]'
eml.sent = False
eml.incoming =True
eml.save()
name = get_counterparty_name(eml)
self.assertEqual("Lu Lee <[email protected]>", name)

0 comments on commit 399713f

Please sign in to comment.