def test_database_ping__raises_exception_on_failure(db: Database): mocked_scalar = mock.Mock(side_effect=DBAPIError(None, None, None)) mocked_engine = create_engine_mock(scalar=mocked_scalar) with mock_db(db, engine=mocked_engine): with pytest.raises(DBAPIError): db.ping()
def test_database_ping__raises_when_invalidated_connection_retry_fails( db: Database): mocked_scalar = mock.Mock( side_effect=DBAPIError(None, None, None, connection_invalidated=True)) mocked_engine = create_engine_mock(scalar=mocked_scalar) with mock_db(db, engine=mocked_engine): with pytest.raises(DBAPIError): db.ping()
def test_database_ping__retries_on_invalidated_connection(filedb: Database): mocked_scalar = mock.Mock(side_effect=[ DBAPIError(None, None, None, connection_invalidated=True), 1 ]) mocked_engine = create_engine_mock(scalar=mocked_scalar) with mock_db(filedb, engine=mocked_engine): assert filedb.ping() is True
def test_database_ping__returns_true_on_success(filedb: Database): assert filedb.ping() is True