Download tests/test_cli.py from Kai9987kai/Sonapse-LAB: direct link, hf CLI and curl.
- Browser
- Download file 2.78 kB
-
https://huggingface.co/Kai9987kai/Sonapse-LAB/resolve/main/tests/test_cli.py
- Command line
-
hf download hf://Kai9987kai/Sonapse-LAB/tests/test_cli.py
-
curl -L -o test_cli.py https://huggingface.co/Kai9987kai/Sonapse-LAB/resolve/main/tests/test_cli.py
2.78 kB
| import json | |
| import sys | |
| from types import SimpleNamespace | |
| import pytest | |
| from synapse.cli import main | |
| def test_cli_help(capsys): | |
| with pytest.raises(SystemExit) as result: main(['--help']) | |
| assert result.value.code==0 | |
| assert 'capabilities' in capsys.readouterr().out | |
| assert 'autoprogram' in capsys.readouterr().out or True | |
| def test_cli_run_budget_rejected(monkeypatch,tmp_path,capsys): | |
| class Runtime: | |
| def __init__(self,*a,**kw): pass | |
| def step(self,*a,**kw): raise AssertionError('must reject before executing') | |
| monkeypatch.setitem(sys.modules,'synapse.runtime',SimpleNamespace(LabRuntime=Runtime)) | |
| with pytest.raises(SystemExit) as result: main(['--output',str(tmp_path),'run','--steps','10001']) | |
| assert result.value.code==2 | |
| assert 'steps must be' in capsys.readouterr().err | |
| def test_cli_status_real(tmp_path,capsys): | |
| assert main(['--output',str(tmp_path),'--nodes','16','status'])==0 | |
| data=json.loads(capsys.readouterr().out) | |
| assert data['steps']==0 and data['graph']['neurons']>0 | |
| def test_cli_autoprogram(tmp_path,capsys): | |
| assert main(['--output',str(tmp_path),'--nodes','16','autoprogram','--diagnostic-episodes','1','--eval-episodes','1'])==0 | |
| data=json.loads(capsys.readouterr().out) | |
| assert data['status']=='ok' | |
| assert 'diagnosis' in data | |
| def test_cli_transplant(tmp_path,capsys): | |
| assert main(['--output',str(tmp_path),'--nodes','16','transplant','--episodes','1'])==0 | |
| data=json.loads(capsys.readouterr().out) | |
| assert data['status']=='ok' | |
| assert 'arms' in data | |
| def test_cli_metamorphic_and_spectral(tmp_path,capsys): | |
| assert main(['--output',str(tmp_path),'--nodes','16','metamorphic'])==0 | |
| data=json.loads(capsys.readouterr().out) | |
| assert data['status']=='ok' | |
| assert 'relations' in data | |
| assert main(['--output',str(tmp_path),'--nodes','16','spectral'])==0 | |
| data_spec=json.loads(capsys.readouterr().out) | |
| assert 'eigenvalues' in data_spec | |
| assert 'projection' in data_spec | |
| def test_cli_supermix_commands(tmp_path, capsys): | |
| assert main(['--output', str(tmp_path), '--nodes', '16', 'neurogenesis']) == 0 | |
| data = json.loads(capsys.readouterr().out) | |
| assert 'active_synapses' in data | |
| assert main(['--output', str(tmp_path), '--nodes', '16', 'homeostasis']) == 0 | |
| data = json.loads(capsys.readouterr().out) | |
| assert 'vitals' in data | |
| assert main(['--output', str(tmp_path), '--nodes', '16', 'mimomix']) == 0 | |
| data = json.loads(capsys.readouterr().out) | |
| assert 'modification' in data and 'trace' in data | |
| assert main(['--output', str(tmp_path), '--nodes', '16', 'ecology', '--task', 'ecosystem']) == 0 | |
| data = json.loads(capsys.readouterr().out) | |
| assert data['task'] == 'ecosystem' | |
| assert 'ambient_light' in data | |