File size: 962 Bytes
35e80ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import json

from ai_coach.cli import main

from .helpers import EXAMPLES


def test_cli_fallback_only_prints_a_note(capsys, monkeypatch, tmp_path):
    monkeypatch.setenv("COACH_CACHE_PATH", str(tmp_path / "c.sqlite3"))
    monkeypatch.setenv("COACH_LOG_DIR", str(tmp_path / "logs"))
    code = main([str(EXAMPLES / "hitting_overstride_240fps.json"), "--fallback-only"])
    out = capsys.readouterr()
    assert code == 0 and "What to work on" in out.out and "Mechanics score" in out.out and "source=rules" in out.err


def test_cli_json_output_is_valid(capsys, monkeypatch, tmp_path):
    monkeypatch.setenv("COACH_CACHE_PATH", str(tmp_path / "c.sqlite3"))
    monkeypatch.setenv("COACH_LOG_DIR", str(tmp_path / "logs"))
    main([str(EXAMPLES / "pitching_short_stride_240fps.json"), "--fallback-only", "--json"])
    data = json.loads(capsys.readouterr().out)
    assert data["meta"]["source"] == "rules" and data["focus"][0]["problem_key"] == "short_stride"