1
+ import pytest
2
+ from core .models .models import RequestBody , ResponseModel
3
+
4
+ # Import the data models to be tested
5
+ from core .models .models import RequestBody , ResponseModel
6
+
7
+ # Test cases for RequestBody model
8
+ def test_request_body_valid_data ():
9
+ # Valid input data
10
+ text = "This is a test text."
11
+ model = "gpt-3.5-turbo"
12
+
13
+ # Create RequestBody instance
14
+ request_body = RequestBody (text = text , model = model )
15
+
16
+ # Assert that the data is correctly assigned
17
+ assert request_body .text == text
18
+ assert request_body .model == model
19
+
20
+ def test_request_body_empty_text ():
21
+ # Invalid input data with empty text
22
+ text = ""
23
+ model = "gpt-3.5-turbo"
24
+
25
+ # Attempt to create RequestBody instance
26
+ with pytest .raises (ValueError ) as excinfo :
27
+ RequestBody (text = text , model = model )
28
+
29
+ # Assert the error message
30
+ assert str (excinfo .value ) == "Text cannot be empty."
31
+
32
+ def test_request_body_invalid_model ():
33
+ # Invalid input data with an invalid model name
34
+ text = "This is a test text."
35
+ model = "invalid_model"
36
+
37
+ # Attempt to create RequestBody instance
38
+ with pytest .raises (ValueError ) as excinfo :
39
+ RequestBody (text = text , model = model )
40
+
41
+ # Assert the error message
42
+ assert str (excinfo .value ) == "Invalid model name."
43
+
44
+ # Test cases for ResponseModel model
45
+ def test_response_model_valid_data ():
46
+ # Valid response data
47
+ text = "This is a test response."
48
+
49
+ # Create ResponseModel instance
50
+ response_model = ResponseModel (text = text )
51
+
52
+ # Assert that the data is correctly assigned
53
+ assert response_model .text == text
54
+
55
+ def test_response_model_empty_text ():
56
+ # Valid response data with empty text
57
+ text = ""
58
+
59
+ # Create ResponseModel instance
60
+ response_model = ResponseModel (text = text )
61
+
62
+ # Assert that the data is correctly assigned
63
+ assert response_model .text == text
0 commit comments