refactor: rename package from RNS.Interfaces to ble_reticulum
Fixes namespace collision with Reticulum's own RNS.Interfaces package. When both packages were installed, the collision caused import issues and prevented BLE discovery between devices. Changes: - Rename src/RNS/Interfaces/ to src/ble_reticulum/ - Update pyproject.toml package configuration - Update all imports in source and test files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
bbeb6c43e8
commit
2fbb9c3ad2
28 changed files with 49 additions and 49 deletions
|
|
@ -237,7 +237,7 @@ def sample_configuration():
|
|||
def sample_discovered_peers():
|
||||
"""Sample DiscoveredPeer objects for testing."""
|
||||
try:
|
||||
from RNS.Interfaces.BLEInterface import DiscoveredPeer
|
||||
from ble_reticulum.BLEInterface import DiscoveredPeer
|
||||
except ImportError:
|
||||
# Create a simple mock DiscoveredPeer for testing
|
||||
import time
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from unittest.mock import Mock, AsyncMock, patch, MagicMock
|
|||
|
||||
# Import fragmentation for testing
|
||||
try:
|
||||
from RNS.Interfaces.BLEFragmentation import BLEFragmenter, BLEReassembler
|
||||
from ble_reticulum.BLEFragmentation import BLEFragmenter, BLEReassembler
|
||||
except ImportError:
|
||||
BLEFragmenter = None
|
||||
BLEReassembler = None
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ class TestRemoveBlueZDeviceMethod:
|
|||
@pytest.mark.asyncio
|
||||
async def test_requires_dbus(self):
|
||||
"""Test that method returns False when D-Bus is not available."""
|
||||
from RNS.Interfaces import linux_bluetooth_driver
|
||||
from ble_reticulum import linux_bluetooth_driver
|
||||
|
||||
# Mock HAS_DBUS to False
|
||||
with patch.object(linux_bluetooth_driver, 'HAS_DBUS', False):
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class TestBREDRFallbackPrevention:
|
|||
This tests the pure logic of parameter building, which is fully
|
||||
unit-testable without D-Bus.
|
||||
"""
|
||||
from RNS.Interfaces import linux_bluetooth_driver
|
||||
from ble_reticulum import linux_bluetooth_driver
|
||||
|
||||
# Mock driver
|
||||
driver = Mock()
|
||||
|
|
@ -97,7 +97,7 @@ class TestBREDRFallbackPrevention:
|
|||
This test verifies that we handle the object path return value
|
||||
properly instead of ignoring it.
|
||||
"""
|
||||
from RNS.Interfaces import linux_bluetooth_driver
|
||||
from ble_reticulum import linux_bluetooth_driver
|
||||
|
||||
# Mock the D-Bus call to return an object path (what BlueZ actually returns)
|
||||
mock_object_path = "/org/bluez/hci0/dev_AA_BB_CC_DD_EE_FF"
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class TestConfigDirectoryResolution(unittest.TestCase):
|
|||
# Remove BLEInterface from sys.modules if it was imported
|
||||
modules_to_remove = [
|
||||
'BLEInterface',
|
||||
'RNS.Interfaces.BLEInterface'
|
||||
'ble_reticulum.BLEInterface'
|
||||
]
|
||||
for module in modules_to_remove:
|
||||
if module in sys.modules:
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class TestDBusDisconnectMonitoring:
|
|||
@pytest.fixture
|
||||
def mock_gatt_server(self, mock_driver):
|
||||
"""Create mock GATT server with monitoring setup."""
|
||||
from RNS.Interfaces.linux_bluetooth_driver import BluezeroGATTServer
|
||||
from ble_reticulum.linux_bluetooth_driver import BluezeroGATTServer
|
||||
|
||||
server = Mock(spec=BluezeroGATTServer)
|
||||
server.driver = mock_driver
|
||||
|
|
@ -304,7 +304,7 @@ class TestDBusDisconnectMonitoring:
|
|||
|
||||
def test_error_handling_no_dbus(self, mock_gatt_server):
|
||||
"""Test that monitoring returns early when D-Bus is not available."""
|
||||
with patch('RNS.Interfaces.linux_bluetooth_driver.HAS_DBUS', False):
|
||||
with patch('ble_reticulum.linux_bluetooth_driver.HAS_DBUS', False):
|
||||
# Simulate the early return logic
|
||||
HAS_DBUS = False
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from unittest.mock import Mock, AsyncMock, patch, MagicMock
|
|||
# conftest.py handles path setup - imports should work after that
|
||||
# Import only what we need for testing
|
||||
try:
|
||||
from RNS.Interfaces.BLEFragmentation import BLEFragmenter, BLEReassembler
|
||||
from ble_reticulum.BLEFragmentation import BLEFragmenter, BLEReassembler
|
||||
except ImportError:
|
||||
# If imports fail, tests will be skipped
|
||||
BLEFragmenter = None
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import os
|
|||
# Add parent directory to path
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../src'))
|
||||
|
||||
from RNS.Interfaces.BLEFragmentation import BLEFragmenter, BLEReassembler, HDLCFramer
|
||||
from ble_reticulum.BLEFragmentation import BLEFragmenter, BLEReassembler, HDLCFramer
|
||||
|
||||
|
||||
class TestBLEFragmenter:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import os
|
|||
# Add src to path
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
||||
|
||||
from RNS.Interfaces.BLEGATTServer import BLEGATTServer, BLESS_AVAILABLE
|
||||
from ble_reticulum.BLEGATTServer import BLEGATTServer, BLESS_AVAILABLE
|
||||
|
||||
|
||||
class MockInterface:
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class TestEventDrivenDBusMonitor:
|
|||
@pytest.fixture
|
||||
def mock_gatt_server(self, mock_driver):
|
||||
"""Create mock GATT server with event-driven monitoring setup."""
|
||||
from RNS.Interfaces.linux_bluetooth_driver import BluezeroGATTServer
|
||||
from ble_reticulum.linux_bluetooth_driver import BluezeroGATTServer
|
||||
|
||||
server = Mock(spec=BluezeroGATTServer)
|
||||
server.driver = mock_driver
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class TestComputeIdentityHash:
|
|||
# Read the actual BLEInterface.py source
|
||||
ble_interface_path = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
'../src/RNS/Interfaces/BLEInterface.py'
|
||||
'../src/ble_reticulum/BLEInterface.py'
|
||||
)
|
||||
|
||||
with open(ble_interface_path, 'r') as f:
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ def test_interface_has_gatt_integration():
|
|||
code = f.read()
|
||||
|
||||
# Check for driver-based architecture
|
||||
assert 'from RNS.Interfaces.bluetooth_driver import BLEDriverInterface' in code or 'bluetooth_driver' in code
|
||||
assert 'from ble_reticulum.bluetooth_driver import BLEDriverInterface' in code or 'bluetooth_driver' in code
|
||||
|
||||
# Check for peripheral mode configuration
|
||||
assert 'enable_peripheral' in code
|
||||
|
|
|
|||
|
|
@ -456,7 +456,7 @@ class TestRealWorldScenario:
|
|||
Verifies that cleanup is idempotent - if both mechanisms detect the same
|
||||
disconnect, cleanup should only happen once without errors.
|
||||
"""
|
||||
from RNS.Interfaces.linux_bluetooth_driver import BluezeroGATTServer
|
||||
from ble_reticulum.linux_bluetooth_driver import BluezeroGATTServer
|
||||
|
||||
# Setup GATT server with monitoring
|
||||
server = Mock(spec=BluezeroGATTServer)
|
||||
|
|
@ -502,7 +502,7 @@ class TestRealWorldScenario:
|
|||
Simulates scenario where D-Bus signal fails or is delayed, but polling
|
||||
fallback detects and triggers cleanup within 30 seconds.
|
||||
"""
|
||||
from RNS.Interfaces.linux_bluetooth_driver import BluezeroGATTServer
|
||||
from ble_reticulum.linux_bluetooth_driver import BluezeroGATTServer
|
||||
|
||||
# Setup GATT server
|
||||
server = Mock(spec=BluezeroGATTServer)
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class TestScannerConnectionCoordination:
|
|||
if scanning should be paused based on connection state.
|
||||
"""
|
||||
# Import the actual driver to test real method
|
||||
from RNS.Interfaces import linux_bluetooth_driver
|
||||
from ble_reticulum import linux_bluetooth_driver
|
||||
|
||||
# Create minimal driver instance
|
||||
driver = Mock()
|
||||
|
|
@ -103,7 +103,7 @@ class TestScannerConnectionCoordination:
|
|||
This test reproduces the core bug - scanner doesn't know to pause
|
||||
when connections are active.
|
||||
"""
|
||||
from RNS.Interfaces import linux_bluetooth_driver
|
||||
from ble_reticulum import linux_bluetooth_driver
|
||||
|
||||
driver = Mock()
|
||||
driver._connecting_peers = {"AA:BB:CC:DD:EE:FF"}
|
||||
|
|
@ -126,7 +126,7 @@ class TestScannerConnectionCoordination:
|
|||
|
||||
PASSES AFTER FIX: Method correctly handles multiple connections
|
||||
"""
|
||||
from RNS.Interfaces import linux_bluetooth_driver
|
||||
from ble_reticulum import linux_bluetooth_driver
|
||||
|
||||
driver = Mock()
|
||||
driver._connecting_peers = {
|
||||
|
|
@ -156,7 +156,7 @@ class TestScannerConnectionCoordination:
|
|||
This test verifies the coordination logic is actually used in the
|
||||
scan loop. We mock BleakScanner to avoid real Bluetooth operations.
|
||||
"""
|
||||
from RNS.Interfaces import linux_bluetooth_driver
|
||||
from ble_reticulum import linux_bluetooth_driver
|
||||
|
||||
# Create mock driver
|
||||
driver = Mock()
|
||||
|
|
@ -196,7 +196,7 @@ class TestScannerConnectionCoordination:
|
|||
|
||||
PASSES AFTER FIX: Scanner starts when _connecting_peers is empty
|
||||
"""
|
||||
from RNS.Interfaces import linux_bluetooth_driver
|
||||
from ble_reticulum import linux_bluetooth_driver
|
||||
|
||||
driver = Mock()
|
||||
driver._connecting_peers = set() # No connections
|
||||
|
|
@ -231,7 +231,7 @@ class TestScannerConnectionCoordination:
|
|||
2. Connection completes -> peer removed from _connecting_peers
|
||||
3. Next scan loop iteration -> scanner resumes
|
||||
"""
|
||||
from RNS.Interfaces import linux_bluetooth_driver
|
||||
from ble_reticulum import linux_bluetooth_driver
|
||||
|
||||
driver = Mock()
|
||||
driver._connecting_peers = {"AA:BB:CC:DD:EE:FF"}
|
||||
|
|
@ -280,7 +280,7 @@ class TestScannerConnectionCoordination:
|
|||
- It correctly identifies when to pause
|
||||
- It prevents scanner.start() calls during connections
|
||||
"""
|
||||
from RNS.Interfaces import linux_bluetooth_driver
|
||||
from ble_reticulum import linux_bluetooth_driver
|
||||
|
||||
driver = Mock()
|
||||
driver._log = Mock()
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class TestStaleConnectionPolling:
|
|||
@pytest.fixture
|
||||
def mock_gatt_server(self, mock_driver):
|
||||
"""Create mock GATT server with polling setup."""
|
||||
from RNS.Interfaces.linux_bluetooth_driver import BluezeroGATTServer
|
||||
from ble_reticulum.linux_bluetooth_driver import BluezeroGATTServer
|
||||
|
||||
server = Mock(spec=BluezeroGATTServer)
|
||||
server.driver = mock_driver
|
||||
|
|
|
|||
|
|
@ -53,11 +53,11 @@ if not hasattr(RNS, 'Identity'):
|
|||
RNS.Identity = MagicMock()
|
||||
RNS.Identity.full_hash = lambda x: (x * 2)[:16] # Simple mock
|
||||
|
||||
# Mock RNS.Interfaces.Interface (required by BLEInterface.py)
|
||||
# Mock ble_reticulum.Interface (required by BLEInterface.py)
|
||||
# First, ensure mock is in place BEFORE any imports that need it
|
||||
rns_interfaces_mock = MagicMock()
|
||||
_sys.modules['RNS.Interfaces'] = rns_interfaces_mock
|
||||
_sys.modules['RNS.Interfaces.Interface'] = MagicMock()
|
||||
_sys.modules['ble_reticulum'] = rns_interfaces_mock
|
||||
_sys.modules['ble_reticulum.Interface'] = MagicMock()
|
||||
|
||||
# Create mock Interface base class
|
||||
class MockInterface:
|
||||
|
|
@ -89,7 +89,7 @@ class MockInterface:
|
|||
return ConfigObj(configuration)
|
||||
|
||||
rns_interfaces_mock.Interface = MockInterface
|
||||
_sys.modules['RNS.Interfaces.Interface'].Interface = MockInterface
|
||||
_sys.modules['ble_reticulum.Interface'].Interface = MockInterface
|
||||
|
||||
from tests.mock_ble_driver import MockBLEDriver
|
||||
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ if not hasattr(RNS, 'Identity'):
|
|||
RNS.Identity = MagicMock()
|
||||
RNS.Identity.full_hash = lambda x: (x * 2)[:16]
|
||||
|
||||
# Mock RNS.Interfaces.Interface module (the base class module, not the whole namespace)
|
||||
# Mock ble_reticulum.Interface module (the base class module, not the whole namespace)
|
||||
# We only mock the Interface.py module, allowing BLEInterface.py to be imported from src/
|
||||
if 'RNS.Interfaces.Interface' not in _sys.modules:
|
||||
if 'ble_reticulum.Interface' not in _sys.modules:
|
||||
# Create mock Interface base class
|
||||
class MockInterface:
|
||||
MODE_FULL = 1
|
||||
|
|
@ -100,13 +100,13 @@ if 'RNS.Interfaces.Interface' not in _sys.modules:
|
|||
return bool(val) if val is not None else default
|
||||
return ConfigObj(configuration)
|
||||
|
||||
# Create a mock module for RNS.Interfaces.Interface
|
||||
# Create a mock module for ble_reticulum.Interface
|
||||
interface_module = MagicMock()
|
||||
interface_module.Interface = MockInterface
|
||||
_sys.modules['RNS.Interfaces.Interface'] = interface_module
|
||||
_sys.modules['ble_reticulum.Interface'] = interface_module
|
||||
|
||||
from tests.mock_ble_driver import MockBLEDriver
|
||||
from RNS.Interfaces.BLEInterface import BLEInterface, DiscoveredPeer
|
||||
from ble_reticulum.BLEInterface import BLEInterface, DiscoveredPeer
|
||||
import time
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -64,10 +64,10 @@ if not hasattr(RNS, 'Identity'):
|
|||
RNS.Identity = MagicMock()
|
||||
RNS.Identity.full_hash = lambda x: (x * 2)[:16]
|
||||
|
||||
# Mock RNS.Interfaces.Interface (required by BLEInterface.py)
|
||||
if 'RNS.Interfaces' not in _sys.modules:
|
||||
# Mock ble_reticulum.Interface (required by BLEInterface.py)
|
||||
if 'ble_reticulum' not in _sys.modules:
|
||||
rns_interfaces_mock = MagicMock()
|
||||
_sys.modules['RNS.Interfaces'] = rns_interfaces_mock
|
||||
_sys.modules['ble_reticulum'] = rns_interfaces_mock
|
||||
|
||||
# Create mock Interface base class
|
||||
class MockInterface:
|
||||
|
|
@ -80,7 +80,7 @@ if 'RNS.Interfaces' not in _sys.modules:
|
|||
rns_interfaces_mock.Interface = MockInterface
|
||||
|
||||
from tests.mock_ble_driver import MockBLEDriver
|
||||
from RNS.Interfaces.BLEInterface import BLEInterface, DiscoveredPeer
|
||||
from ble_reticulum.BLEInterface import BLEInterface, DiscoveredPeer
|
||||
|
||||
|
||||
class MockOwner:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue