remove .value (#26633)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -64,7 +64,7 @@ class TestAccountService:
|
||||
password=password,
|
||||
)
|
||||
assert account.email == email
|
||||
assert account.status == AccountStatus.ACTIVE.value
|
||||
assert account.status == AccountStatus.ACTIVE
|
||||
|
||||
# Login with correct password
|
||||
logged_in = AccountService.authenticate(email, password)
|
||||
@@ -185,7 +185,7 @@ class TestAccountService:
|
||||
)
|
||||
|
||||
# Ban the account
|
||||
account.status = AccountStatus.BANNED.value
|
||||
account.status = AccountStatus.BANNED
|
||||
from extensions.ext_database import db
|
||||
|
||||
db.session.commit()
|
||||
@@ -269,14 +269,14 @@ class TestAccountService:
|
||||
interface_language="en-US",
|
||||
password=password,
|
||||
)
|
||||
account.status = AccountStatus.PENDING.value
|
||||
account.status = AccountStatus.PENDING
|
||||
from extensions.ext_database import db
|
||||
|
||||
db.session.commit()
|
||||
|
||||
# Authenticate should activate the account
|
||||
authenticated_account = AccountService.authenticate(email, password)
|
||||
assert authenticated_account.status == AccountStatus.ACTIVE.value
|
||||
assert authenticated_account.status == AccountStatus.ACTIVE
|
||||
assert authenticated_account.initialized_at is not None
|
||||
|
||||
def test_update_account_password_success(self, db_session_with_containers, mock_external_service_dependencies):
|
||||
@@ -539,7 +539,7 @@ class TestAccountService:
|
||||
from extensions.ext_database import db
|
||||
|
||||
db.session.refresh(account)
|
||||
assert account.status == AccountStatus.CLOSED.value
|
||||
assert account.status == AccountStatus.CLOSED
|
||||
|
||||
def test_update_account_fields(self, db_session_with_containers, mock_external_service_dependencies):
|
||||
"""
|
||||
@@ -679,7 +679,7 @@ class TestAccountService:
|
||||
interface_language="en-US",
|
||||
password=password,
|
||||
)
|
||||
account.status = AccountStatus.PENDING.value
|
||||
account.status = AccountStatus.PENDING
|
||||
from extensions.ext_database import db
|
||||
|
||||
db.session.commit()
|
||||
@@ -688,7 +688,7 @@ class TestAccountService:
|
||||
token_pair = AccountService.login(account)
|
||||
|
||||
db.session.refresh(account)
|
||||
assert account.status == AccountStatus.ACTIVE.value
|
||||
assert account.status == AccountStatus.ACTIVE
|
||||
|
||||
def test_logout(self, db_session_with_containers, mock_external_service_dependencies):
|
||||
"""
|
||||
@@ -860,7 +860,7 @@ class TestAccountService:
|
||||
)
|
||||
|
||||
# Ban the account
|
||||
account.status = AccountStatus.BANNED.value
|
||||
account.status = AccountStatus.BANNED
|
||||
from extensions.ext_database import db
|
||||
|
||||
db.session.commit()
|
||||
@@ -990,7 +990,7 @@ class TestAccountService:
|
||||
)
|
||||
|
||||
# Ban the account
|
||||
account.status = AccountStatus.BANNED.value
|
||||
account.status = AccountStatus.BANNED
|
||||
from extensions.ext_database import db
|
||||
|
||||
db.session.commit()
|
||||
|
||||
@@ -86,7 +86,7 @@ class TestFileService:
|
||||
join = TenantAccountJoin(
|
||||
tenant_id=tenant.id,
|
||||
account_id=account.id,
|
||||
role=TenantAccountRole.OWNER.value,
|
||||
role=TenantAccountRole.OWNER,
|
||||
current=True,
|
||||
)
|
||||
db.session.add(join)
|
||||
@@ -187,7 +187,7 @@ class TestFileService:
|
||||
assert upload_file.extension == "pdf"
|
||||
assert upload_file.mime_type == mimetype
|
||||
assert upload_file.created_by == account.id
|
||||
assert upload_file.created_by_role == CreatorUserRole.ACCOUNT.value
|
||||
assert upload_file.created_by_role == CreatorUserRole.ACCOUNT
|
||||
assert upload_file.used is False
|
||||
assert upload_file.hash == hashlib.sha3_256(content).hexdigest()
|
||||
|
||||
@@ -216,7 +216,7 @@ class TestFileService:
|
||||
|
||||
assert upload_file is not None
|
||||
assert upload_file.created_by == end_user.id
|
||||
assert upload_file.created_by_role == CreatorUserRole.END_USER.value
|
||||
assert upload_file.created_by_role == CreatorUserRole.END_USER
|
||||
|
||||
def test_upload_file_with_datasets_source(
|
||||
self, db_session_with_containers, engine, mock_external_service_dependencies
|
||||
|
||||
@@ -72,7 +72,7 @@ class TestMetadataService:
|
||||
join = TenantAccountJoin(
|
||||
tenant_id=tenant.id,
|
||||
account_id=account.id,
|
||||
role=TenantAccountRole.OWNER.value,
|
||||
role=TenantAccountRole.OWNER,
|
||||
current=True,
|
||||
)
|
||||
db.session.add(join)
|
||||
|
||||
@@ -103,7 +103,7 @@ class TestModelLoadBalancingService:
|
||||
join = TenantAccountJoin(
|
||||
tenant_id=tenant.id,
|
||||
account_id=account.id,
|
||||
role=TenantAccountRole.OWNER.value,
|
||||
role=TenantAccountRole.OWNER,
|
||||
current=True,
|
||||
)
|
||||
db.session.add(join)
|
||||
|
||||
@@ -67,7 +67,7 @@ class TestModelProviderService:
|
||||
join = TenantAccountJoin(
|
||||
tenant_id=tenant.id,
|
||||
account_id=account.id,
|
||||
role=TenantAccountRole.OWNER.value,
|
||||
role=TenantAccountRole.OWNER,
|
||||
current=True,
|
||||
)
|
||||
db.session.add(join)
|
||||
|
||||
@@ -66,7 +66,7 @@ class TestTagService:
|
||||
join = TenantAccountJoin(
|
||||
tenant_id=tenant.id,
|
||||
account_id=account.id,
|
||||
role=TenantAccountRole.OWNER.value,
|
||||
role=TenantAccountRole.OWNER,
|
||||
current=True,
|
||||
)
|
||||
db.session.add(join)
|
||||
|
||||
@@ -144,7 +144,7 @@ class TestWebConversationService:
|
||||
system_instruction=fake.text(max_nb_chars=300),
|
||||
system_instruction_tokens=50,
|
||||
status="normal",
|
||||
invoke_from=InvokeFrom.WEB_APP.value,
|
||||
invoke_from=InvokeFrom.WEB_APP,
|
||||
from_source="console" if isinstance(user, Account) else "api",
|
||||
from_end_user_id=user.id if isinstance(user, EndUser) else None,
|
||||
from_account_id=user.id if isinstance(user, Account) else None,
|
||||
|
||||
@@ -87,7 +87,7 @@ class TestWebAppAuthService:
|
||||
join = TenantAccountJoin(
|
||||
tenant_id=tenant.id,
|
||||
account_id=account.id,
|
||||
role=TenantAccountRole.OWNER.value,
|
||||
role=TenantAccountRole.OWNER,
|
||||
current=True,
|
||||
)
|
||||
db.session.add(join)
|
||||
@@ -150,7 +150,7 @@ class TestWebAppAuthService:
|
||||
join = TenantAccountJoin(
|
||||
tenant_id=tenant.id,
|
||||
account_id=account.id,
|
||||
role=TenantAccountRole.OWNER.value,
|
||||
role=TenantAccountRole.OWNER,
|
||||
current=True,
|
||||
)
|
||||
db.session.add(join)
|
||||
@@ -232,7 +232,7 @@ class TestWebAppAuthService:
|
||||
assert result.id == account.id
|
||||
assert result.email == account.email
|
||||
assert result.name == account.name
|
||||
assert result.status == AccountStatus.ACTIVE.value
|
||||
assert result.status == AccountStatus.ACTIVE
|
||||
|
||||
# Verify database state
|
||||
from extensions.ext_database import db
|
||||
@@ -280,7 +280,7 @@ class TestWebAppAuthService:
|
||||
email=fake.email(),
|
||||
name=fake.name(),
|
||||
interface_language="en-US",
|
||||
status=AccountStatus.BANNED.value,
|
||||
status=AccountStatus.BANNED,
|
||||
)
|
||||
|
||||
# Hash password
|
||||
@@ -411,7 +411,7 @@ class TestWebAppAuthService:
|
||||
assert result.id == account.id
|
||||
assert result.email == account.email
|
||||
assert result.name == account.name
|
||||
assert result.status == AccountStatus.ACTIVE.value
|
||||
assert result.status == AccountStatus.ACTIVE
|
||||
|
||||
# Verify database state
|
||||
from extensions.ext_database import db
|
||||
@@ -455,7 +455,7 @@ class TestWebAppAuthService:
|
||||
email=unique_email,
|
||||
name=fake.name(),
|
||||
interface_language="en-US",
|
||||
status=AccountStatus.BANNED.value,
|
||||
status=AccountStatus.BANNED,
|
||||
)
|
||||
|
||||
from extensions.ext_database import db
|
||||
|
||||
@@ -199,7 +199,7 @@ class TestWorkflowAppService:
|
||||
elapsed_time=1.5,
|
||||
total_tokens=100,
|
||||
total_steps=3,
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC),
|
||||
finished_at=datetime.now(UTC),
|
||||
@@ -215,7 +215,7 @@ class TestWorkflowAppService:
|
||||
workflow_id=workflow.id,
|
||||
workflow_run_id=workflow_run.id,
|
||||
created_from="service-api",
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
@@ -356,7 +356,7 @@ class TestWorkflowAppService:
|
||||
elapsed_time=1.0 + i,
|
||||
total_tokens=100 + i * 10,
|
||||
total_steps=3,
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i),
|
||||
finished_at=datetime.now(UTC) + timedelta(minutes=i + 1) if status != "running" else None,
|
||||
@@ -371,7 +371,7 @@ class TestWorkflowAppService:
|
||||
workflow_id=workflow.id,
|
||||
workflow_run_id=workflow_run.id,
|
||||
created_from="service-api",
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i),
|
||||
)
|
||||
@@ -464,7 +464,7 @@ class TestWorkflowAppService:
|
||||
elapsed_time=1.0,
|
||||
total_tokens=100,
|
||||
total_steps=3,
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=timestamp,
|
||||
finished_at=timestamp + timedelta(minutes=1),
|
||||
@@ -479,7 +479,7 @@ class TestWorkflowAppService:
|
||||
workflow_id=workflow.id,
|
||||
workflow_run_id=workflow_run.id,
|
||||
created_from="service-api",
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=timestamp,
|
||||
)
|
||||
@@ -571,7 +571,7 @@ class TestWorkflowAppService:
|
||||
elapsed_time=1.0,
|
||||
total_tokens=100,
|
||||
total_steps=3,
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i),
|
||||
finished_at=datetime.now(UTC) + timedelta(minutes=i + 1),
|
||||
@@ -586,7 +586,7 @@ class TestWorkflowAppService:
|
||||
workflow_id=workflow.id,
|
||||
workflow_run_id=workflow_run.id,
|
||||
created_from="service-api",
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i),
|
||||
)
|
||||
@@ -701,7 +701,7 @@ class TestWorkflowAppService:
|
||||
elapsed_time=1.0,
|
||||
total_tokens=100,
|
||||
total_steps=3,
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i),
|
||||
finished_at=datetime.now(UTC) + timedelta(minutes=i + 1),
|
||||
@@ -716,7 +716,7 @@ class TestWorkflowAppService:
|
||||
workflow_id=workflow.id,
|
||||
workflow_run_id=workflow_run.id,
|
||||
created_from="service-api",
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i),
|
||||
)
|
||||
@@ -743,7 +743,7 @@ class TestWorkflowAppService:
|
||||
elapsed_time=1.0,
|
||||
total_tokens=100,
|
||||
total_steps=3,
|
||||
created_by_role=CreatorUserRole.END_USER.value,
|
||||
created_by_role=CreatorUserRole.END_USER,
|
||||
created_by=end_user.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i + 10),
|
||||
finished_at=datetime.now(UTC) + timedelta(minutes=i + 11),
|
||||
@@ -758,7 +758,7 @@ class TestWorkflowAppService:
|
||||
workflow_id=workflow.id,
|
||||
workflow_run_id=workflow_run.id,
|
||||
created_from="web-app",
|
||||
created_by_role=CreatorUserRole.END_USER.value,
|
||||
created_by_role=CreatorUserRole.END_USER,
|
||||
created_by=end_user.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i + 10),
|
||||
)
|
||||
@@ -780,14 +780,14 @@ class TestWorkflowAppService:
|
||||
limit=20,
|
||||
)
|
||||
assert result_session_filter["total"] == 2
|
||||
assert all(log.created_by_role == CreatorUserRole.END_USER.value for log in result_session_filter["data"])
|
||||
assert all(log.created_by_role == CreatorUserRole.END_USER for log in result_session_filter["data"])
|
||||
|
||||
# Test filtering by account email
|
||||
result_account_filter = service.get_paginate_workflow_app_logs(
|
||||
session=db_session_with_containers, app_model=app, created_by_account=account.email, page=1, limit=20
|
||||
)
|
||||
assert result_account_filter["total"] == 3
|
||||
assert all(log.created_by_role == CreatorUserRole.ACCOUNT.value for log in result_account_filter["data"])
|
||||
assert all(log.created_by_role == CreatorUserRole.ACCOUNT for log in result_account_filter["data"])
|
||||
|
||||
# Test filtering by non-existent session ID
|
||||
result_no_session = service.get_paginate_workflow_app_logs(
|
||||
@@ -853,7 +853,7 @@ class TestWorkflowAppService:
|
||||
elapsed_time=1.0,
|
||||
total_tokens=100,
|
||||
total_steps=3,
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC),
|
||||
finished_at=datetime.now(UTC) + timedelta(minutes=1),
|
||||
@@ -869,7 +869,7 @@ class TestWorkflowAppService:
|
||||
workflow_id=workflow.id,
|
||||
workflow_run_id=workflow_run.id,
|
||||
created_from="service-api",
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
@@ -943,7 +943,7 @@ class TestWorkflowAppService:
|
||||
elapsed_time=0.0, # Edge case: 0 elapsed time
|
||||
total_tokens=0, # Edge case: 0 tokens
|
||||
total_steps=0, # Edge case: 0 steps
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC),
|
||||
finished_at=datetime.now(UTC),
|
||||
@@ -959,7 +959,7 @@ class TestWorkflowAppService:
|
||||
workflow_id=workflow.id,
|
||||
workflow_run_id=workflow_run.id,
|
||||
created_from="service-api",
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
@@ -1098,7 +1098,7 @@ class TestWorkflowAppService:
|
||||
elapsed_time=1.5,
|
||||
total_tokens=100,
|
||||
total_steps=3,
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i),
|
||||
finished_at=datetime.now(UTC) + timedelta(minutes=i + 1) if status == "succeeded" else None,
|
||||
@@ -1113,7 +1113,7 @@ class TestWorkflowAppService:
|
||||
workflow_id=workflow.id,
|
||||
workflow_run_id=workflow_run.id,
|
||||
created_from="service-api",
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i),
|
||||
)
|
||||
@@ -1198,7 +1198,7 @@ class TestWorkflowAppService:
|
||||
elapsed_time=1.5,
|
||||
total_tokens=100,
|
||||
total_steps=3,
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i),
|
||||
finished_at=datetime.now(UTC) + timedelta(minutes=i + 1) if status != "running" else None,
|
||||
@@ -1213,7 +1213,7 @@ class TestWorkflowAppService:
|
||||
workflow_id=workflow.id,
|
||||
workflow_run_id=workflow_run.id,
|
||||
created_from="service-api",
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i),
|
||||
)
|
||||
@@ -1300,7 +1300,7 @@ class TestWorkflowAppService:
|
||||
elapsed_time=1.5,
|
||||
total_tokens=100,
|
||||
total_steps=3,
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i * 10 + j),
|
||||
finished_at=datetime.now(UTC) + timedelta(minutes=i * 10 + j + 1),
|
||||
@@ -1315,7 +1315,7 @@ class TestWorkflowAppService:
|
||||
workflow_id=workflow.id,
|
||||
workflow_run_id=workflow_run.id,
|
||||
created_from="service-api",
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC) + timedelta(minutes=i * 10 + j),
|
||||
)
|
||||
|
||||
@@ -130,7 +130,7 @@ class TestWorkflowRunService:
|
||||
elapsed_time=1.5,
|
||||
total_tokens=100,
|
||||
total_steps=3,
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=created_time,
|
||||
finished_at=created_time,
|
||||
@@ -167,7 +167,7 @@ class TestWorkflowRunService:
|
||||
inputs={},
|
||||
status="normal",
|
||||
mode="chat",
|
||||
from_source=CreatorUserRole.ACCOUNT.value,
|
||||
from_source=CreatorUserRole.ACCOUNT,
|
||||
from_account_id=account.id,
|
||||
)
|
||||
db.session.add(conversation)
|
||||
@@ -188,7 +188,7 @@ class TestWorkflowRunService:
|
||||
message.answer_price_unit = 0.001
|
||||
message.currency = "USD"
|
||||
message.status = "normal"
|
||||
message.from_source = CreatorUserRole.ACCOUNT.value
|
||||
message.from_source = CreatorUserRole.ACCOUNT
|
||||
message.from_account_id = account.id
|
||||
message.workflow_run_id = workflow_run.id
|
||||
message.inputs = {"input": "test input"}
|
||||
@@ -458,7 +458,7 @@ class TestWorkflowRunService:
|
||||
status="succeeded",
|
||||
elapsed_time=0.5,
|
||||
execution_metadata=json.dumps({"tokens": 50}),
|
||||
created_by_role=CreatorUserRole.ACCOUNT.value,
|
||||
created_by_role=CreatorUserRole.ACCOUNT,
|
||||
created_by=account.id,
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
@@ -689,7 +689,7 @@ class TestWorkflowRunService:
|
||||
status="succeeded",
|
||||
elapsed_time=0.5,
|
||||
execution_metadata=json.dumps({"tokens": 50}),
|
||||
created_by_role=CreatorUserRole.END_USER.value,
|
||||
created_by_role=CreatorUserRole.END_USER,
|
||||
created_by=end_user.id,
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
@@ -710,4 +710,4 @@ class TestWorkflowRunService:
|
||||
assert node_exec.app_id == app.id
|
||||
assert node_exec.workflow_run_id == workflow_run.id
|
||||
assert node_exec.created_by == end_user.id
|
||||
assert node_exec.created_by_role == CreatorUserRole.END_USER.value
|
||||
assert node_exec.created_by_role == CreatorUserRole.END_USER
|
||||
|
||||
@@ -130,7 +130,7 @@ class TestWorkflowService:
|
||||
id=fake.uuid4(),
|
||||
tenant_id=app.tenant_id,
|
||||
app_id=app.id,
|
||||
type=WorkflowType.WORKFLOW.value,
|
||||
type=WorkflowType.WORKFLOW,
|
||||
version=Workflow.VERSION_DRAFT,
|
||||
graph=json.dumps({"nodes": [], "edges": []}),
|
||||
features=json.dumps({"features": []}),
|
||||
@@ -176,7 +176,7 @@ class TestWorkflowService:
|
||||
node_execution.node_type = "test_node"
|
||||
node_execution.title = "Test Node" # Required field
|
||||
node_execution.status = "succeeded"
|
||||
node_execution.created_by_role = CreatorUserRole.ACCOUNT.value # Required field
|
||||
node_execution.created_by_role = CreatorUserRole.ACCOUNT # Required field
|
||||
node_execution.created_by = account.id # Required field
|
||||
node_execution.created_at = fake.date_time_this_year()
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class TestWorkspaceService:
|
||||
join = TenantAccountJoin(
|
||||
tenant_id=tenant.id,
|
||||
account_id=account.id,
|
||||
role=TenantAccountRole.OWNER.value,
|
||||
role=TenantAccountRole.OWNER,
|
||||
current=True,
|
||||
)
|
||||
db.session.add(join)
|
||||
@@ -111,7 +111,7 @@ class TestWorkspaceService:
|
||||
assert result["name"] == tenant.name
|
||||
assert result["plan"] == tenant.plan
|
||||
assert result["status"] == tenant.status
|
||||
assert result["role"] == TenantAccountRole.OWNER.value
|
||||
assert result["role"] == TenantAccountRole.OWNER
|
||||
assert result["created_at"] == tenant.created_at
|
||||
assert result["trial_end_reason"] is None
|
||||
|
||||
@@ -159,7 +159,7 @@ class TestWorkspaceService:
|
||||
assert result["name"] == tenant.name
|
||||
assert result["plan"] == tenant.plan
|
||||
assert result["status"] == tenant.status
|
||||
assert result["role"] == TenantAccountRole.OWNER.value
|
||||
assert result["role"] == TenantAccountRole.OWNER
|
||||
assert result["created_at"] == tenant.created_at
|
||||
assert result["trial_end_reason"] is None
|
||||
|
||||
@@ -194,7 +194,7 @@ class TestWorkspaceService:
|
||||
from extensions.ext_database import db
|
||||
|
||||
join = db.session.query(TenantAccountJoin).filter_by(tenant_id=tenant.id, account_id=account.id).first()
|
||||
join.role = TenantAccountRole.NORMAL.value
|
||||
join.role = TenantAccountRole.NORMAL
|
||||
db.session.commit()
|
||||
|
||||
# Setup mocks for feature service
|
||||
@@ -212,7 +212,7 @@ class TestWorkspaceService:
|
||||
assert result["name"] == tenant.name
|
||||
assert result["plan"] == tenant.plan
|
||||
assert result["status"] == tenant.status
|
||||
assert result["role"] == TenantAccountRole.NORMAL.value
|
||||
assert result["role"] == TenantAccountRole.NORMAL
|
||||
assert result["created_at"] == tenant.created_at
|
||||
assert result["trial_end_reason"] is None
|
||||
|
||||
@@ -245,7 +245,7 @@ class TestWorkspaceService:
|
||||
from extensions.ext_database import db
|
||||
|
||||
join = db.session.query(TenantAccountJoin).filter_by(tenant_id=tenant.id, account_id=account.id).first()
|
||||
join.role = TenantAccountRole.ADMIN.value
|
||||
join.role = TenantAccountRole.ADMIN
|
||||
db.session.commit()
|
||||
|
||||
# Setup mocks for feature service and tenant service
|
||||
@@ -260,7 +260,7 @@ class TestWorkspaceService:
|
||||
|
||||
# Assert: Verify the expected outcomes
|
||||
assert result is not None
|
||||
assert result["role"] == TenantAccountRole.ADMIN.value
|
||||
assert result["role"] == TenantAccountRole.ADMIN
|
||||
|
||||
# Verify custom config is included for admin users
|
||||
assert "custom_config" in result
|
||||
@@ -378,7 +378,7 @@ class TestWorkspaceService:
|
||||
from extensions.ext_database import db
|
||||
|
||||
join = db.session.query(TenantAccountJoin).filter_by(tenant_id=tenant.id, account_id=account.id).first()
|
||||
join.role = TenantAccountRole.EDITOR.value
|
||||
join.role = TenantAccountRole.EDITOR
|
||||
db.session.commit()
|
||||
|
||||
# Setup mocks for feature service and tenant service
|
||||
@@ -394,7 +394,7 @@ class TestWorkspaceService:
|
||||
|
||||
# Assert: Verify the expected outcomes
|
||||
assert result is not None
|
||||
assert result["role"] == TenantAccountRole.EDITOR.value
|
||||
assert result["role"] == TenantAccountRole.EDITOR
|
||||
|
||||
# Verify custom config is not included for editor users without admin privileges
|
||||
assert "custom_config" not in result
|
||||
@@ -425,7 +425,7 @@ class TestWorkspaceService:
|
||||
from extensions.ext_database import db
|
||||
|
||||
join = db.session.query(TenantAccountJoin).filter_by(tenant_id=tenant.id, account_id=account.id).first()
|
||||
join.role = TenantAccountRole.DATASET_OPERATOR.value
|
||||
join.role = TenantAccountRole.DATASET_OPERATOR
|
||||
db.session.commit()
|
||||
|
||||
# Setup mocks for feature service and tenant service
|
||||
@@ -441,7 +441,7 @@ class TestWorkspaceService:
|
||||
|
||||
# Assert: Verify the expected outcomes
|
||||
assert result is not None
|
||||
assert result["role"] == TenantAccountRole.DATASET_OPERATOR.value
|
||||
assert result["role"] == TenantAccountRole.DATASET_OPERATOR
|
||||
|
||||
# Verify custom config is not included for dataset operators without admin privileges
|
||||
assert "custom_config" not in result
|
||||
|
||||
@@ -72,7 +72,7 @@ class TestApiToolManageService:
|
||||
join = TenantAccountJoin(
|
||||
tenant_id=tenant.id,
|
||||
account_id=account.id,
|
||||
role=TenantAccountRole.OWNER.value,
|
||||
role=TenantAccountRole.OWNER,
|
||||
current=True,
|
||||
)
|
||||
db.session.add(join)
|
||||
|
||||
@@ -72,7 +72,7 @@ class TestMCPToolManageService:
|
||||
join = TenantAccountJoin(
|
||||
tenant_id=tenant.id,
|
||||
account_id=account.id,
|
||||
role=TenantAccountRole.OWNER.value,
|
||||
role=TenantAccountRole.OWNER,
|
||||
current=True,
|
||||
)
|
||||
db.session.add(join)
|
||||
|
||||
@@ -168,7 +168,7 @@ class TestToolTransformService:
|
||||
"""
|
||||
# Arrange: Setup test data
|
||||
fake = Faker()
|
||||
provider_type = ToolProviderType.BUILT_IN.value
|
||||
provider_type = ToolProviderType.BUILT_IN
|
||||
provider_name = fake.company()
|
||||
icon = "🔧"
|
||||
|
||||
@@ -206,7 +206,7 @@ class TestToolTransformService:
|
||||
"""
|
||||
# Arrange: Setup test data
|
||||
fake = Faker()
|
||||
provider_type = ToolProviderType.API.value
|
||||
provider_type = ToolProviderType.API
|
||||
provider_name = fake.company()
|
||||
icon = '{"background": "#FF6B6B", "content": "🔧"}'
|
||||
|
||||
@@ -231,7 +231,7 @@ class TestToolTransformService:
|
||||
"""
|
||||
# Arrange: Setup test data with invalid JSON
|
||||
fake = Faker()
|
||||
provider_type = ToolProviderType.API.value
|
||||
provider_type = ToolProviderType.API
|
||||
provider_name = fake.company()
|
||||
icon = '{"invalid": json}'
|
||||
|
||||
@@ -257,7 +257,7 @@ class TestToolTransformService:
|
||||
"""
|
||||
# Arrange: Setup test data
|
||||
fake = Faker()
|
||||
provider_type = ToolProviderType.WORKFLOW.value
|
||||
provider_type = ToolProviderType.WORKFLOW
|
||||
provider_name = fake.company()
|
||||
icon = {"background": "#FF6B6B", "content": "🔧"}
|
||||
|
||||
@@ -282,7 +282,7 @@ class TestToolTransformService:
|
||||
"""
|
||||
# Arrange: Setup test data
|
||||
fake = Faker()
|
||||
provider_type = ToolProviderType.MCP.value
|
||||
provider_type = ToolProviderType.MCP
|
||||
provider_name = fake.company()
|
||||
icon = {"background": "#FF6B6B", "content": "🔧"}
|
||||
|
||||
@@ -329,7 +329,7 @@ class TestToolTransformService:
|
||||
# Arrange: Setup test data
|
||||
fake = Faker()
|
||||
tenant_id = fake.uuid4()
|
||||
provider = {"type": ToolProviderType.BUILT_IN.value, "name": fake.company(), "icon": "🔧"}
|
||||
provider = {"type": ToolProviderType.BUILT_IN, "name": fake.company(), "icon": "🔧"}
|
||||
|
||||
# Act: Execute the method under test
|
||||
ToolTransformService.repack_provider(tenant_id, provider)
|
||||
|
||||
@@ -66,7 +66,7 @@ class TestWorkflowConverter:
|
||||
mock_config.model = ModelConfigEntity(
|
||||
provider="openai",
|
||||
model="gpt-4",
|
||||
mode=LLMMode.CHAT.value,
|
||||
mode=LLMMode.CHAT,
|
||||
parameters={},
|
||||
stop=[],
|
||||
)
|
||||
@@ -120,7 +120,7 @@ class TestWorkflowConverter:
|
||||
join = TenantAccountJoin(
|
||||
tenant_id=tenant.id,
|
||||
account_id=account.id,
|
||||
role=TenantAccountRole.OWNER.value,
|
||||
role=TenantAccountRole.OWNER,
|
||||
current=True,
|
||||
)
|
||||
db.session.add(join)
|
||||
@@ -150,7 +150,7 @@ class TestWorkflowConverter:
|
||||
app = App(
|
||||
tenant_id=tenant.id,
|
||||
name=fake.company(),
|
||||
mode=AppMode.CHAT.value,
|
||||
mode=AppMode.CHAT,
|
||||
icon_type="emoji",
|
||||
icon="🤖",
|
||||
icon_background="#FF6B6B",
|
||||
@@ -218,7 +218,7 @@ class TestWorkflowConverter:
|
||||
# Assert: Verify the expected outcomes
|
||||
assert new_app is not None
|
||||
assert new_app.name == "Test Workflow App"
|
||||
assert new_app.mode == AppMode.ADVANCED_CHAT.value
|
||||
assert new_app.mode == AppMode.ADVANCED_CHAT
|
||||
assert new_app.icon_type == "emoji"
|
||||
assert new_app.icon == "🚀"
|
||||
assert new_app.icon_background == "#4CAF50"
|
||||
@@ -257,7 +257,7 @@ class TestWorkflowConverter:
|
||||
app = App(
|
||||
tenant_id=tenant.id,
|
||||
name=fake.company(),
|
||||
mode=AppMode.CHAT.value,
|
||||
mode=AppMode.CHAT,
|
||||
icon_type="emoji",
|
||||
icon="🤖",
|
||||
icon_background="#FF6B6B",
|
||||
@@ -522,7 +522,7 @@ class TestWorkflowConverter:
|
||||
model_config = ModelConfigEntity(
|
||||
provider="openai",
|
||||
model="gpt-4",
|
||||
mode=LLMMode.CHAT.value,
|
||||
mode=LLMMode.CHAT,
|
||||
parameters={"temperature": 0.7},
|
||||
stop=[],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user