~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-23 02:03:42 UTC
  • Revision ID: william.grant@canonical.com-20120123020342-sxal2reak5s8p0l6
Extract _format_message into a normal function.

Show diffs side-by-side

added added

removed removed

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