Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

An open-source framework for building general AI agents

[![codecov](https://codecov.io/gh/LearnHD/OpenManus/branch/main/graph/badge.svg)](https://codecov.io/gh/LearnHD/OpenManus)

## Features

- Modular architecture for easy extension
- Built-in tools for file, web, GitHub, code, and system operations
- FastAPI backend with React frontend
- Comprehensive test suite
- CI/CD pipeline with GitHub Actions
- Code coverage tracking with Codecov

## Installation

Expand Down
48 changes: 48 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import pytest
from unittest.mock import patch, MagicMock
import sys
import os
import signal
from main import start_backend, start_frontend, stop_servers, cleanup, signal_handler

def test_start_backend():
with patch('subprocess.Popen') as mock_popen:
mock_process = MagicMock()
mock_popen.return_value = mock_process

assert start_backend() == True
mock_popen.assert_called_once()

def test_start_frontend():
with patch('subprocess.Popen') as mock_popen, \
patch('os.chdir') as mock_chdir:
mock_process = MagicMock()
mock_popen.return_value = mock_process

assert start_frontend() == True
mock_popen.assert_called_once()
assert mock_chdir.call_count == 2

def test_stop_servers():
with patch('main.cleanup') as mock_cleanup:
assert stop_servers() == True
mock_cleanup.assert_called_once()

def test_cleanup():
with patch('main.backend_process') as mock_backend, \
patch('main.frontend_process') as mock_frontend:
mock_backend.terminate = MagicMock()
mock_frontend.terminate = MagicMock()

cleanup()

mock_backend.terminate.assert_called_once()
mock_frontend.terminate.assert_called_once()

def test_signal_handler():
with patch('main.cleanup') as mock_cleanup, \
patch('sys.exit') as mock_exit:
signal_handler(signal.SIGTERM, None)

mock_cleanup.assert_called_once()
mock_exit.assert_called_once_with(0)
Loading