blob: 13eb9b5aa67878faf281837e6943234567bed00e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# Copyright (C) 2017 Lucas Hoffmann
# This file is released under the GNU GPL, version 3 or a later revision.
# For further details see the COPYING file
from __future__ import absolute_import
import tempfile
import unittest
from alot.addressbook import abook
from alot.settings.errors import ConfigError
class TestAbookAddressBook(unittest.TestCase):
def test_abook_file_can_not_be_empty(self):
with self.assertRaises(ConfigError):
abook.AbookAddressBook("/dev/null")
def test_get_contacts_lists_all_emails(self):
data = """
[format]
version = unknown
program = alot-test-suite
[1]
name = me
email = me@example.com
[2]
name = you
email = you@other.domain, you@example.com
"""
with tempfile.NamedTemporaryFile(delete=False) as tmp:
tmp.write(data)
path = tmp.name
addressbook = abook.AbookAddressBook(path)
actual = addressbook.get_contacts()
expected = [('me', 'me@example.com'), ('you', 'you@other.domain'),
('you', 'you@example.com')]
self.assertListEqual(actual, expected)
|