mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-09 19:06:51 +08:00
controller test (#9469)
This commit is contained in:
24
api/tests/integration_tests/controllers/app_fixture.py
Normal file
24
api/tests/integration_tests/controllers/app_fixture.py
Normal 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
|
||||
10
api/tests/integration_tests/controllers/test_controllers.py
Normal file
10
api/tests/integration_tests/controllers/test_controllers.py
Normal 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
|
||||
Reference in New Issue
Block a user