86
85
self.assertEqual(key, archive_messages[0][1])
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.
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())
95
93
convert_uuid_to_time(archive_messages[0][0]))
164
162
self.assertMessages([0, 1], messages)
165
163
prev, messages, next = conn.get_messages(archive, 'date', 2, next)
166
164
self.assertMessages([2, 3], messages)
167
prev, messages, next = conn.get_messages(
168
archive, 'date', 2, prev, backward=True)
169
self.assertMessages([0, 1], messages)
170
prev, messages, next = conn.get_messages(
171
archive, 'date', 2, prev, backward=True)
172
self.assertIs(None, prev)
173
self.assertMessages([], messages)
174
self.assertIs(None, next)
176
def test_date_filter(self):
177
conn, archive = self.makeArchive()
178
self.makeMessages(conn, archive, 10)
179
start = datetime.datetime.utcfromtimestamp(250).replace(
181
finish = datetime.datetime.utcfromtimestamp(500).replace(
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)
165
# XXX: We shouldn't have to reverse the sort order. There should
166
# be a flag to work backwards, but I'm not sure if we can get
167
# that from Cassandra without reversing in Python.
168
prev, messages, next = conn.get_messages(archive, '-date', 2, prev)
169
self.assertMessages([1, 0], messages)