11import os
22import sys
33from unittest .mock import MagicMock , patch
4+
45import pytest
56from fastapi .testclient import TestClient
67
@@ -48,8 +49,8 @@ def test_input_task_invalid_json():
4849 response = client .post ("/input_task" , data = invalid_json , headers = headers )
4950
5051
51- def test_create_plan_endpoint_success ():
52- """Test the /api/create_plan endpoint with valid input."""
52+ def test_process_request_endpoint_success ():
53+ """Test the /api/process_request endpoint with valid input."""
5354 headers = {"Authorization" : "Bearer mock-token" }
5455
5556 # Mock the RAI success function
@@ -66,7 +67,7 @@ def test_create_plan_endpoint_success():
6667 "description" : "Create a marketing plan for our new product"
6768 }
6869
69- response = client .post ("/api/create_plan " , json = test_input , headers = headers )
70+ response = client .post ("/api/process_request " , json = test_input , headers = headers )
7071
7172 # Print response details for debugging
7273 print (f"Response status: { response .status_code } " )
@@ -85,8 +86,8 @@ def test_create_plan_endpoint_success():
8586 mock_memory_store .add_plan .assert_called_once ()
8687
8788
88- def test_create_plan_endpoint_rai_failure ():
89- """Test the /api/create_plan endpoint when RAI check fails."""
89+ def test_process_request_endpoint_rai_failure ():
90+ """Test the /api/process_request endpoint when RAI check fails."""
9091 headers = {"Authorization" : "Bearer mock-token" }
9192
9293 # Mock the RAI failure
@@ -98,7 +99,7 @@ def test_create_plan_endpoint_rai_failure():
9899 "description" : "This is an unsafe description"
99100 }
100101
101- response = client .post ("/api/create_plan " , json = test_input , headers = headers )
102+ response = client .post ("/api/process_request " , json = test_input , headers = headers )
102103
103104 # Check response
104105 assert response .status_code == 400
@@ -107,8 +108,8 @@ def test_create_plan_endpoint_rai_failure():
107108 assert "safety validation" in data ["detail" ]
108109
109110
110- def test_create_plan_endpoint_harmful_content ():
111- """Test the /api/create_plan endpoint with harmful content that should fail RAI."""
111+ def test_process_request_endpoint_harmful_content ():
112+ """Test the /api/process_request endpoint with harmful content that should fail RAI."""
112113 headers = {"Authorization" : "Bearer mock-token" }
113114
114115 # Mock the RAI failure for harmful content
@@ -120,7 +121,7 @@ def test_create_plan_endpoint_harmful_content():
120121 "description" : "I want to kill my neighbors cat"
121122 }
122123
123- response = client .post ("/api/create_plan " , json = test_input , headers = headers )
124+ response = client .post ("/api/process_request " , json = test_input , headers = headers )
124125
125126 # Print response details for debugging
126127 print (f"Response status: { response .status_code } " )
@@ -133,8 +134,8 @@ def test_create_plan_endpoint_harmful_content():
133134 assert "safety validation" in data ["detail" ]
134135
135136
136- def test_create_plan_endpoint_real_rai_check ():
137- """Test the /api/create_plan endpoint with real RAI check (no mocking)."""
137+ def test_process_request_endpoint_real_rai_check ():
138+ """Test the /api/process_request endpoint with real RAI check (no mocking)."""
138139 headers = {"Authorization" : "Bearer mock-token" }
139140
140141 # Don't mock RAI - let it run the real check
@@ -150,7 +151,7 @@ def test_create_plan_endpoint_real_rai_check():
150151 "description" : "I want to kill my neighbors cat"
151152 }
152153
153- response = client .post ("/api/create_plan " , json = test_input , headers = headers )
154+ response = client .post ("/api/process_request " , json = test_input , headers = headers )
154155
155156 # Print response details for debugging
156157 print (f"Real RAI Response status: { response .status_code } " )
0 commit comments