Skip to content

Commit f833ac0

Browse files
GeneAIclaude
authored andcommitted
fix: Skip tests when dependencies unavailable in CI
- Skip Redis tests when redis module not installed - Skip ChainExecutor tests when .empathy/wizard_chains.yaml not found - Skip encryption test when cryptography library not installed These tests require optional dependencies that may not be present in all CI environments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent cb2563a commit f833ac0

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

tests/test_intelligence_integration.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313

1414
import pytest
1515

16-
from empathy_os.memory import EdgeType, MemoryGraph
17-
from empathy_os.routing import (
16+
# Check if wizard_chains.yaml exists for chain executor tests
17+
CHAIN_CONFIG_EXISTS = Path(".empathy/wizard_chains.yaml").exists()
18+
19+
from empathy_os.memory import EdgeType, MemoryGraph # noqa: E402
20+
from empathy_os.routing import ( # noqa: E402
1821
ChainExecutor,
1922
ClassificationResult,
2023
HaikuClassifier,
@@ -202,6 +205,7 @@ def test_graph_statistics(self, temp_graph):
202205
assert stats["nodes_by_wizard"]["bug-predict"] == 1
203206

204207

208+
@pytest.mark.skipif(not CHAIN_CONFIG_EXISTS, reason=".empathy/wizard_chains.yaml not found")
205209
class TestChainExecutorIntegration:
206210
"""Integration tests for Chain Executor with routing."""
207211

tests/test_long_term.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from empathy_os.memory.long_term import (
2121
DEFAULT_CLASSIFICATION_RULES,
22+
HAS_ENCRYPTION,
2223
Classification,
2324
ClassificationRules,
2425
EncryptionManager,
@@ -360,14 +361,12 @@ def test_load_key_from_env(self):
360361
except ImportError:
361362
pytest.skip("cryptography library not installed")
362363

364+
@pytest.mark.skipif(not HAS_ENCRYPTION, reason="cryptography library not installed")
363365
def test_invalid_env_key_raises(self):
364366
"""Test invalid environment key raises ValueError."""
365-
try:
366-
with patch.dict(os.environ, {"EMPATHY_MASTER_KEY": "not-valid-base64!!!"}):
367-
with pytest.raises(ValueError):
368-
EncryptionManager()
369-
except ImportError:
370-
pytest.skip("cryptography library not installed")
367+
with patch.dict(os.environ, {"EMPATHY_MASTER_KEY": "not-valid-base64!!!"}):
368+
with pytest.raises(ValueError):
369+
EncryptionManager()
371370

372371

373372
class TestClassificationIntegration:

tests/test_redis_bootstrap.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
import subprocess
1818
from unittest.mock import Mock, patch
1919

20+
import pytest
21+
22+
# Check if redis is available
23+
try:
24+
import redis # noqa: F401
25+
26+
REDIS_AVAILABLE = True
27+
except ImportError:
28+
REDIS_AVAILABLE = False
29+
2030
from empathy_os.memory.redis_bootstrap import (
2131
RedisStartMethod,
2232
RedisStatus,
@@ -69,6 +79,7 @@ def test_redis_status_defaults(self):
6979
assert status.pid is None
7080

7181

82+
@pytest.mark.skipif(not REDIS_AVAILABLE, reason="redis package not installed")
7283
class TestCheckRedisRunning:
7384
"""Test _check_redis_running function"""
7485

tests/test_smart_router.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
Licensed under Fair Source 0.9
66
"""
77

8-
from empathy_os.routing import (
8+
from pathlib import Path
9+
10+
import pytest
11+
12+
# Check if wizard_chains.yaml exists for chain executor tests
13+
CHAIN_CONFIG_EXISTS = Path(".empathy/wizard_chains.yaml").exists()
14+
15+
from empathy_os.routing import ( # noqa: E402
916
ChainExecutor,
1017
HaikuClassifier,
1118
RoutingDecision,
@@ -230,6 +237,7 @@ def test_routing_decision_structure(self):
230237
assert hasattr(decision, "context")
231238

232239

240+
@pytest.mark.skipif(not CHAIN_CONFIG_EXISTS, reason=".empathy/wizard_chains.yaml not found")
233241
class TestChainExecutor:
234242
"""Tests for ChainExecutor."""
235243

0 commit comments

Comments
 (0)