controller test (#9469)

This commit is contained in:
Sergio Sacristán 2024-10-18 02:23:36 +02:00 • committed by GitHub
commit 28de676956
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 249 additions and 203 deletions

View file

@ -0,0 +1,24 @@
import pytest
from app_factory import create_app
mock_user = type(
"MockUser",
(object,),
{
"is_authenticated": True,
"id": "123",
"is_editor": True,
"is_dataset_editor": True,
"status": "active",
"get_id": "123",
"current_tenant_id": "9d2074fc-6f86-45a9-b09d-6ecc63b9056b",
},
)
@pytest.fixture
def app():
app = create_app()
app.config["LOGIN_DISABLED"] = True
return app

View file

@ -0,0 +1,10 @@
from unittest.mock import patch
from app_fixture import app, mock_user
def test_post_requires_login(app):
with app.test_client() as client:
with patch("flask_login.utils._get_user", mock_user):
response = client.get("/console/api/data-source/integrates")
assert response.status_code == 200