1
# Copyright 2009-2010 Canonical Ltd.
3
# This file is part of desktopcouch-contacts.
5
# desktopcouch is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU Lesser General Public License version 3
7
# as published by the Free Software Foundation.
9
# desktopcouch is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU Lesser General Public License for more details.
14
# You should have received a copy of the GNU Lesser General Public License
15
# along with desktopcouch. If not, see <http://www.gnu.org/licenses/>.
17
# Authors: Nicola Larosa <nicola.larosa@canonical.com>
18
# Vincenzo Di Somma <vincenzo.di.somma@canonical.com>
20
"""Tests for the ContactDocument class"""
22
from unittest import TestCase
24
from desktopcouch.recordtypes.contacts import Contact
26
SINGLE_FIELDS = frozenset((
27
'first_name', 'middle_name', 'last_name', 'title', 'suffix', 'birth_date',
28
'nick_name', 'spouse_name', 'wedding_date', 'company', 'department',
29
'job_title', 'manager_name', 'assistant_name', 'office'))
30
LIST_FIELDS = frozenset((
31
'addresses', 'phone_numbers', 'email_addresses', 'urls', 'im_addresses'))
32
ALL_FIELDS = SINGLE_FIELDS | LIST_FIELDS
35
class TestContactRecord(TestCase):
36
"""Test the Contact Record object."""
38
def test_contact_record(self):
39
"""Test that we get the correct record type."""
41
for field_name in SINGLE_FIELDS:
42
self.assert_(hasattr(contact, field_name))
43
# direct access to internal representation
44
for field_name in LIST_FIELDS:
45
self.assert_(hasattr(contact, field_name))
46
# direct access to internal representation
48
contact.first_name = first_name
49
self.assertEqual(first_name, contact.first_name)
50
self.assertEqual(set(['first_name']), set(contact.keys()))