Beispiel #1
0
class MasterHandlerTests(NeoUnitTestBase):
    def setUp(self):
        super(MasterHandlerTests, self).setUp()
        self.app = Mock()
        self.handler = PrimaryAnswersHandler(self.app)

    def test_answerPack(self):
        self.assertRaises(NEOStorageError, self.handler.answerPack, None,
                          False)
        # Check it doesn't raise
        self.handler.answerPack(None, True)
Beispiel #2
0
class MasterAnswersHandlerTests(MasterHandlerTests):

    def setUp(self):
        super(MasterAnswersHandlerTests, self).setUp()
        self.handler = PrimaryAnswersHandler(self.app)

    def test_answerBeginTransaction(self):
        tid = self.getNextTID()
        conn = self.getFakeConnection()
        self.handler.answerBeginTransaction(conn, tid)
        calls = self.app.mockGetNamedCalls('setHandlerData')
        self.assertEqual(len(calls), 1)
        calls[0].checkArgs(tid)

    def test_answerNewOIDs(self):
        conn = self.getFakeConnection()
        oid1, oid2, oid3 = self.getOID(0), self.getOID(1), self.getOID(2)
        self.handler.answerNewOIDs(conn, [oid1, oid2, oid3])
        self.assertEqual(self.app.new_oid_list, [oid3, oid2, oid1])

    def test_answerTransactionFinished(self):
        conn = self.getFakeConnection()
        ttid2 = self.getNextTID()
        tid2 = self.getNextTID()
        self.handler.answerTransactionFinished(conn, ttid2, tid2)
        calls = self.app.mockGetNamedCalls('setHandlerData')
        self.assertEqual(len(calls), 1)
        calls[0].checkArgs(tid2)

    def test_answerPack(self):
        self.assertRaises(NEOStorageError, self.handler.answerPack, None, False)
        # Check it doesn't raise
        self.handler.answerPack(None, True)
Beispiel #3
0
class MasterAnswersHandlerTests(MasterHandlerTests):
    def setUp(self):
        super(MasterAnswersHandlerTests, self).setUp()
        self.handler = PrimaryAnswersHandler(self.app)

    def test_answerBeginTransaction(self):
        tid = self.getNextTID()
        conn = self.getFakeConnection()
        self.handler.answerBeginTransaction(conn, tid)
        calls = self.app.mockGetNamedCalls('setHandlerData')
        self.assertEqual(len(calls), 1)
        calls[0].checkArgs(tid)

    def test_answerNewOIDs(self):
        conn = self.getFakeConnection()
        oid1, oid2, oid3 = self.getOID(0), self.getOID(1), self.getOID(2)
        self.handler.answerNewOIDs(conn, [oid1, oid2, oid3])
        self.assertEqual(self.app.new_oid_list, [oid3, oid2, oid1])

    def test_answerTransactionFinished(self):
        conn = self.getFakeConnection()
        ttid2 = self.getNextTID()
        tid2 = self.getNextTID()
        self.handler.answerTransactionFinished(conn, ttid2, tid2)
        calls = self.app.mockGetNamedCalls('setHandlerData')
        self.assertEqual(len(calls), 1)
        calls[0].checkArgs(tid2)

    def test_answerPack(self):
        self.assertRaises(NEOStorageError, self.handler.answerPack, None,
                          False)
        # Check it doesn't raise
        self.handler.answerPack(None, True)
Beispiel #4
0
 def setUp(self):
     super(MasterHandlerTests, self).setUp()
     self.app = Mock()
     self.handler = PrimaryAnswersHandler(self.app)
Beispiel #5
0
 def setUp(self):
     super(MasterAnswersHandlerTests, self).setUp()
     self.handler = PrimaryAnswersHandler(self.app)