示例#1
0
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:]
示例#2
0
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
示例#3
0
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 != ""
示例#4
0
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
示例#5
0
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)
示例#6
0
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
示例#7
0
"""Main module to run CLI commands"""
from pesel.main import cli

cli()
示例#8
0
def test_cli_pesel_generate(monkeypatch, capsys, mock):
    monkeypatch.setattr("sys.argv", ["pesel", "generate"])
    cli()
    out, _ = capsys.readouterr()
    assert len(out.strip()) == 11
示例#9
0
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"