Skip to content

Commit 0df5e9f

Browse files
committed
Improve test coverage
1 parent 9dc2485 commit 0df5e9f

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""Unit tests for Client initialization"""
2+
import pytest
3+
from terminusdb_client.client import Client
4+
from terminusdb_client.errors import InterfaceError
5+
6+
7+
class TestClientInitialization:
8+
"""Test Client initialization and basic properties"""
9+
10+
def test_client_init_basic(self):
11+
"""Test basic Client initialization"""
12+
client = Client("http://localhost:6363")
13+
assert client.server_url == "http://localhost:6363"
14+
assert client._connected is False
15+
16+
def test_client_init_with_user_agent(self):
17+
"""Test Client initialization with custom user agent"""
18+
client = Client("http://localhost:6363", user_agent="test-agent/1.0")
19+
assert "test-agent/1.0" in client._default_headers.get("user-agent", "")
20+
21+
def test_client_init_with_trailing_slash(self):
22+
"""Test Client handles URLs with trailing slashes"""
23+
client = Client("http://localhost:6363/")
24+
# Should work without errors
25+
assert client.server_url in ["http://localhost:6363", "http://localhost:6363/"]
26+
27+
def test_client_copy(self):
28+
"""Test Client copy method creates independent instance"""
29+
client1 = Client("http://localhost:6363")
30+
client1.team = "test_team"
31+
client1.db = "test_db"
32+
33+
client2 = client1.copy()
34+
35+
assert client2.server_url == client1.server_url
36+
assert client2.team == client1.team
37+
assert client2.db == client1.db
38+
# Ensure it's a different object
39+
assert client2 is not client1
40+
41+
def test_client_copy_modifications_independent(self):
42+
"""Test modifications to copied client don't affect original"""
43+
client1 = Client("http://localhost:6363")
44+
client1.team = "team1"
45+
46+
client2 = client1.copy()
47+
client2.team = "team2"
48+
49+
assert client1.team == "team1"
50+
assert client2.team == "team2"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Unit tests for GraphType enum"""
2+
from terminusdb_client.client import GraphType
3+
4+
5+
class TestGraphType:
6+
"""Test GraphType enum values"""
7+
8+
def test_graphtype_instance(self):
9+
"""Test GraphType.INSTANCE value"""
10+
assert GraphType.INSTANCE == "instance"
11+
12+
def test_graphtype_schema(self):
13+
"""Test GraphType.SCHEMA value"""
14+
assert GraphType.SCHEMA == "schema"
15+
16+
def test_graphtype_enum_members(self):
17+
"""Test GraphType has exactly two members"""
18+
members = list(GraphType)
19+
assert len(members) == 2
20+
assert GraphType.INSTANCE in members
21+
assert GraphType.SCHEMA in members
22+
23+
def test_graphtype_values(self):
24+
"""Test all GraphType enum values exist"""
25+
assert hasattr(GraphType, 'INSTANCE')
26+
assert hasattr(GraphType, 'SCHEMA')

0 commit comments

Comments
 (0)