Example #1
0
    def test_mismatched_release(self):
        mock_dbapi2 = mock.MagicMock()
        pool = ConnectionPool(mock_dbapi2, {}, maxsize=10)
        pool.acquire()

        with warnings.catch_warnings(record=True) as warns:
            pool.finalize()

        self.assertEqual(len(warns), 1)
        self.assertEqual([str(warn.message) for warn in warns],
                         ['finalize() called with unreleased connections'] *
                         len(warns))
Example #2
0
    def test_mismatched_release(self):
        mock_dbapi2 = mock.MagicMock()
        pool = ConnectionPool(mock_dbapi2, {}, maxsize=10)
        pool.acquire()

        with warnings.catch_warnings(record=True) as warns:
            pool.finalize()

        self.assertEqual(len(warns), 1)
        self.assertEqual(
            [str(warn.message) for warn in warns],
            ['finalize() called with unreleased connections'] * len(warns)
        )
Example #3
0
    def test_finalize(self):  # pylint: disable=no-self-use
        mock_dbapi2 = mock.MagicMock()
        pool = ConnectionPool(mock_dbapi2, {}, maxsize=10)

        pool.release(pool.acquire())

        pool.finalize()

        mock_dbapi2.assert_has_calls([
            mock.call.connect(),
            mock.call.connect().rollback(),
            mock.call.connect().close(),
        ])
Example #4
0
    def test_finalize(self): # pylint: disable=no-self-use
        mock_dbapi2 = mock.MagicMock()
        pool = ConnectionPool(mock_dbapi2, {}, maxsize=10)

        pool.release(pool.acquire())

        pool.finalize()

        mock_dbapi2.assert_has_calls(
            [
                mock.call.connect(),
                mock.call.connect().rollback(),
                mock.call.connect().close(),
            ]
        )