|
2 | 2 |
|
3 | 3 | from cart_api import CartAPI |
4 | 4 | from open_ai_client import OpenAIClient |
| 5 | +import json |
5 | 6 |
|
6 | 7 |
|
7 | 8 | class TestCase: |
8 | | - |
9 | 9 | api = CartAPI() |
10 | 10 | open_ai_client = OpenAIClient() |
11 | 11 |
|
@@ -42,26 +42,31 @@ class TestCase: |
42 | 42 | }, |
43 | 43 | } |
44 | 44 |
|
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): |
47 | 47 | test_cases_str = self.open_ai_client.generate_api_test_cases( |
48 | 48 | method=self.PROMPT['method'], |
49 | 49 | api_path=self.PROMPT['api_path'], |
50 | 50 | request_sample=self.PROMPT['request_sample'], |
51 | 51 | 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 |
52 | 56 | ) |
53 | | - test_cases = json.loads(test_cases_str) |
54 | 57 |
|
55 | 58 | for case in test_cases: |
| 59 | + self.open_ai_client.print_test_cases( |
| 60 | + test_case=case |
| 61 | + ) |
56 | 62 | input_data = case['input'] |
57 | 63 | expected_status = case['expected']['status_code'] |
58 | 64 | expected_response = case['expected']['response'] |
59 | 65 |
|
60 | 66 | resp = self.api.post_cart( |
61 | | - cartId=input_data['cartId'], |
| 67 | + cartId=input_data['id'], |
62 | 68 | userId=input_data['userId'], |
63 | 69 | products=input_data['products'] |
64 | 70 | ) |
65 | 71 |
|
66 | | - assert resp.status_code == expected_status |
67 | 72 | assert resp.json() == expected_response |
0 commit comments