~ubuntu-branches/ubuntu/trusty/desktopcouch/trusty

« back to all changes in this revision

Viewing changes to desktopcouch/notes/tests/test_record.py

  • Committer: Bazaar Package Importer
  • Author(s): Chad MILLER
  • Date: 2010-06-22 16:21:19 UTC
  • Revision ID: james.westby@ubuntu.com-20100622162119-3ebuc61x323kahha
Tags: 0.6.6-0ubuntu1
* New upstream release, 0.6.6. (There is no 0.6.5, except in the wild.)
* Resolve circular dependencies.  Group together dependent code in 
  'desktopcouch' package, and make transition packages of subpackages.
  Upstream will try decoupling properly in future.  (Debian: #571929)
* debian/patches/lp_522538.patch
  - No longer needed.  Removed.
* debian/patches/replication-exclusion.patch
  - No longer needed.  Removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2009-2010 Canonical Ltd.
 
2
#
 
3
# This file is part of desktopcouch-notes.
 
4
#
 
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.
 
8
#
 
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.
 
13
#
 
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/>.
 
16
#
 
17
# Authors: Nicola Larosa <nicola.larosa@canonical.com>
 
18
#          Rodrigo Moya <rodrigo.moya@canonical.com>
 
19
 
 
20
"""Tests for the NoteDocument class"""
 
21
 
 
22
import testtools
 
23
from time import (strftime, gmtime)
 
24
from desktopcouch.notes import record as note_mod
 
25
 
 
26
class TestNoteRecord(testtools.TestCase):
 
27
    """Test the Note Record object."""
 
28
 
 
29
    def test_note_record(self):
 
30
        """Test that we get the correct record type."""
 
31
        note = note_mod.Note()
 
32
        self.assertEqual(note_mod.NOTE_RECORD_TYPE, note.record_type)
 
33
        for field_name in note_mod.FIELDS:
 
34
            field_type = note_mod.FIELDS[field_name]
 
35
            if field_type == 'string':
 
36
                setattr(note, field_name, 'value')
 
37
                self.assertEqual('value', note._data[field_name])
 
38
                self.assertEqual(getattr(note, field_name), 'value')
 
39
            elif field_type == 'date':
 
40
                current_time = strftime("%Y-%m-%dT%H:%M:%S", gmtime())
 
41
                setattr(note, field_name, current_time)
 
42
                self.assertEqual(current_time, note._data[field_name])
 
43
                self.assertEqual(getattr(note, field_name), current_time)
 
44
            else:
 
45
                self.fail('Unknown field type: %s' % field_type)
 
46
 
 
47
        # Check all keys
 
48
        all_keys = set(note_mod.FIELDS)
 
49
        all_keys.add('record_type')
 
50
        self.assertEqual(set(note.keys()), all_keys)