Ejemplo n.º 1
0
def test_main_invalid_date(mocker, capsys):
    mocker.patch("sys.argv", ["aocd", "1", "2014"])
    with pytest.raises(SystemExit(2)):
        main()
    out, err = capsys.readouterr()
    msg = "aocd: error: argument year: invalid choice: 2014 (choose from 2015, 2016, 2017, 2018"
    assert msg in err
Ejemplo n.º 2
0
def test_main_valid_date_forgiving(mocker, capsys):
    mocker.patch("sys.argv", ["aocd", "2015", "8"])
    getter = mocker.patch("aocd.cli.get_data", return_value="stuff")
    main()
    out, err = capsys.readouterr()
    assert err == ""
    assert out == "stuff\n"
    getter.assert_called_once_with(year=2015, day=8)
Ejemplo n.º 3
0
def test_main_invalid_date(mocker, capsys):
    mocker.patch("sys.argv", ["aocd", "1", "2014"])
    with pytest.raises(SystemExit(1)):
        main()
    out, err = capsys.readouterr()
    assert "usage: aocd [-h] [day] [year]" in out