testProtocol.py 17.7 KB
Newer Older
Aurel's avatar
Aurel committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#
# Copyright (C) 2009  Nexedi SA
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

import unittest, os
from mock import Mock
20
from neo import protocol
21
from neo.protocol import NodeTypes, NodeStates, CellStates
22 23
from neo.protocol import ErrorCodes, PacketTypes, Packet
from neo.protocol import INVALID_TID, PACKET_HEADER_SIZE
24
from neo.tests import NeoTestBase
25
from neo.util import getNextTID
Aurel's avatar
Aurel committed
26 27
from time import time, gmtime

28
class ProtocolTests(NeoTestBase):
Aurel's avatar
Aurel committed
29 30 31 32 33 34 35 36

    def setUp(self):
        self.ltid = INVALID_TID

    def tearDown(self):
        pass

    def getNextTID(self):
37 38
        self.ltid = getNextTID(self.ltid)
        return self.ltid
Aurel's avatar
Aurel committed
39 40

    def test_01_Packet_init(self):
41 42
        p = Packet(msg_type=PacketTypes.ASK_PRIMARY_MASTER, body=None)
        self.assertEqual(p.getType(), PacketTypes.ASK_PRIMARY_MASTER)
Aurel's avatar
Aurel committed
43 44 45
        self.assertEqual(len(p), PACKET_HEADER_SIZE)

    def test_02_error(self):
Grégory Wisniewski's avatar
Grégory Wisniewski committed
46
        p = protocol._error(0, "error message")
47
        code, msg = protocol._decodeError(p._body)
48
        self.assertEqual(code, ErrorCodes.NO_ERROR)
Aurel's avatar
Aurel committed
49 50
        self.assertEqual(msg, "error message")

51
    def test_03_protocolError(self):
52
        p = protocol.protocolError("bad protocol")
Aurel's avatar
Aurel committed
53
        error_code, error_msg = p.decode()
54
        self.assertEqual(error_code, ErrorCodes.PROTOCOL_ERROR)
Aurel's avatar
Aurel committed
55 56
        self.assertEqual(error_msg, "protocol error: bad protocol")

57
    def test_05_notReady(self):
58
        p = protocol.notReady("wait")
Aurel's avatar
Aurel committed
59
        error_code, error_msg = p.decode()
60
        self.assertEqual(error_code, ErrorCodes.NOT_READY)
Aurel's avatar
Aurel committed
61 62
        self.assertEqual(error_msg, "not ready: wait")

63
    def test_06_brokenNodeDisallowedError(self):
64
        p = protocol.brokenNodeDisallowedError("broken")
Aurel's avatar
Aurel committed
65
        error_code, error_msg = p.decode()
66
        self.assertEqual(error_code, ErrorCodes.BROKEN_NODE)
Aurel's avatar
Aurel committed
67 68
        self.assertEqual(error_msg, "broken node disallowed error: broken")

69
    def test_07_oidNotFound(self):
70
        p = protocol.oidNotFound("no oid")
Aurel's avatar
Aurel committed
71 72 73
        error_code, error_msg = p.decode()
        self.assertEqual(error_msg, "oid not found: no oid")

74
    def test_08_oidNotFound(self):
75
        p = protocol.tidNotFound("no tid")
Aurel's avatar
Aurel committed
76
        error_code, error_msg = p.decode()
77
        self.assertEqual(error_code, ErrorCodes.TID_NOT_FOUND)
Aurel's avatar
Aurel committed
78 79
        self.assertEqual(error_msg, "tid not found: no tid")

80
    def test_09_ping(self):
81
        p = protocol.ping()
Aurel's avatar
Aurel committed
82 83
        self.assertEqual(None, p.decode())

84
    def test_10_pong(self):
85
        p = protocol.pong()
Aurel's avatar
Aurel committed
86 87
        self.assertEqual(None, p.decode())

88
    def test_11_requestNodeIdentification(self):
Aurel's avatar
Aurel committed
89
        uuid = self.getNewUUID()
90
        p = protocol.requestNodeIdentification(NodeTypes.CLIENT, uuid,
Grégory Wisniewski's avatar
Grégory Wisniewski committed
91 92
                                    ("127.0.0.1", 9080), "unittest")
        node, p_uuid, (ip, port), name  = p.decode()
93
        self.assertEqual(node, NodeTypes.CLIENT)
Aurel's avatar
Aurel committed
94 95 96 97 98
        self.assertEqual(p_uuid, uuid)
        self.assertEqual(ip, "127.0.0.1")
        self.assertEqual(port, 9080)
        self.assertEqual(name, "unittest")

99
    def test_12_acceptNodeIdentification(self):
100
        uuid1, uuid2 = self.getNewUUID(), self.getNewUUID()
101
        p = protocol.acceptNodeIdentification(NodeTypes.CLIENT, uuid1,
Grégory Wisniewski's avatar
Grégory Wisniewski committed
102 103
                                   ("127.0.0.1", 9080), 10, 20, uuid2)
        node, p_uuid, (ip, port), nb_partitions, nb_replicas, your_uuid  = p.decode()
104
        self.assertEqual(node, NodeTypes.CLIENT)
105
        self.assertEqual(p_uuid, uuid1)
Aurel's avatar
Aurel committed
106 107 108 109
        self.assertEqual(ip, "127.0.0.1")
        self.assertEqual(port, 9080)
        self.assertEqual(nb_partitions, 10)
        self.assertEqual(nb_replicas, 20)
110
        self.assertEqual(your_uuid, uuid2)
Aurel's avatar
Aurel committed
111

112
    def test_13_askPrimaryMaster(self):
113
        p = protocol.askPrimaryMaster()
Aurel's avatar
Aurel committed
114 115
        self.assertEqual(None, p.decode())

116
    def test_14_answerPrimaryMaster(self):
Aurel's avatar
Aurel committed
117 118 119 120
        uuid = self.getNewUUID()
        uuid1 = self.getNewUUID()
        uuid2 = self.getNewUUID()
        uuid3 = self.getNewUUID()
Grégory Wisniewski's avatar
Grégory Wisniewski committed
121 122 123
        master_list = [(("127.0.0.1", 1), uuid1),
                       (("127.0.0.2", 2), uuid2),
                       (("127.0.0.3", 3), uuid3)]
124
        p = protocol.answerPrimaryMaster(uuid, master_list)
Aurel's avatar
Aurel committed
125 126 127 128
        primary_uuid, p_master_list  = p.decode()
        self.assertEqual(primary_uuid, uuid)
        self.assertEqual(master_list, p_master_list)

129
    def test_15_announcePrimaryMaster(self):
130
        p = protocol.announcePrimaryMaster()
Aurel's avatar
Aurel committed
131 132
        self.assertEqual(p.decode(), None)

133
    def test_16_reelectPrimaryMaster(self):
134
        p = protocol.reelectPrimaryMaster()
Aurel's avatar
Aurel committed
135 136
        self.assertEqual(p.decode(), None)

137
    def test_17_notifyNodeInformation(self):
Aurel's avatar
Aurel committed
138 139 140 141
        uuid = self.getNewUUID()
        uuid1 = self.getNewUUID()
        uuid2 = self.getNewUUID()
        uuid3 = self.getNewUUID()
142 143 144
        node_list = [(NodeTypes.CLIENT, ("127.0.0.1", 1), uuid1, NodeStates.RUNNING),
                       (NodeTypes.CLIENT, ("127.0.0.2", 2), uuid2, NodeStates.DOWN),
                       (NodeTypes.CLIENT, ("127.0.0.3", 3), uuid3, NodeStates.BROKEN)]
145
        p = protocol.notifyNodeInformation(node_list)
146
        p_node_list = p.decode()[0]
Aurel's avatar
Aurel committed
147 148
        self.assertEqual(node_list, p_node_list)

149
    def test_18_askLastIDs(self):
150
        p = protocol.askLastIDs()
Aurel's avatar
Aurel committed
151 152
        self.assertEqual(p.decode(), None)

153
    def test_19_answerLastIDs(self):
Aurel's avatar
Aurel committed
154 155 156
        oid = self.getNextTID()
        tid = self.getNextTID()
        ptid = self.getNextTID()
157
        p = protocol.answerLastIDs(oid, tid, ptid)
Aurel's avatar
Aurel committed
158 159 160 161 162
        loid, ltid, lptid = p.decode()
        self.assertEqual(loid, oid)
        self.assertEqual(ltid, tid)
        self.assertEqual(lptid, ptid)

163
    def test_20_askPartitionTable(self):
Aurel's avatar
Aurel committed
164
        offset_list = [1, 523, 6, 124]
165
        p = protocol.askPartitionTable(offset_list)
Aurel's avatar
Aurel committed
166 167 168
        p_offset_list  = p.decode()[0]
        self.assertEqual(offset_list, p_offset_list)

169
    def test_21_answerPartitionTable(self):
Aurel's avatar
Aurel committed
170 171 172 173
        ptid = self.getNextTID()
        uuid1 = self.getNewUUID()
        uuid2 = self.getNewUUID()
        uuid3 = self.getNewUUID()
174 175 176
        cell_list = [(0, ((uuid1, CellStates.UP_TO_DATE), (uuid2, CellStates.OUT_OF_DATE))),
                     (43, ((uuid2, CellStates.OUT_OF_DATE),(uuid3, CellStates.DISCARDED))),
                     (124, ((uuid1, CellStates.DISCARDED), (uuid3, CellStates.UP_TO_DATE)))]
177
        p = protocol.answerPartitionTable(ptid, cell_list)
Aurel's avatar
Aurel committed
178 179 180 181
        pptid, p_cell_list  = p.decode()
        self.assertEqual(pptid, ptid)
        self.assertEqual(p_cell_list, cell_list)

182
    def test_22_sendPartitionTable(self):
Aurel's avatar
Aurel committed
183 184 185 186
        ptid = self.getNextTID()
        uuid1 = self.getNewUUID()
        uuid2 = self.getNewUUID()
        uuid3 = self.getNewUUID()
187 188 189
        cell_list = [(0, ((uuid1, CellStates.UP_TO_DATE), (uuid2, CellStates.OUT_OF_DATE))),
                     (43, ((uuid2, CellStates.OUT_OF_DATE),(uuid3, CellStates.DISCARDED))),
                     (124, ((uuid1, CellStates.DISCARDED), (uuid3, CellStates.UP_TO_DATE)))]
190
        p = protocol.answerPartitionTable(ptid, cell_list)
Aurel's avatar
Aurel committed
191 192 193 194
        pptid, p_cell_list  = p.decode()
        self.assertEqual(pptid, ptid)
        self.assertEqual(p_cell_list, cell_list)

195
    def test_23_notifyPartitionChanges(self):
Aurel's avatar
Aurel committed
196 197 198 199
        ptid = self.getNextTID()
        uuid1 = self.getNewUUID()
        uuid2 = self.getNewUUID()
        uuid3 = self.getNewUUID()
200 201 202
        cell_list = [(0, uuid1, CellStates.UP_TO_DATE),
                     (43, uuid2, CellStates.OUT_OF_DATE),
                     (124, uuid1, CellStates.DISCARDED)]
203
        p = protocol.notifyPartitionChanges(ptid,
Aurel's avatar
Aurel committed
204 205 206 207 208
                                 cell_list)
        pptid, p_cell_list  = p.decode()
        self.assertEqual(pptid, ptid)
        self.assertEqual(p_cell_list, cell_list)

209
    def test_24_startOperation(self):
210
        p = protocol.startOperation()
Aurel's avatar
Aurel committed
211 212
        self.assertEqual(p.decode(), None)

213
    def test_25_stopOperation(self):
214
        p = protocol.stopOperation()
Aurel's avatar
Aurel committed
215 216
        self.assertEqual(p.decode(), None)

217
    def test_26_askUnfinishedTransaction(self):
218
        p = protocol.askUnfinishedTransactions()
Aurel's avatar
Aurel committed
219 220
        self.assertEqual(p.decode(), None)

221
    def test_27_answerUnfinishedTransaction(self):
Aurel's avatar
Aurel committed
222 223 224 225 226
        tid1 = self.getNextTID()
        tid2 = self.getNextTID()
        tid3 = self.getNextTID()
        tid4 = self.getNextTID()
        tid_list = [tid1, tid2, tid3, tid4]
227
        p = protocol.answerUnfinishedTransactions(tid_list)
Aurel's avatar
Aurel committed
228 229 230
        p_tid_list  = p.decode()[0]
        self.assertEqual(p_tid_list, tid_list)

231
    def test_28_askObjectPresent(self):
Aurel's avatar
Aurel committed
232 233
        oid = self.getNextTID()
        tid = self.getNextTID()
234
        p = protocol.askObjectPresent(oid, tid)
Aurel's avatar
Aurel committed
235 236 237 238
        loid, ltid = p.decode()
        self.assertEqual(loid, oid)
        self.assertEqual(ltid, tid)

239
    def test_29_answerObjectPresent(self):
Aurel's avatar
Aurel committed
240 241
        oid = self.getNextTID()
        tid = self.getNextTID()
242
        p = protocol.answerObjectPresent(oid, tid)
Aurel's avatar
Aurel committed
243 244 245 246
        loid, ltid = p.decode()
        self.assertEqual(loid, oid)
        self.assertEqual(ltid, tid)

247
    def test_30_deleteTransaction(self):
Aurel's avatar
Aurel committed
248
        tid = self.getNextTID()
249
        p = protocol.deleteTransaction(tid)
250
        self.assertEqual(p.getType(), PacketTypes.DELETE_TRANSACTION)
Aurel's avatar
Aurel committed
251 252 253
        ptid = p.decode()[0]
        self.assertEqual(ptid, tid)

254
    def test_31_commitTransaction(self):
Aurel's avatar
Aurel committed
255
        tid = self.getNextTID()
256
        p = protocol.commitTransaction(tid)
Aurel's avatar
Aurel committed
257 258 259 260
        ptid = p.decode()[0]
        self.assertEqual(ptid, tid)


261
    def test_32_askBeginTransaction(self):
Grégory Wisniewski's avatar
Grégory Wisniewski committed
262 263 264 265 266 267 268 269
        # try with an invalid TID, None must be returned
        tid = '\0' * 8
        p = protocol.askBeginTransaction(tid)
        self.assertEqual(p.decode(), (None, ))
        # and with another TID
        tid = '\1' * 8
        p = protocol.askBeginTransaction(tid)
        self.assertEqual(p.decode(), (tid, ))
Aurel's avatar
Aurel committed
270

271
    def test_33_answerBeginTransaction(self):
Aurel's avatar
Aurel committed
272
        tid = self.getNextTID()
273
        p = protocol.answerBeginTransaction(tid)
Aurel's avatar
Aurel committed
274 275 276
        ptid = p.decode()[0]
        self.assertEqual(ptid, tid)

277
    def test_34_askNewOIDs(self):
278
        p = protocol.askNewOIDs(10)
Aurel's avatar
Aurel committed
279 280 281
        nb = p.decode()
        self.assertEqual(nb, (10,))

282
    def test_35_answerNewOIDs(self):
Aurel's avatar
Aurel committed
283 284 285 286 287
        oid1 = self.getNextTID()
        oid2 = self.getNextTID()
        oid3 = self.getNextTID()
        oid4 = self.getNextTID()
        oid_list = [oid1, oid2, oid3, oid4]
288
        p = protocol.answerNewOIDs(oid_list)
Aurel's avatar
Aurel committed
289 290 291
        p_oid_list  = p.decode()[0]
        self.assertEqual(p_oid_list, oid_list)

292
    def test_36_finishTransaction(self):
Aurel's avatar
Aurel committed
293 294 295 296 297 298
        oid1 = self.getNextTID()
        oid2 = self.getNextTID()
        oid3 = self.getNextTID()
        oid4 = self.getNextTID()
        tid = self.getNextTID()
        oid_list = [oid1, oid2, oid3, oid4]
299
        p = protocol.finishTransaction(oid_list, tid)
Aurel's avatar
Aurel committed
300 301 302 303
        p_oid_list, ptid  = p.decode()
        self.assertEqual(ptid, tid)
        self.assertEqual(p_oid_list, oid_list)

304
    def test_37_notifyTransactionFinished(self):
Aurel's avatar
Aurel committed
305
        tid = self.getNextTID()
306
        p = protocol.notifyTransactionFinished(tid)
Aurel's avatar
Aurel committed
307 308 309
        ptid = p.decode()[0]
        self.assertEqual(ptid, tid)

310
    def test_38_lockInformation(self):
Aurel's avatar
Aurel committed
311
        tid = self.getNextTID()
312
        p = protocol.lockInformation(tid)
Aurel's avatar
Aurel committed
313 314 315
        ptid = p.decode()[0]
        self.assertEqual(ptid, tid)

316
    def test_39_notifyInformationLocked(self):
Aurel's avatar
Aurel committed
317
        tid = self.getNextTID()
318
        p = protocol.notifyInformationLocked(tid)
Aurel's avatar
Aurel committed
319 320 321
        ptid = p.decode()[0]
        self.assertEqual(ptid, tid)

322
    def test_40_invalidateObjects(self):
Aurel's avatar
Aurel committed
323 324 325 326 327 328
        oid1 = self.getNextTID()
        oid2 = self.getNextTID()
        oid3 = self.getNextTID()
        oid4 = self.getNextTID()
        tid = self.getNextTID()
        oid_list = [oid1, oid2, oid3, oid4]
329
        p = protocol.invalidateObjects(oid_list, tid)
Aurel's avatar
Aurel committed
330 331 332 333
        p_oid_list, ptid  = p.decode()
        self.assertEqual(ptid, tid)
        self.assertEqual(p_oid_list, oid_list)

334
    def test_41_unlockInformation(self):
Aurel's avatar
Aurel committed
335
        tid = self.getNextTID()
336
        p = protocol.unlockInformation(tid)
Aurel's avatar
Aurel committed
337 338 339
        ptid = p.decode()[0]
        self.assertEqual(ptid, tid)

340
    def test_42_abortTransaction(self):
Aurel's avatar
Aurel committed
341
        tid = self.getNextTID()
342
        p = protocol.abortTransaction(tid)
Aurel's avatar
Aurel committed
343 344 345
        ptid = p.decode()[0]
        self.assertEqual(ptid, tid)

346
    def test_43_askStoreTransaction(self):
Aurel's avatar
Aurel committed
347 348 349 350 351 352
        tid = self.getNextTID()
        oid1 = self.getNextTID()
        oid2 = self.getNextTID()
        oid3 = self.getNextTID()
        oid4 = self.getNextTID()
        oid_list = [oid1, oid2, oid3, oid4]
353
        p = protocol.askStoreTransaction(tid, "moi", "transaction", "exti", oid_list)
Aurel's avatar
Aurel committed
354 355 356 357 358 359 360
        ptid, user, desc, ext, p_oid_list = p.decode()
        self.assertEqual(ptid, tid)
        self.assertEqual(p_oid_list, oid_list)
        self.assertEqual(user, "moi")
        self.assertEqual(desc, "transaction")
        self.assertEqual(ext, "exti")

361
    def test_44_answerStoreTransaction(self):
Aurel's avatar
Aurel committed
362
        tid = self.getNextTID()
363
        p = protocol.answerStoreTransaction(tid)
Aurel's avatar
Aurel committed
364 365 366
        ptid = p.decode()[0]
        self.assertEqual(ptid, tid)

367
    def test_45_askStoreObject(self):
Aurel's avatar
Aurel committed
368 369 370
        oid = self.getNextTID()
        serial = self.getNextTID()
        tid = self.getNextTID()
371
        p = protocol.askStoreObject(oid, serial, 1, 55, "to", tid)
Aurel's avatar
Aurel committed
372 373 374 375 376 377 378 379
        poid, pserial, compression, checksum, data, ptid = p.decode()
        self.assertEqual(oid, poid)
        self.assertEqual(serial, pserial)
        self.assertEqual(tid, ptid)
        self.assertEqual(compression, 1)
        self.assertEqual(checksum, 55)
        self.assertEqual(data, "to")

380
    def test_46_answerStoreObject(self):
Aurel's avatar
Aurel committed
381 382
        oid = self.getNextTID()
        serial = self.getNextTID()
383
        p = protocol.answerStoreObject(1, oid, serial)
Aurel's avatar
Aurel committed
384 385 386 387 388
        conflicting, poid, pserial = p.decode()
        self.assertEqual(oid, poid)
        self.assertEqual(serial, pserial)
        self.assertEqual(conflicting, 1)

389
    def test_47_askObject(self):
Aurel's avatar
Aurel committed
390 391 392
        oid = self.getNextTID()
        serial = self.getNextTID()
        tid = self.getNextTID()
393
        p = protocol.askObject(oid, serial, tid)
Aurel's avatar
Aurel committed
394 395 396 397 398
        poid, pserial, ptid = p.decode()
        self.assertEqual(oid, poid)
        self.assertEqual(serial, pserial)
        self.assertEqual(tid, ptid)

399
    def test_48_answerObject(self):
Aurel's avatar
Aurel committed
400 401 402
        oid = self.getNextTID()
        serial_start = self.getNextTID()
        serial_end = self.getNextTID()
403
        p = protocol.answerObject(oid, serial_start, serial_end, 1, 55, "to",)
Aurel's avatar
Aurel committed
404 405 406 407 408 409 410 411
        poid, pserial_start, pserial_end, compression, checksum, data= p.decode()
        self.assertEqual(oid, poid)
        self.assertEqual(serial_start, pserial_start)
        self.assertEqual(serial_end, pserial_end)
        self.assertEqual(compression, 1)
        self.assertEqual(checksum, 55)
        self.assertEqual(data, "to")

412
    def test_49_askTIDs(self):
413
        p = protocol.askTIDs(1, 10, 5)
Aurel's avatar
Aurel committed
414 415 416 417 418
        first, last, partition = p.decode()
        self.assertEqual(first, 1)
        self.assertEqual(last, 10)
        self.assertEqual(partition, 5)

419
    def test_50_answerTIDs(self):
Aurel's avatar
Aurel committed
420 421 422 423 424
        tid1 = self.getNextTID()
        tid2 = self.getNextTID()
        tid3 = self.getNextTID()
        tid4 = self.getNextTID()
        tid_list = [tid1, tid2, tid3, tid4]
425
        p = protocol.answerTIDs(tid_list)
Aurel's avatar
Aurel committed
426 427 428
        p_tid_list  = p.decode()[0]
        self.assertEqual(p_tid_list, tid_list)

429
    def test_51_askTransactionInfomation(self):
Aurel's avatar
Aurel committed
430
        tid = self.getNextTID()
431
        p = protocol.askTransactionInformation(tid)
Aurel's avatar
Aurel committed
432 433 434
        ptid = p.decode()[0]
        self.assertEqual(tid, ptid)

435
    def test_52_answerTransactionInformation(self):
Aurel's avatar
Aurel committed
436 437 438 439 440 441
        tid = self.getNextTID()
        oid1 = self.getNextTID()
        oid2 = self.getNextTID()
        oid3 = self.getNextTID()
        oid4 = self.getNextTID()
        oid_list = [oid1, oid2, oid3, oid4]
442
        p = protocol.answerTransactionInformation(tid, "moi", 
443
                "transaction", "exti", oid_list)
Aurel's avatar
Aurel committed
444 445 446 447 448 449 450
        ptid, user, desc, ext, p_oid_list = p.decode()
        self.assertEqual(ptid, tid)
        self.assertEqual(p_oid_list, oid_list)
        self.assertEqual(user, "moi")
        self.assertEqual(desc, "transaction")
        self.assertEqual(ext, "exti")

451
    def test_53_askObjectHistory(self):
Aurel's avatar
Aurel committed
452
        oid = self.getNextTID()
453
        p = protocol.askObjectHistory(oid, 1, 10,)
Aurel's avatar
Aurel committed
454 455 456 457 458
        poid, first, last = p.decode()
        self.assertEqual(first, 1)
        self.assertEqual(last, 10)
        self.assertEqual(poid, oid)

459
    def test_54_answerObjectHistory(self):
Aurel's avatar
Aurel committed
460 461 462 463 464 465
        oid = self.getNextTID()
        hist1 = (self.getNextTID(), 15)
        hist2 = (self.getNextTID(), 353)
        hist3 = (self.getNextTID(), 326)
        hist4 = (self.getNextTID(), 652)
        hist_list = [hist1, hist2, hist3, hist4]
466
        p = protocol.answerObjectHistory(oid, hist_list)
Aurel's avatar
Aurel committed
467 468 469 470
        poid, p_hist_list  = p.decode()
        self.assertEqual(p_hist_list, hist_list)
        self.assertEqual(oid, poid)

471
    def test_55_askOIDs(self):
472
        p = protocol.askOIDs(1, 10, 5)
Aurel's avatar
Aurel committed
473 474 475 476 477
        first, last, partition = p.decode()
        self.assertEqual(first, 1)
        self.assertEqual(last, 10)
        self.assertEqual(partition, 5)

478
    def test_56_answerOIDs(self):
Aurel's avatar
Aurel committed
479 480 481 482 483
        oid1 = self.getNextTID()
        oid2 = self.getNextTID()
        oid3 = self.getNextTID()
        oid4 = self.getNextTID()
        oid_list = [oid1, oid2, oid3, oid4]
484
        p = protocol.answerOIDs(oid_list)
Aurel's avatar
Aurel committed
485 486 487 488 489 490
        p_oid_list  = p.decode()[0]
        self.assertEqual(p_oid_list, oid_list)

if __name__ == '__main__':
    unittest.main()