fix: add Redis installation step and improve aitbc_crypto mocking in tests
Some checks failed
Production Tests / Production Integration Tests (push) Failing after 1m16s
Python Tests / test-python (push) Failing after 3m33s

- Added Redis server installation step in production-tests.yml workflow
  - Checks if Redis binaries are already available before installing
  - Installs redis-server package if needed
- Improved aitbc_crypto mocking in conftest.py
  - Try importing real aitbc_crypto module first before mocking
  - Only mock functions if they don't already exist
  - Prevents overriding real implementations when aitbc_crypto is available
This commit is contained in:
aitbc
2026-04-19 19:49:40 +02:00
parent 625c1b7812
commit 22a2597e23
2 changed files with 22 additions and 4 deletions

View File

@@ -63,9 +63,14 @@ sys.modules['slowapi'] = Mock()
sys.modules['slowapi.util'] = Mock()
sys.modules['slowapi.limiter'] = Mock()
sys.modules['web3'] = Mock()
sys.modules['aitbc_crypto'] = Mock()
# Mock aitbc_crypto functions
try:
import aitbc_crypto as _aitbc_crypto
except ImportError:
_aitbc_crypto = Mock()
sys.modules['aitbc_crypto'] = _aitbc_crypto
def mock_encrypt_data(data, key):
return f"encrypted_{data}"
def mock_decrypt_data(data, key):
@@ -73,9 +78,12 @@ def mock_decrypt_data(data, key):
def mock_generate_viewing_key():
return "test_viewing_key"
sys.modules['aitbc_crypto'].encrypt_data = mock_encrypt_data
sys.modules['aitbc_crypto'].decrypt_data = mock_decrypt_data
sys.modules['aitbc_crypto'].generate_viewing_key = mock_generate_viewing_key
if not hasattr(_aitbc_crypto, 'encrypt_data'):
_aitbc_crypto.encrypt_data = mock_encrypt_data
if not hasattr(_aitbc_crypto, 'decrypt_data'):
_aitbc_crypto.decrypt_data = mock_decrypt_data
if not hasattr(_aitbc_crypto, 'generate_viewing_key'):
_aitbc_crypto.generate_viewing_key = mock_generate_viewing_key
# Common fixtures for all test types
@pytest.fixture