-
Notifications
You must be signed in to change notification settings - Fork 10
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
6 changed files
with
85 additions
and
16 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
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
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
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
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,2 @@ | ||
"First Name","Middle Name","Last Name","Company","E-mail Address","Business Phone","Business Street","Business Street 2","City","Business State","Business Postal Code" | ||
Toto,Tata,Titi,Company,[email protected],12345678,Street 1,Street 2,City,State,France |
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 |
---|---|---|
|
@@ -351,17 +351,29 @@ def test_emails_list(self): | |
class ImportTestCase(TestDataMixin, ModoTestCase): | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self.path = os.path.join( | ||
os.path.abspath(os.path.dirname(__file__)), | ||
"test_data/outlook_export.csv" | ||
) | ||
self.wrong_path = os.path.join( | ||
os.path.abspath(os.path.dirname(__file__)), | ||
"test_data/unknown_export.csv" | ||
) | ||
|
||
def test_import_wrong_addressbook(self): | ||
with self.assertRaises(management.base.CommandError) as ctx: | ||
management.call_command( | ||
"import_contacts", "[email protected]", self.path) | ||
self.assertEqual(ctx.exception, | ||
"Address Book for email '[email protected]' not found") | ||
self.assertEqual(str(ctx.exception), | ||
"Address Book for email '[email protected]' not found") | ||
|
||
def test_import_unknown_backend(self): | ||
with self.assertRaises(management.base.CommandError) as ctx: | ||
management.call_command( | ||
"import_contacts", "[email protected]", self.wrong_path) | ||
self.assertEqual(str(ctx.exception), | ||
"Failed to detect backend to use") | ||
|
||
def test_import_from_outlook(self): | ||
management.call_command( | ||
|
@@ -376,3 +388,20 @@ def test_import_from_outlook(self): | |
address.contact.address, | ||
"Street 1 Street 2" | ||
) | ||
|
||
def test_import_and_carddav_sync(self): | ||
with httmock.HTTMock(mocks.options_mock, mocks.put_mock): | ||
management.call_command( | ||
"import_contacts", "[email protected]", self.path, | ||
carddav_password="Toto1234" | ||
) | ||
address = models.EmailAddress.objects.get( | ||
address="[email protected]") | ||
phone = models.PhoneNumber.objects.get( | ||
number="12345678") | ||
self.assertEqual(address.contact.first_name, "Toto Tata") | ||
self.assertEqual(address.contact.addressbook.user.email, "[email protected]") | ||
self.assertEqual( | ||
address.contact.address, | ||
"Street 1 Street 2" | ||
) |