File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments