-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |