|
8 | 8 |
|
9 | 9 | def test_create_no_api_key(): |
10 | 10 | with pytest.raises(CommonbaseException): |
11 | | - Completion.create(api_key=None, project_id="") |
| 11 | + Completion.create( |
| 12 | + api_key=None, project_id=os.getenv("CB_PROJECT_ID") or "", prompt="" |
| 13 | + ) |
12 | 14 |
|
13 | 15 |
|
14 | 16 | def test_create_no_project_id(): |
15 | 17 | with pytest.raises(CommonbaseApiException): |
16 | | - Completion.create(api_key="", project_id=None) # type: ignore |
| 18 | + Completion.create(api_key=os.getenv("CB_API_KEY") or "", project_id=None, prompt="") # type: ignore |
| 19 | + |
| 20 | + |
| 21 | +def test_create_no_prompt(): |
| 22 | + with pytest.raises(CommonbaseApiException): |
| 23 | + Completion.create(api_key=os.getenv("CB_API_KEY") or "", project_id=os.getenv("CB_PROJECT_ID") or "", prompt=None) # type: ignore |
17 | 24 |
|
18 | 25 |
|
19 | 26 | def test_stream_no_api_key(): |
20 | 27 | with pytest.raises(CommonbaseException): |
21 | | - for _ in Completion.stream(api_key=None, project_id=""): |
| 28 | + for _ in Completion.stream(api_key=None, project_id=os.getenv("CB_PROJECT_ID") or "", prompt=""): # type: ignore |
22 | 29 | pass |
23 | 30 |
|
24 | 31 |
|
25 | 32 | def test_stream_no_project_id(): |
26 | 33 | with pytest.raises(CommonbaseApiException): |
27 | | - for _ in Completion.stream(api_key="", project_id=None, prompt=""): # type: ignore |
| 34 | + for _ in Completion.stream(api_key=os.getenv("CB_API_KEY") or "", project_id=None, prompt=""): # type: ignore |
| 35 | + pass |
| 36 | + |
| 37 | + |
| 38 | +def test_stream_no_prompt(): |
| 39 | + with pytest.raises(CommonbaseApiException): |
| 40 | + for _ in Completion.stream(api_key=os.getenv("CB_API_KEY") or "", project_id=os.getenv("CB_PROJECT_ID") or "", prompt=None): # type: ignore |
28 | 41 | pass |
29 | 42 |
|
30 | 43 |
|
31 | 44 | def test_create_invalid_project_id(): |
32 | 45 | with pytest.raises(CommonbaseApiException): |
33 | | - Completion.create(api_key="", project_id="", prompt="Hello") |
| 46 | + Completion.create( |
| 47 | + api_key=os.getenv("CB_API_KEY") or "", project_id="", prompt="Hello" |
| 48 | + ) |
34 | 49 |
|
35 | 50 |
|
36 | 51 | def test_stream_invalid_project_id(): |
37 | 52 | with pytest.raises(CommonbaseApiException): |
38 | | - for _ in Completion.stream(api_key="", project_id="", prompt="Hello"): |
| 53 | + for _ in Completion.stream( |
| 54 | + api_key=os.getenv("CB_API_KEY") or "", project_id="", prompt="Hello" |
| 55 | + ): |
39 | 56 | pass |
40 | 57 |
|
41 | 58 |
|
@@ -74,6 +91,7 @@ def test_completion_variables(): |
74 | 91 | result = Completion.create( |
75 | 92 | api_key=os.getenv("CB_API_KEY") or "", |
76 | 93 | project_id=os.getenv("CB_PROJECT_ID") or "", |
| 94 | + prompt="My name is {{user_name}} and my email is {{email}}", |
77 | 95 | variables={"user_name": "USERNAME", "email": "USER@COMPANY.COM"}, |
78 | 96 | ) |
79 | 97 |
|
|
0 commit comments