Пример #1
0
def test_breaking_notes_extraction(breaking_release_notes):
    e = ReleaseNoteExtractor(SUPPORTED_SECTIONS)

    sections = e.extract()

    assert sections == {
        "feat": {
            "2": {
                "description": "Detail about 2",
                "breaking": False
            },
            "3": {
                "description": "Detail about 3",
                "breaking": True
            },
        },
        "fix": {
            "1": {
                "description": "Detail about 1",
                "breaking": True
            },
            "4": {
                "description": "Detail about 4",
                "breaking": False
            },
        },
    }
Пример #2
0
def test_section_mapping_can_handle_new_sections(invalid_release_notes):
    e = ReleaseNoteExtractor({"bug": "BugFix", "feat": "Features"})

    sections = e.extract({"fix": "bug"})
    assert sections == {
        "feat": {
            "2": {
                "description": "Detail about 2",
                "breaking": False
            },
        },
        "bug": {
            "1": {
                "description": "Detail about 1",
                "breaking": False
            },
            "3": {
                "description": "Detail about 3",
                "breaking": False
            },
            "4": {
                "description": "Detail about 4",
                "breaking": False
            },
        },
    }
Пример #3
0
def test_section_remapping_can_remap_custom_sections(invalid_release_notes):
    e = ReleaseNoteExtractor(SUPPORTED_SECTIONS)

    sections = e.extract({"bug": "fix"})
    assert sections == {
        "feat": {
            "2": {
                "description": "Detail about 2",
                "breaking": False
            },
        },
        "fix": {
            "1": {
                "description": "Detail about 1",
                "breaking": False
            },
            "3": {
                "description": "Detail about 3",
                "breaking": False
            },
            "4": {
                "description": "Detail about 4",
                "breaking": False
            },
        },
    }
Пример #4
0
def test_clean_removes_all_non_dotfiles(valid_release_notes, release_notes):
    """
    Clean should not remove .gitkeep files etc
    """
    e = ReleaseNoteExtractor(SUPPORTED_SECTIONS)

    e.clean()

    assert [f.name for f in release_notes.iterdir()] == [".file"]
Пример #5
0
def test_dry_run_clean_keeps_files(valid_release_notes, release_notes):
    e = ReleaseNoteExtractor(SUPPORTED_SECTIONS, dry_run=True)

    e.clean()

    assert sorted([f.name for f in release_notes.iterdir()]) == sorted([
        "1.fix",
        "2.feat",
        "3.feat",
        "4.fix",
        ".file",
    ])
Пример #6
0
def test_init_with_release_notes_non_dir_raises(cwd):
    r = cwd / "release_notes"
    r.write_text("not a dir")

    with pytest.raises(errors.NoReleaseNotesError):
        ReleaseNoteExtractor(SUPPORTED_SECTIONS)
Пример #7
0
def test_init_with_no_release_notes_raises(cwd):
    with pytest.raises(errors.NoReleaseNotesError):
        ReleaseNoteExtractor(SUPPORTED_SECTIONS)
Пример #8
0
def test_invalid_notes_extraction_raises(invalid_release_notes):
    e = ReleaseNoteExtractor(SUPPORTED_SECTIONS)

    with pytest.raises(errors.InvalidSectionError):
        e.extract()