127
127
conn, archive = self.makeArchive()
128
128
self.makeMessages(conn, archive, 1)
129
129
self.assertMessages(
130
[0], conn.get_messages(archive, 'date', 1, '')[0])
130
[0], conn.get_messages(archive, 'date', 1, '')[1])
132
132
def test_limit(self):
133
133
conn, archive = self.makeArchive()
134
134
self.makeMessages(conn, archive, 4)
135
135
self.assertMessages(
136
[0, 1], conn.get_messages(archive, 'date', 2, '')[0])
136
[0, 1], conn.get_messages(archive, 'date', 2, '')[1])
138
138
def test_order(self):
139
139
conn, archive = self.makeArchive()
140
140
self.makeMessages(conn, archive, 4)
141
141
self.assertMessages(
142
[3, 2], conn.get_messages(archive, '-date', 2, '')[0])
142
[3, 2], conn.get_messages(archive, '-date', 2, '')[1])
144
144
def test_batching_forward(self):
145
145
conn, archive = self.makeArchive()
146
146
self.makeMessages(conn, archive, 5)
147
messages, start = conn.get_messages(archive, 'date', 2, '')
147
prev, messages, next = conn.get_messages(archive, 'date', 2, '')
148
148
self.assertMessages([0, 1], messages)
149
messages, start = conn.get_messages(archive, 'date', 2, start)
149
prev, messages, next = conn.get_messages(archive, 'date', 2, next)
150
150
self.assertMessages([2, 3], messages)
151
messages, start = conn.get_messages(archive, 'date', 2, start)
151
prev, messages, next = conn.get_messages(archive, 'date', 2, next)
152
152
self.assertMessages([4], messages)
153
self.assertIs(None, start)
154
def test_batching_forward_complete(self):
155
conn, archive = self.makeArchive()
156
self.makeMessages(conn, archive, 3)
157
prev, messages, next = conn.get_messages(archive, 'date', 3, '')
158
self.assertMessages([0, 1, 2], messages)
159
self.assertIs(None, next)