wip(handoff): restore backend suite to green
Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
@@ -472,19 +472,20 @@ class TestScriptBuilderSlugCollision:
|
||||
# Pre-create a template with slug "test-script" to cause collision
|
||||
user_resp = await client.get("/api/v1/auth/me", headers=auth_headers)
|
||||
user_id = user_resp.json()["id"]
|
||||
account_id = user_resp.json()["account_id"]
|
||||
await test_db.execute(
|
||||
sa.text("""
|
||||
INSERT INTO script_templates
|
||||
(id, category_id, created_by, name, slug, script_body,
|
||||
(id, category_id, created_by, account_id, name, slug, script_body,
|
||||
parameters_schema, default_values, validation_rules, tags,
|
||||
complexity, is_active, version, usage_count, created_at, updated_at)
|
||||
VALUES
|
||||
(:id, 'a0000000-0000-0000-0000-000000000001'::uuid, :uid,
|
||||
(:id, 'a0000000-0000-0000-0000-000000000001'::uuid, :uid, :account_id,
|
||||
'Test Script', 'test-script', 'echo hello',
|
||||
'{"parameters": []}', '{}', '{}', '["powershell"]',
|
||||
'beginner', true, 1, 0, NOW(), NOW())
|
||||
"""),
|
||||
{"id": str(uuid_mod.uuid4()), "uid": user_id},
|
||||
{"id": str(uuid_mod.uuid4()), "uid": user_id, "account_id": account_id},
|
||||
)
|
||||
await test_db.commit()
|
||||
|
||||
@@ -561,6 +562,7 @@ class TestScriptTemplateFilters:
|
||||
"""mine=true returns only templates created by the current user."""
|
||||
user_resp = await client.get("/api/v1/auth/me", headers=auth_headers)
|
||||
user_id = user_resp.json()["id"]
|
||||
account_id = user_resp.json()["account_id"]
|
||||
|
||||
second_resp = await client.get("/api/v1/auth/me", headers=second_user_headers)
|
||||
second_user_id = second_resp.json()["id"]
|
||||
@@ -571,32 +573,32 @@ class TestScriptTemplateFilters:
|
||||
await test_db.execute(
|
||||
sa.text("""
|
||||
INSERT INTO script_templates
|
||||
(id, category_id, created_by, team_id, name, slug, script_body,
|
||||
(id, category_id, created_by, account_id, team_id, name, slug, script_body,
|
||||
parameters_schema, default_values, validation_rules, tags,
|
||||
complexity, is_active, version, usage_count, created_at, updated_at)
|
||||
VALUES
|
||||
(:id, :cat, :uid, NULL,
|
||||
(:id, :cat, :uid, :account_id, NULL,
|
||||
'My Script', 'my-script', 'echo mine',
|
||||
'{"parameters": []}', '{}', '{}', '[]',
|
||||
'beginner', true, 1, 0, NOW(), NOW())
|
||||
"""),
|
||||
{"id": str(uuid_mod.uuid4()), "cat": cat_id, "uid": user_id},
|
||||
{"id": str(uuid_mod.uuid4()), "cat": cat_id, "uid": user_id, "account_id": account_id},
|
||||
)
|
||||
|
||||
# Create template owned by second user (no team_id, so visible to all)
|
||||
await test_db.execute(
|
||||
sa.text("""
|
||||
INSERT INTO script_templates
|
||||
(id, category_id, created_by, team_id, name, slug, script_body,
|
||||
(id, category_id, created_by, account_id, team_id, name, slug, script_body,
|
||||
parameters_schema, default_values, validation_rules, tags,
|
||||
complexity, is_active, version, usage_count, created_at, updated_at)
|
||||
VALUES
|
||||
(:id, :cat, :uid, NULL,
|
||||
(:id, :cat, :uid, :account_id, NULL,
|
||||
'Other Script', 'other-script', 'echo other',
|
||||
'{"parameters": []}', '{}', '{}', '[]',
|
||||
'beginner', true, 1, 0, NOW(), NOW())
|
||||
"""),
|
||||
{"id": str(uuid_mod.uuid4()), "cat": cat_id, "uid": second_user_id},
|
||||
{"id": str(uuid_mod.uuid4()), "cat": cat_id, "uid": second_user_id, "account_id": account_id},
|
||||
)
|
||||
await test_db.commit()
|
||||
|
||||
@@ -617,6 +619,7 @@ class TestScriptTemplateFilters:
|
||||
"""shared=true returns only templates shared with the user's team."""
|
||||
user_resp = await client.get("/api/v1/auth/me", headers=auth_headers)
|
||||
user_id = user_resp.json()["id"]
|
||||
account_id = user_resp.json()["account_id"]
|
||||
|
||||
cat_id = "b0000000-0000-0000-0000-000000000001"
|
||||
|
||||
@@ -639,32 +642,32 @@ class TestScriptTemplateFilters:
|
||||
await test_db.execute(
|
||||
sa.text("""
|
||||
INSERT INTO script_templates
|
||||
(id, category_id, created_by, team_id, name, slug, script_body,
|
||||
(id, category_id, created_by, account_id, team_id, name, slug, script_body,
|
||||
parameters_schema, default_values, validation_rules, tags,
|
||||
complexity, is_active, version, usage_count, created_at, updated_at)
|
||||
VALUES
|
||||
(:id, :cat, :uid, :tid,
|
||||
(:id, :cat, :uid, :account_id, :tid,
|
||||
'Team Script', 'team-script', 'echo team',
|
||||
'{"parameters": []}', '{}', '{}', '[]',
|
||||
'beginner', true, 1, 0, NOW(), NOW())
|
||||
"""),
|
||||
{"id": str(uuid_mod.uuid4()), "cat": cat_id, "uid": user_id, "tid": team_id},
|
||||
{"id": str(uuid_mod.uuid4()), "cat": cat_id, "uid": user_id, "account_id": account_id, "tid": team_id},
|
||||
)
|
||||
|
||||
# Template NOT shared (no team_id)
|
||||
await test_db.execute(
|
||||
sa.text("""
|
||||
INSERT INTO script_templates
|
||||
(id, category_id, created_by, team_id, name, slug, script_body,
|
||||
(id, category_id, created_by, account_id, team_id, name, slug, script_body,
|
||||
parameters_schema, default_values, validation_rules, tags,
|
||||
complexity, is_active, version, usage_count, created_at, updated_at)
|
||||
VALUES
|
||||
(:id, :cat, :uid, NULL,
|
||||
(:id, :cat, :uid, :account_id, NULL,
|
||||
'Personal Script', 'personal-script', 'echo personal',
|
||||
'{"parameters": []}', '{}', '{}', '[]',
|
||||
'beginner', true, 1, 0, NOW(), NOW())
|
||||
"""),
|
||||
{"id": str(uuid_mod.uuid4()), "cat": cat_id, "uid": user_id},
|
||||
{"id": str(uuid_mod.uuid4()), "cat": cat_id, "uid": user_id, "account_id": account_id},
|
||||
)
|
||||
await test_db.commit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user