feat: migrate Mac mini services into Reyna CLI
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import XCTest
|
||||
@testable import ReynaCLIHostCore
|
||||
|
||||
final class PythonLauncherTests: XCTestCase {
|
||||
func testConfiguredRuntimeUsesEnvironmentBeforeConfigAndDefaults() throws {
|
||||
let home = URL(fileURLWithPath: "/tmp/reyna-home")
|
||||
let config = [
|
||||
"REYNA_CLI_DIR": "/config/repo",
|
||||
"REYNA_CLI_PYTHON": "/config/python",
|
||||
]
|
||||
let environment = [
|
||||
"REYNA_CLI_DIR": "/environment/repo",
|
||||
"REYNA_CLI_PYTHON": "/environment/python",
|
||||
]
|
||||
|
||||
let runtime = resolvePythonRuntime(
|
||||
homeDirectory: home,
|
||||
environment: environment,
|
||||
config: config,
|
||||
isExecutable: { path in path == "/environment/python" }
|
||||
)
|
||||
|
||||
XCTAssertEqual(runtime.workingDirectory.path, "/environment/repo")
|
||||
XCTAssertEqual(runtime.python.path, "/environment/python")
|
||||
}
|
||||
|
||||
func testConfiguredRuntimeFallsBackToSystemPythonWhenSelectedPythonMissing() throws {
|
||||
let runtime = resolvePythonRuntime(
|
||||
homeDirectory: URL(fileURLWithPath: "/tmp/reyna-home"),
|
||||
environment: [:],
|
||||
config: ["REYNA_CLI_DIR": "/config/repo", "REYNA_CLI_PYTHON": "/missing/python"],
|
||||
isExecutable: { _ in false }
|
||||
)
|
||||
|
||||
XCTAssertEqual(runtime.workingDirectory.path, "/config/repo")
|
||||
XCTAssertEqual(runtime.python.path, "/usr/bin/python3")
|
||||
}
|
||||
|
||||
func testPythonCommandRunsFixedCliModuleAndForwardsArguments() {
|
||||
let runtime = PythonRuntime(
|
||||
workingDirectory: URL(fileURLWithPath: "/repo"),
|
||||
python: URL(fileURLWithPath: "/repo/.venv/bin/python")
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
pythonCommand(runtime: runtime, forwardedArguments: ["local-services", "speech", "generate", "hello"]),
|
||||
["/repo/.venv/bin/python", "-m", "reyna_cli.cli", "local-services", "speech", "generate", "hello"]
|
||||
)
|
||||
}
|
||||
|
||||
func testPythonEnvironmentRemovesParentInterpreterOverrides() {
|
||||
let environment = pythonLaunchEnvironment(from: [
|
||||
"PATH": "/bin",
|
||||
"PYTHONHOME": "/wrong",
|
||||
"PYTHONPATH": "/wrong/site-packages",
|
||||
"VIRTUAL_ENV": "/wrong/.venv",
|
||||
"KEEP": "yes",
|
||||
])
|
||||
|
||||
XCTAssertNil(environment["PYTHONHOME"])
|
||||
XCTAssertNil(environment["PYTHONPATH"])
|
||||
XCTAssertNil(environment["VIRTUAL_ENV"])
|
||||
XCTAssertEqual(environment["PYTHONNOUSERSITE"], "1")
|
||||
XCTAssertEqual(environment["KEEP"], "yes")
|
||||
}
|
||||
|
||||
func testConfigParserIgnoresCommentsBlankLinesAndQuotes() {
|
||||
let config = parsePythonRuntimeConfig("# comment\nREYNA_CLI_DIR = '/repo path'\n\nREYNA_CLI_PYTHON=\"/python\"\ninvalid\n")
|
||||
|
||||
XCTAssertEqual(config["REYNA_CLI_DIR"], "/repo path")
|
||||
XCTAssertEqual(config["REYNA_CLI_PYTHON"], "/python")
|
||||
XCTAssertNil(config["invalid"])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user