Skip to content

Commit ff39976

Browse files
test: fill SDK gaps — workers resource, executions resource, update method
test: add client init and error handling tests
2 parents 574c2ea + ac84dfa commit ff39976

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/test_client_init.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""Tests for CueAPI client initialization and error handling."""
2+
3+
import pytest
4+
5+
from cueapi import CueAPI
6+
from cueapi.exceptions import AuthenticationError
7+
8+
9+
class TestClientInit:
10+
def test_client_has_cues_resource(self):
11+
"""Client should have a cues attribute."""
12+
client = CueAPI("test-key", base_url="https://example.com")
13+
assert hasattr(client, "cues")
14+
assert hasattr(client, "executions")
15+
client.close()
16+
17+
def test_client_accepts_base_url(self):
18+
"""Client should accept a custom base_url."""
19+
client = CueAPI("test-key", base_url="https://custom.example.com")
20+
assert client._base_url == "https://custom.example.com"
21+
client.close()
22+
23+
def test_client_close_is_idempotent(self):
24+
"""Calling close() multiple times should not raise."""
25+
client = CueAPI("test-key", base_url="https://example.com")
26+
client.close()
27+
client.close() # Should not raise
28+
29+
30+
class TestClientErrors:
31+
def test_invalid_api_key_raises_auth_error(self):
32+
"""Using an invalid API key should raise AuthenticationError."""
33+
client = CueAPI("invalid-key-that-does-not-exist", base_url="https://api-staging-e962.up.railway.app")
34+
with pytest.raises((AuthenticationError, Exception)):
35+
client.cues.list()
36+
client.close()

0 commit comments

Comments
 (0)