Exemplo n.º 1
0
def test_dump_new(tmp_path):
    """Test dump function without existing db file."""
    report_path = tmp_path / "report_db.yaml"
    dump(report_path, TerminalReporter(REPORT_DATA))

    with report_path.open() as file_:
        db = yaml.safe_load(file_)

    with (DATA_DIR / "report_db.yaml").open() as file_:
        excepted_db = yaml.safe_load(file_)

    assert db == excepted_db
Exemplo n.º 2
0
def test_dump_existing(tmp_path):
    """Test dump function with existing db file."""
    expected_path = DATA_DIR / "report_db.yaml"
    report_path = tmp_path / "report_db.yaml"
    shutil.copy(expected_path, report_path)

    # with the same test outcomes, we shall get the same db
    dump(report_path, TerminalReporter(REPORT_DATA))

    with report_path.open() as file_:
        db = yaml.safe_load(file_)

    with expected_path.open() as file_:
        excepted_db = yaml.safe_load(file_)

    assert db == excepted_db