@defer.inlineCallbacks
    def test_handling_ping_error_then_reconnecting(self):
        engine_manager = self.make_engine_manager()
        engine_manager.engine = mocked_engine = self.mocker.engine
        mocked_connection = self.mocker.connection
        fake_error = FakeError()
        mocked_engine.connect.side_effect=lambda: mocked_connection
        mocked_connection.execute.side_effect=util.get_callable_with_different_side_effects([None, fake_error, lambda *a, **kw: reactor.callFromThread(reactor.callLater, 0, engine_manager.stopService)])

        engine_manager.startService()

        self.assertEquals((yield self.events.get()), ('connected', mocked_engine))

        event = yield self.events.get()
        self.assertEquals(event[0], 'lost')
        self.assertTrue(event[1].value is fake_error)

        self.assertEquals((yield self.events.get()), ('connected', mocked_engine))

        self.failIf(0 > self.events.size)
        yield util.wait(0)

        self.assertEquals(self.mocker.mock_calls, [
            # First ping succeeds.
            mock.call.engine.connect(),
            mock.call.connection.execute("SELECT 'ping'"),
            mock.call.connection.close(),

            # This one fails. The engine is disposed as a result.
            mock.call.engine.connect(),
            mock.call.connection.execute("SELECT 'ping'"),
            mock.call.connection.close(),
            mock.call.engine.dispose(),

            # After this ping we stop the service.
            mock.call.engine.connect(),
            mock.call.connection.execute("SELECT 'ping'"),
            mock.call.connection.close(),
            mock.call.engine.dispose()
        ])
dataset/ETHPy150Open foundit/Piped/contrib/database/piped_database/test/test_database.py/EngineProviderTest.test_handling_ping_error_then_reconnecting/swapped operands of `>`