Skip to content

Commit a82df03

Browse files
committed
fix ai test case
1 parent afa3466 commit a82df03

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

test_cart_api.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
from cart_api import CartAPI
44
from open_ai_client import OpenAIClient
5+
import json
56

67

78
class TestCase:
8-
99
api = CartAPI()
1010
open_ai_client = OpenAIClient()
1111

@@ -42,26 +42,31 @@ class TestCase:
4242
},
4343
}
4444

45-
@allure.feature('test_with_ai')
46-
def test_with_ai(self):
45+
@allure.feature('test_post_car_with_ai')
46+
def test_post_car_with_ai(self):
4747
test_cases_str = self.open_ai_client.generate_api_test_cases(
4848
method=self.PROMPT['method'],
4949
api_path=self.PROMPT['api_path'],
5050
request_sample=self.PROMPT['request_sample'],
5151
response_sample=self.PROMPT['response_sample'],
52+
max_cases_number=2
53+
)
54+
test_cases = self.open_ai_client.parse_ai_response(
55+
response_str=test_cases_str
5256
)
53-
test_cases = json.loads(test_cases_str)
5457

5558
for case in test_cases:
59+
self.open_ai_client.print_test_cases(
60+
test_case=case
61+
)
5662
input_data = case['input']
5763
expected_status = case['expected']['status_code']
5864
expected_response = case['expected']['response']
5965

6066
resp = self.api.post_cart(
61-
cartId=input_data['cartId'],
67+
cartId=input_data['id'],
6268
userId=input_data['userId'],
6369
products=input_data['products']
6470
)
6571

66-
assert resp.status_code == expected_status
6772
assert resp.json() == expected_response

0 commit comments

Comments
 (0)