mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-03 06:51:00 +02:00
Squashed 'ai-context/trustgraph-templates/' content from commit 42a5fd1b
git-subtree-dir: ai-context/trustgraph-templates git-subtree-split: 42a5fd1b678f32be378062e30451e2052ccb95dd
This commit is contained in:
commit
74cc8a4685
1216 changed files with 116347 additions and 0 deletions
62
tests/unit/test_run.py
Normal file
62
tests/unit/test_run.py
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
"""
|
||||
Unit tests for run module (CLI entry point).
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestRun:
|
||||
"""Tests for the run module."""
|
||||
|
||||
def test_run_without_args_fails(self, run_configurator):
|
||||
"""Test that running without required args fails."""
|
||||
stdout, stderr, code = run_configurator([])
|
||||
assert code != 0
|
||||
|
||||
def test_run_with_help_succeeds(self, run_configurator):
|
||||
"""Test that help flag works."""
|
||||
stdout, stderr, code = run_configurator(['-h'])
|
||||
assert code == 0
|
||||
|
||||
def test_run_with_invalid_platform_fails(self, run_configurator, test_config_dir, primary_version):
|
||||
"""Test that invalid platform fails during resource generation."""
|
||||
config_file = str(test_config_dir / "minimal.json")
|
||||
stdout, stderr, code = run_configurator([
|
||||
'-t', primary_version,
|
||||
'-p', 'invalid-platform',
|
||||
'-i', config_file,
|
||||
'--latest-stable',
|
||||
'-R' # Use -R to trigger platform-specific generation
|
||||
])
|
||||
assert code == 1
|
||||
|
||||
def test_run_with_nonexistent_config_fails(self, run_configurator, primary_version):
|
||||
"""Test that nonexistent config file fails."""
|
||||
stdout, stderr, code = run_configurator([
|
||||
'-t', primary_version,
|
||||
'-p', 'docker-compose',
|
||||
'-i', '/nonexistent/config.json',
|
||||
'--latest-stable',
|
||||
'-O'
|
||||
])
|
||||
assert code == 1
|
||||
|
||||
def test_exit_code_propagates(self, monkeypatch):
|
||||
"""Test that exit codes are properly set."""
|
||||
from trustgraph_configurator import run
|
||||
|
||||
# Test successful exit (no exception)
|
||||
# This would require a valid config, so we'll just test the error path
|
||||
|
||||
# Test error exit
|
||||
monkeypatch.setattr(sys, 'argv', [
|
||||
'tg-build-deployment',
|
||||
'-i', '/nonexistent/config.json'
|
||||
])
|
||||
|
||||
with pytest.raises(SystemExit) as exc_info:
|
||||
run() # run is already the function
|
||||
|
||||
assert exc_info.value.code == 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue