def test_cli_pesel_generate_year(monkeypatch, capsys, year): monkeypatch.setattr("sys.argv", ["pesel", "generate", "--year", str(year)]) cli() out, _ = capsys.readouterr() with pytest.assume: assert len(out.strip()) == 11 assert out[:2] == str(year)[2:]
def test_cli_pesel_generate_day(monkeypatch, capsys, day): monkeypatch.setattr("sys.argv", ["pesel", "generate", "--day", str(day)]) cli() out, _ = capsys.readouterr() with pytest.assume: assert len(out.strip()) == 11 assert int(out[4:6]) == day
def test_cli_pesel_generate_incorrect_month(monkeypatch, capsys, month): monkeypatch.setattr("sys.argv", ["pesel", "generate", "--month", str(month)]) with pytest.raises(SystemExit): cli() _, err = capsys.readouterr() assert err != ""
def test_cli_pesel_generate_month(monkeypatch, capsys, month): monkeypatch.setattr("sys.argv", ["pesel", "generate", "--month", str(month)]) cli() out, _ = capsys.readouterr() with pytest.assume: assert len(out.strip()) == 11 assert int(out[2:4]) % 20 == month
def test_cli_pesel_generate_male(monkeypatch, capsys, male): monkeypatch.setattr( "sys.argv", ["pesel", "generate", "--{}male".format("" if male else "fe")]) cli() out, _ = capsys.readouterr() with pytest.assume: assert len(out.strip()) == 11 assert int(out[-3]) % 2 == int(male)
def test_cli_pesel_generate_year_month_day(monkeypatch, capsys, year, month, day): monkeypatch.setattr("sys.argv", [ "pesel", "generate", "--year", str(year), "--month", str(month), "--day", str(day) ]) cli() out, _ = capsys.readouterr() with pytest.assume: assert len(out.strip()) == 11 assert out[:2] == str(year)[2:] assert int(out[2:4]) % 20 == month assert int(out[4:6]) == day
"""Main module to run CLI commands""" from pesel.main import cli cli()
def test_cli_pesel_generate(monkeypatch, capsys, mock): monkeypatch.setattr("sys.argv", ["pesel", "generate"]) cli() out, _ = capsys.readouterr() assert len(out.strip()) == 11
def test_cli_pesel_validate_incorrect_pesel(monkeypatch, capsys, pesel): monkeypatch.setattr("sys.argv", ["pesel", "validate", pesel]) cli() out, _ = capsys.readouterr() with pytest.assume: assert out.strip() == "False"