|
| 1 | +"""Tests for memory CLI commands. |
| 2 | +
|
| 3 | +Module: cli/commands/memory.py (48 lines) |
| 4 | +""" |
| 5 | + |
| 6 | +import pytest |
| 7 | +from unittest.mock import patch |
| 8 | + |
| 9 | +from empathy_os.cli.commands.memory import ( |
| 10 | + memory_app, |
| 11 | + memory_status, |
| 12 | + memory_start, |
| 13 | + memory_stop, |
| 14 | + memory_stats, |
| 15 | + memory_patterns, |
| 16 | +) |
| 17 | + |
| 18 | + |
| 19 | +@pytest.mark.unit |
| 20 | +class TestMemoryApp: |
| 21 | + """Test suite for memory Typer app.""" |
| 22 | + |
| 23 | + def test_memory_app_exists(self): |
| 24 | + """Test that memory_app Typer instance exists.""" |
| 25 | + assert memory_app is not None |
| 26 | + |
| 27 | + |
| 28 | +@pytest.mark.unit |
| 29 | +class TestMemoryCommands: |
| 30 | + """Test suite for individual memory commands.""" |
| 31 | + |
| 32 | + @patch("subprocess.run") |
| 33 | + def test_memory_status_calls_subprocess(self, mock_run): |
| 34 | + """Test that memory_status calls subprocess.""" |
| 35 | + memory_status() |
| 36 | + |
| 37 | + mock_run.assert_called_once() |
| 38 | + args = mock_run.call_args[0][0] |
| 39 | + assert "empathy_os.memory.control_panel" in args |
| 40 | + assert "status" in args |
| 41 | + |
| 42 | + @patch("subprocess.run") |
| 43 | + def test_memory_start_calls_subprocess(self, mock_run): |
| 44 | + """Test that memory_start calls subprocess.""" |
| 45 | + memory_start() |
| 46 | + |
| 47 | + mock_run.assert_called_once() |
| 48 | + args = mock_run.call_args[0][0] |
| 49 | + assert "start" in args |
| 50 | + |
| 51 | + @patch("subprocess.run") |
| 52 | + def test_memory_stop_calls_subprocess(self, mock_run): |
| 53 | + """Test that memory_stop calls subprocess.""" |
| 54 | + memory_stop() |
| 55 | + |
| 56 | + mock_run.assert_called_once() |
| 57 | + args = mock_run.call_args[0][0] |
| 58 | + assert "stop" in args |
| 59 | + |
| 60 | + @patch("subprocess.run") |
| 61 | + def test_memory_stats_calls_subprocess(self, mock_run): |
| 62 | + """Test that memory_stats calls subprocess.""" |
| 63 | + memory_stats() |
| 64 | + |
| 65 | + mock_run.assert_called_once() |
| 66 | + args = mock_run.call_args[0][0] |
| 67 | + assert "stats" in args |
| 68 | + |
| 69 | + @patch("subprocess.run") |
| 70 | + def test_memory_patterns_calls_subprocess(self, mock_run): |
| 71 | + """Test that memory_patterns calls subprocess.""" |
| 72 | + memory_patterns() |
| 73 | + |
| 74 | + mock_run.assert_called_once() |
| 75 | + args = mock_run.call_args[0][0] |
| 76 | + assert "patterns" in args |
| 77 | + assert "--list" in args |
0 commit comments