def test_cli_instantiation(capsys): with pytest.raises(SystemExit): Warehouse.from_cli(["-h"]) out, err = capsys.readouterr() assert "usage: warehouse" in out assert not err
def test_running_cli_command(monkeypatch): commands = {"serve": pretend.call_recorder(lambda *a, **k: None)} monkeypatch.setattr(cli, "__commands__", commands) config = os.path.abspath(os.path.join(os.path.dirname(__file__), "test_config.yml")) Warehouse.from_cli(["-c", config, "serve"]) assert commands["serve"].calls == [pretend.call(mock.ANY)]
def test_running_cli_command(monkeypatch): commands = {"serve": pretend.call_recorder(lambda *a, **k: None)} monkeypatch.setattr(cli, "__commands__", commands) config = os.path.abspath(os.path.join( os.path.dirname(__file__), "test_config.yml", )) Warehouse.from_cli(["-c", config, "serve"]) assert commands["serve"].calls == [pretend.call(mock.ANY)]
def main(): return Warehouse.from_cli(sys.argv[1:])