~unity-2d-team/unity-2d/Shell-MultiMonitor

« back to all changes in this revision

Viewing changes to grackle/tests/test_model.py

  • Committer: William Grant
  • Date: 2012-01-22 12:52:24 UTC
  • Revision ID: william.grant@canonical.com-20120122125224-z19p0uvnb7ch6tc7
Comment and document.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from tempfile import _RandomNameSequence
23
23
import time
24
24
import unittest
25
 
import uuid
26
25
 
27
26
from dateutil.tz import (
28
27
    tzoffset,
86
85
        self.assertEqual(key, archive_messages[0][1])
87
86
 
88
87
        # The key in archive_message is a TimeUUID for the Date field in
89
 
        # the message. There is no UTC equivalent of time.mktime, so we
90
 
        # must subtract the offset.
 
88
        # the message.
91
89
        utctime = time.mktime(datetime.datetime(
92
 
            2000, 1, 1, 0, 2, 34, tzinfo=tzutc()).timetuple()) - time.timezone
 
90
            2000, 1, 1, 0, 2, 34, tzinfo=tzutc()).timetuple())
93
91
        self.assertEqual(
94
92
            utctime,
95
93
            convert_uuid_to_time(archive_messages[0][0]))
172
170
        self.assertIs(None, prev)
173
171
        self.assertMessages([], messages)
174
172
        self.assertIs(None, next)
175
 
 
176
 
    def test_date_filter(self):
177
 
        conn, archive = self.makeArchive()
178
 
        self.makeMessages(conn, archive, 10)
179
 
        start = datetime.datetime.utcfromtimestamp(250).replace(
180
 
            tzinfo=tzutc())
181
 
        finish = datetime.datetime.utcfromtimestamp(500).replace(
182
 
            tzinfo=tzutc())
183
 
        prev, messages, next = conn.get_messages(
184
 
            archive, 'date', 2, '', start_date=start, finish_date=finish)
185
 
        self.assertMessages([3, 4], messages)
186
 
        prev, messages, next = conn.get_messages(
187
 
            archive, 'date', 2, next, start_date=start, finish_date=finish)
188
 
        self.assertMessages([5], messages)