mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 17:47:06 +08:00
- Added Peer class for managing peer-to-peer communication, including initialization, invocation, and cancellation of requests. - Introduced Transport abstract base class with StdioTransport and WebSocketTransport implementations for message handling. - Created Star class for error handling in event-driven architecture. - Developed MemoryTransport for testing purposes, allowing in-memory communication between peers. - Implemented unit tests for Peer functionality, protocol message parsing, and runtime integration with plugins. - Established entry point tests to ensure package import and command-line interface functionality.
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
import unittest
|
|
|
|
|
|
class EntryPointTest(unittest.TestCase):
|
|
def test_import_package(self) -> None:
|
|
process = subprocess.run(
|
|
[sys.executable, "-c", "import astrbot_sdk; print(astrbot_sdk.__name__)"],
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
self.assertEqual(process.returncode, 0, process.stderr)
|
|
self.assertIn("astrbot_sdk", process.stdout)
|
|
|
|
def test_module_help(self) -> None:
|
|
process = subprocess.run(
|
|
[sys.executable, "-m", "astrbot_sdk", "--help"],
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
self.assertEqual(process.returncode, 0, process.stderr)
|
|
self.assertIn("Usage", process.stdout)
|
|
|
|
def test_run_help(self) -> None:
|
|
process = subprocess.run(
|
|
[sys.executable, "-m", "astrbot_sdk", "run", "--help"],
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
self.assertEqual(process.returncode, 0, process.stderr)
|
|
self.assertIn("--plugins-dir", process.stdout)
|