mirror of
https://github.com/Monadical-SAS/cubbi.git
synced 2025-12-20 12:19:07 +00:00
refactor: rename project to cubbi
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Common test fixtures for Monadical Container tests.
|
||||
Common test fixtures for Cubbi Container tests.
|
||||
"""
|
||||
|
||||
import uuid
|
||||
@@ -9,11 +9,11 @@ import docker
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from mcontainer.container import ContainerManager
|
||||
from mcontainer.session import SessionManager
|
||||
from mcontainer.config import ConfigManager
|
||||
from mcontainer.models import Session, SessionStatus
|
||||
from mcontainer.user_config import UserConfigManager
|
||||
from cubbi.container import ContainerManager
|
||||
from cubbi.session import SessionManager
|
||||
from cubbi.config import ConfigManager
|
||||
from cubbi.models import Session, SessionStatus
|
||||
from cubbi.user_config import UserConfigManager
|
||||
|
||||
|
||||
# Check if Docker is available
|
||||
@@ -81,7 +81,7 @@ def isolated_config_manager():
|
||||
@pytest.fixture
|
||||
def mock_session_manager():
|
||||
"""Mock the SessionManager class."""
|
||||
with patch("mcontainer.cli.session_manager") as mock_manager:
|
||||
with patch("cubbi.cli.session_manager") as mock_manager:
|
||||
yield mock_manager
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ def mock_container_manager():
|
||||
ports={"8080": "8080"},
|
||||
)
|
||||
|
||||
with patch("mcontainer.cli.container_manager") as mock_manager:
|
||||
with patch("cubbi.cli.container_manager") as mock_manager:
|
||||
# Set behaviors to avoid TypeErrors
|
||||
mock_manager.list_sessions.return_value = []
|
||||
mock_manager.create_session.return_value = mock_session
|
||||
@@ -149,7 +149,7 @@ def test_file_content(temp_dir):
|
||||
@pytest.fixture
|
||||
def test_network_name():
|
||||
"""Generate a unique network name for testing."""
|
||||
return f"mc-test-network-{uuid.uuid4().hex[:8]}"
|
||||
return f"cubbi-test-network-{uuid.uuid4().hex[:8]}"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -175,5 +175,5 @@ def docker_test_network(test_network_name):
|
||||
@pytest.fixture
|
||||
def patched_config_manager(isolated_config):
|
||||
"""Patch the UserConfigManager in cli.py to use our isolated instance."""
|
||||
with patch("mcontainer.cli.user_config", isolated_config):
|
||||
with patch("cubbi.cli.user_config", isolated_config):
|
||||
yield isolated_config
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from mcontainer.cli import app
|
||||
from cubbi.cli import app
|
||||
|
||||
runner = CliRunner()
|
||||
|
||||
@@ -9,7 +9,7 @@ def test_version() -> None:
|
||||
"""Test version command"""
|
||||
result = runner.invoke(app, ["version"])
|
||||
assert result.exit_code == 0
|
||||
assert "MC - Monadical Container Tool" in result.stdout
|
||||
assert "Cubbi - Cubbi Container Tool" in result.stdout
|
||||
|
||||
|
||||
def test_session_list() -> None:
|
||||
@@ -25,4 +25,4 @@ def test_help() -> None:
|
||||
result = runner.invoke(app, ["--help"])
|
||||
assert result.exit_code == 0
|
||||
assert "Usage" in result.stdout
|
||||
assert "Monadical Container Tool" in result.stdout
|
||||
assert "Cubbi Container Tool" in result.stdout
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
Tests for the configuration management commands.
|
||||
"""
|
||||
|
||||
from mcontainer.cli import app
|
||||
from cubbi.cli import app
|
||||
|
||||
|
||||
def test_config_list(cli_runner, patched_config_manager):
|
||||
"""Test the 'mc config list' command."""
|
||||
"""Test the 'cubbi config list' command."""
|
||||
result = cli_runner.invoke(app, ["config", "list"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
@@ -20,7 +20,7 @@ def test_config_list(cli_runner, patched_config_manager):
|
||||
|
||||
|
||||
def test_config_get(cli_runner, patched_config_manager):
|
||||
"""Test the 'mc config get' command."""
|
||||
"""Test the 'cubbi config get' command."""
|
||||
# Test getting an existing value
|
||||
result = cli_runner.invoke(app, ["config", "get", "defaults.image"])
|
||||
|
||||
@@ -36,7 +36,7 @@ def test_config_get(cli_runner, patched_config_manager):
|
||||
|
||||
|
||||
def test_config_set(cli_runner, patched_config_manager):
|
||||
"""Test the 'mc config set' command."""
|
||||
"""Test the 'cubbi config set' command."""
|
||||
# Test setting a string value
|
||||
result = cli_runner.invoke(app, ["config", "set", "defaults.image", "claude"])
|
||||
|
||||
@@ -60,7 +60,7 @@ def test_config_set(cli_runner, patched_config_manager):
|
||||
|
||||
|
||||
def test_volume_list_empty(cli_runner, patched_config_manager):
|
||||
"""Test the 'mc config volume list' command with no volumes."""
|
||||
"""Test the 'cubbi config volume list' command with no volumes."""
|
||||
result = cli_runner.invoke(app, ["config", "volume", "list"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
@@ -133,7 +133,7 @@ def test_volume_add_nonexistent_path(cli_runner, patched_config_manager, monkeyp
|
||||
|
||||
|
||||
def test_network_list_empty(cli_runner, patched_config_manager):
|
||||
"""Test the 'mc config network list' command with no networks."""
|
||||
"""Test the 'cubbi config network list' command with no networks."""
|
||||
result = cli_runner.invoke(app, ["config", "network", "list"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Integration tests for Docker interactions in Monadical Container.
|
||||
Integration tests for Docker interactions in Cubbi Container.
|
||||
These tests require Docker to be running.
|
||||
"""
|
||||
|
||||
@@ -31,7 +31,7 @@ def test_integration_session_create_with_volumes(container_manager, test_file_co
|
||||
# Create a session with a volume mount
|
||||
session = container_manager.create_session(
|
||||
image_name="goose",
|
||||
session_name=f"mc-test-volume-{uuid.uuid4().hex[:8]}",
|
||||
session_name=f"cubbi-test-volume-{uuid.uuid4().hex[:8]}",
|
||||
mount_local=False, # Don't mount current directory
|
||||
volumes={str(test_file): {"bind": "/test/volume_test.txt", "mode": "ro"}},
|
||||
)
|
||||
@@ -66,7 +66,7 @@ def test_integration_session_create_with_networks(
|
||||
# Create a session with the test network
|
||||
session = container_manager.create_session(
|
||||
image_name="goose",
|
||||
session_name=f"mc-test-network-{uuid.uuid4().hex[:8]}",
|
||||
session_name=f"cubbi-test-network-{uuid.uuid4().hex[:8]}",
|
||||
mount_local=False, # Don't mount current directory
|
||||
networks=[docker_test_network],
|
||||
)
|
||||
@@ -85,7 +85,7 @@ def test_integration_session_create_with_networks(
|
||||
container = client.containers.get(session.container_id)
|
||||
container_networks = container.attrs["NetworkSettings"]["Networks"]
|
||||
|
||||
# Container should be connected to both the default mc-network and our test network
|
||||
# Container should be connected to both the default cubbi-network and our test network
|
||||
assert docker_test_network in container_networks
|
||||
|
||||
# Verify network interface exists in container
|
||||
@@ -93,7 +93,7 @@ def test_integration_session_create_with_networks(
|
||||
session.container_id, "ip link show | grep -v 'lo' | wc -l"
|
||||
)
|
||||
|
||||
# Should have at least 2 interfaces (eth0 for mc-network, eth1 for test network)
|
||||
# Should have at least 2 interfaces (eth0 for cubbi-network, eth1 for test network)
|
||||
assert int(network_interfaces) >= 2
|
||||
|
||||
finally:
|
||||
|
||||
@@ -4,15 +4,15 @@ Tests for the MCP server management commands.
|
||||
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
from mcontainer.cli import app
|
||||
from cubbi.cli import app
|
||||
|
||||
|
||||
def test_mcp_list_empty(cli_runner, patched_config_manager):
|
||||
"""Test the 'mc mcp list' command with no MCPs configured."""
|
||||
"""Test the 'cubbi mcp list' command with no MCPs configured."""
|
||||
# Make sure mcps is empty
|
||||
patched_config_manager.set("mcps", [])
|
||||
|
||||
with patch("mcontainer.cli.mcp_manager.list_mcps") as mock_list_mcps:
|
||||
with patch("cubbi.cli.mcp_manager.list_mcps") as mock_list_mcps:
|
||||
mock_list_mcps.return_value = []
|
||||
|
||||
result = cli_runner.invoke(app, ["mcp", "list"])
|
||||
@@ -94,7 +94,7 @@ def test_mcp_remove(cli_runner, patched_config_manager):
|
||||
)
|
||||
|
||||
# Mock the get_mcp and remove_mcp methods
|
||||
with patch("mcontainer.cli.mcp_manager.get_mcp") as mock_get_mcp:
|
||||
with patch("cubbi.cli.mcp_manager.get_mcp") as mock_get_mcp:
|
||||
# First make get_mcp return our MCP
|
||||
mock_get_mcp.return_value = {
|
||||
"name": "test-mcp",
|
||||
@@ -128,7 +128,7 @@ def test_mcp_status(cli_runner, patched_config_manager, mock_container_manager):
|
||||
)
|
||||
|
||||
# First mock get_mcp to return our MCP config
|
||||
with patch("mcontainer.cli.mcp_manager.get_mcp") as mock_get_mcp:
|
||||
with patch("cubbi.cli.mcp_manager.get_mcp") as mock_get_mcp:
|
||||
mock_get_mcp.return_value = {
|
||||
"name": "test-docker-mcp",
|
||||
"type": "docker",
|
||||
@@ -138,7 +138,7 @@ def test_mcp_status(cli_runner, patched_config_manager, mock_container_manager):
|
||||
}
|
||||
|
||||
# Then mock the get_mcp_status method
|
||||
with patch("mcontainer.cli.mcp_manager.get_mcp_status") as mock_get_status:
|
||||
with patch("cubbi.cli.mcp_manager.get_mcp_status") as mock_get_status:
|
||||
mock_get_status.return_value = {
|
||||
"status": "running",
|
||||
"container_id": "test-container-id",
|
||||
@@ -262,7 +262,7 @@ def test_mcp_logs(cli_runner, patched_config_manager, mock_container_manager):
|
||||
)
|
||||
|
||||
# Mock the logs operation
|
||||
with patch("mcontainer.cli.mcp_manager.get_mcp_logs") as mock_get_logs:
|
||||
with patch("cubbi.cli.mcp_manager.get_mcp_logs") as mock_get_logs:
|
||||
mock_get_logs.return_value = "Test log output"
|
||||
|
||||
# View MCP logs
|
||||
@@ -288,7 +288,7 @@ def test_session_with_mcp(cli_runner, patched_config_manager, mock_container_man
|
||||
)
|
||||
|
||||
# Mock the session creation with MCP
|
||||
from mcontainer.models import Session, SessionStatus
|
||||
from cubbi.models import Session, SessionStatus
|
||||
|
||||
# timestamp no longer needed since we don't use created_at in Session
|
||||
mock_container_manager.create_session.return_value = Session(
|
||||
|
||||
@@ -6,7 +6,7 @@ import time
|
||||
import uuid
|
||||
|
||||
from conftest import requires_docker
|
||||
from mcontainer.mcp import MCPManager
|
||||
from cubbi.mcp import MCPManager
|
||||
|
||||
|
||||
@requires_docker
|
||||
|
||||
@@ -5,11 +5,11 @@ Tests for the session management commands.
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
from mcontainer.cli import app
|
||||
from cubbi.cli import app
|
||||
|
||||
|
||||
def test_session_list_empty(cli_runner, mock_container_manager):
|
||||
"""Test 'mc session list' with no active sessions."""
|
||||
"""Test 'cubbi session list' with no active sessions."""
|
||||
mock_container_manager.list_sessions.return_value = []
|
||||
|
||||
result = cli_runner.invoke(app, ["session", "list"])
|
||||
@@ -19,9 +19,9 @@ def test_session_list_empty(cli_runner, mock_container_manager):
|
||||
|
||||
|
||||
def test_session_list_with_sessions(cli_runner, mock_container_manager):
|
||||
"""Test 'mc session list' with active sessions."""
|
||||
"""Test 'cubbi session list' with active sessions."""
|
||||
# Create a mock session and set list_sessions to return it
|
||||
from mcontainer.models import Session, SessionStatus
|
||||
from cubbi.models import Session, SessionStatus
|
||||
|
||||
mock_session = Session(
|
||||
id="test-session-id",
|
||||
@@ -40,9 +40,9 @@ def test_session_list_with_sessions(cli_runner, mock_container_manager):
|
||||
|
||||
|
||||
def test_session_create_basic(cli_runner, mock_container_manager):
|
||||
"""Test 'mc session create' with basic options."""
|
||||
"""Test 'cubbi session create' with basic options."""
|
||||
# We need to patch user_config.get with a side_effect to handle different keys
|
||||
with patch("mcontainer.cli.user_config") as mock_user_config:
|
||||
with patch("cubbi.cli.user_config") as mock_user_config:
|
||||
# Handle different key requests appropriately
|
||||
def mock_get_side_effect(key, default=None):
|
||||
if key == "defaults.image":
|
||||
@@ -76,7 +76,7 @@ def test_session_create_basic(cli_runner, mock_container_manager):
|
||||
|
||||
|
||||
def test_session_close(cli_runner, mock_container_manager):
|
||||
"""Test 'mc session close' command."""
|
||||
"""Test 'cubbi session close' command."""
|
||||
mock_container_manager.close_session.return_value = True
|
||||
|
||||
result = cli_runner.invoke(app, ["session", "close", "test-session-id"])
|
||||
@@ -87,9 +87,9 @@ def test_session_close(cli_runner, mock_container_manager):
|
||||
|
||||
|
||||
def test_session_close_all(cli_runner, mock_container_manager):
|
||||
"""Test 'mc session close --all' command."""
|
||||
"""Test 'cubbi session close --all' command."""
|
||||
# Set up mock sessions
|
||||
from mcontainer.models import Session, SessionStatus
|
||||
from cubbi.models import Session, SessionStatus
|
||||
|
||||
# timestamp no longer needed since we don't use created_at in Session
|
||||
mock_sessions = [
|
||||
|
||||
Reference in New Issue
Block a user