def test_main_1(capsys, mocker): mocker.patch("lumapps.api.cli.parse_args", return_value=parse_args(["--user", "foo"])) main() out = capsys.readouterr().out assert "usage" in out mocker.patch("lumapps.api.utils._get_conn", return_value=_get_conn(":memory:")) mocker.patch("lumapps.api.cli.parse_args", return_value=parse_args(["-c"])) main() out = capsys.readouterr().out assert "no saved" in out mocker.patch("lumapps.api.cli.parse_args", return_value=parse_args(["--token", "foo"])) with open("tests/legacy/test_data/lumapps_discovery.json") as fh: mocker.patch( "lumapps.api.client.BaseClient.discovery_doc", new_callable=PropertyMock, return_value=load(fh), ) with raises(SystemExit): main() mocker.patch( "lumapps.api.cli.parse_args", return_value=parse_args(["--token", "foo", "user", "get"]), ) with raises(SystemExit): main()
def test_arg_parser(): with pytest.raises(SystemExit): arg_parser, args = parse_args() with pytest.raises(SystemExit): arg_parser, args = parse_args(["--user", "foo", "--email", "bar"]) arg_parser, args = parse_args(["--user", "foo"])