~ubuntu-branches/ubuntu/precise/desktopcouch/precise

« back to all changes in this revision

Viewing changes to desktopcouch/recordtypes/tests/test_notes.py

  • Committer: Bazaar Package Importer
  • Author(s): Chad MILLER
  • Date: 2011-01-12 15:08:25 UTC
  • mfrom: (1.5.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110112150825-bzvn23kzufr0qdyb
Tags: 1.0.5-0ubuntu1
* New upstream release, skipping a few buggy releases.
* Split code into binary packages:
  - desktopcouch, configuration files and dependencies, but no code.
  - python-desktopcouch: transitional package
  - python-desktopcouch-application: local DB startup and discovery
  - python-desktopcouch-records: library for DB access anywhere
  - python-desktopcouch-recordtypes: support specific data structures
  - desktopcouch-ubuntuone, replication and pairing with cloud service
* Drop patch that some maverick apps incorrectly needed.
  patches/0-items-should-expose-private-data-for-now.patch
* Update package compatibility-version, 6 -> 7.
* Use newer debhelper and use python-support instead of python-central.
* Depend on contemporary python-couchdb, instead of ancient version.

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
#          Vincenzo Di Somma <vincenzo.di.somma@canonical.com>
 
20
 
 
21
"""Tests for the NoteDocument class"""
 
22
 
 
23
from time import strftime, gmtime
 
24
from unittest import TestCase
 
25
 
 
26
from desktopcouch.recordtypes.notes import Note, NOTE_RECORD_TYPE
 
27
 
 
28
FIELDS = {
 
29
    # String fields
 
30
    'note_format': 'string',
 
31
    'title': 'string',
 
32
    'content': 'string',
 
33
    # Date fields
 
34
    'last_change_date': 'date',
 
35
    'create_date': 'date'}
 
36
 
 
37
 
 
38
class TestNoteRecord(TestCase):
 
39
    """Test the Note Record object."""
 
40
 
 
41
    def test_note_record(self):
 
42
        """Test that we get the correct record type."""
 
43
        note = Note()
 
44
        self.assertEqual(NOTE_RECORD_TYPE, note.record_type)
 
45
        for field_name in FIELDS:
 
46
            self.assert_(hasattr(note, field_name))
 
47
        now = gmtime()
 
48
        now_str = strftime("%Y-%m-%dT%H:%M:%S", now)
 
49
        note.last_change_date = now_str
 
50
        # For some reason that I ignore strptime and strftime return
 
51
        # different timezones so we remove the timezone value
 
52
        # before asserting equal
 
53
        self.assertEqual(now[0:-1], note.last_change_date[0:-1])