from app_new.extensions import db
from app_new.core.models.maintenance import WatchdogLog


def test_admin_can_clear_watchdog_logs(app, authenticated_client):
    with app.app_context():
        db.session.add(
            WatchdogLog(
                watchdog_name='test_watchdog',
                level='info',
                message='journal de test',
            )
        )
        db.session.commit()

    response = authenticated_client.post('/logs/clear')
    assert response.status_code == 302

    with app.app_context():
        assert WatchdogLog.query.count() == 0
