Skip to content

Tests🔗

berhoel.ctitools.tests.test_ctitools 🔗

Tests for ctitools.

Classes🔗

berhoel.ctitools.tests.test_processing 🔗

Test article entry processing.

Functions:

Classes🔗

Functions🔗

berhoel.ctitools.tests.test_processing.cti_entry 🔗

cti_entry(request: SubRequest) -> str

Return filename for test file.

Parameters:

  • request 🔗
    (SubRequest) –

    testfile request

Returns:

  • str –

    file name

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.fixture
def cti_entry(request: _pytest.fixtures.SubRequest) -> str:
    """Return filename for test file.

    Args:
        request: testfile request

    Returns:
        file name
    """
    return request.getfixturevalue(request.param)

berhoel.ctitools.tests.test_processing.cti_entry_1 🔗

cti_entry_1(tmp_path: Path, cti_entry_data_1: Buffer) -> Path

Return path to sample CTI file.

Parameters:

  • tmp_path 🔗
    (Path) –

    directory for temporary files

  • cti_entry_data_1 🔗
    (Buffer) –

    content for sample file

Returns:

  • Path –

    path to sample CTI file

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.fixture
def cti_entry_1(tmp_path: Path, cti_entry_data_1: Buffer) -> Path:
    """Return path to sample CTI file.

    Args:
       tmp_path: directory for temporary files
       cti_entry_data_1: content for sample file

    Returns:
       path to sample CTI file
    """
    p = tmp_path / "cti_entry_1.cti"
    p.write_bytes(cti_entry_data_1)
    return p

berhoel.ctitools.tests.test_processing.cti_entry_2 🔗

cti_entry_2(tmp_path: Path, cti_entry_data_2: Buffer) -> Path

Provide sample data file.

Parameters:

  • tmp_path 🔗
    (Path) –

    temporary path for storing files

  • cti_entry_data_2 🔗
    (Buffer) –

    content for sample file

Returns:

  • Path –

    path to sample file

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.fixture
def cti_entry_2(tmp_path: Path, cti_entry_data_2: Buffer) -> Path:
    """Provide sample data file.

    Args:
        tmp_path: temporary path for storing files
        cti_entry_data_2: content for sample file

    Returns:
        path to sample file
    """
    p = tmp_path / "cti_entry_2.cti"
    p.write_bytes(cti_entry_data_2)
    return p

berhoel.ctitools.tests.test_processing.cti_entry_3 🔗

cti_entry_3(tmp_path: Path, cti_entry_data_3: Buffer) -> Path

Provide cti entries.

Parameters:

  • tmp_path 🔗
    (Path) –

    temporary path for storing files

  • cti_entry_data_3 🔗
    (Buffer) –

    content for sample file

Returns:

  • Path –

    path to sample file

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.fixture
def cti_entry_3(tmp_path: Path, cti_entry_data_3: Buffer) -> Path:
    """Provide cti entries.

    Args:
        tmp_path: temporary path for storing files
        cti_entry_data_3: content for sample file

    Returns:
        path to sample file
    """
    p = tmp_path / "cti_entry_3.cti"
    p.write_bytes(cti_entry_data_3)
    return p

berhoel.ctitools.tests.test_processing.cti_entry_4 🔗

cti_entry_4(tmp_path: Path, cti_entry_data_4: Buffer) -> Path

Return path to sample CTI file.

Parameters:

  • tmp_path 🔗
    (Path) –

    directory for temporary files

  • cti_entry_data_4 🔗
    (Buffer) –

    content for sample file

Returns:

  • Path –

    path to sample CTI file

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.fixture
def cti_entry_4(tmp_path: Path, cti_entry_data_4: Buffer) -> Path:
    """Return path to sample CTI file.

    Args:
        tmp_path: directory for temporary files
        cti_entry_data_4: content for sample file

    Returns:
         path to sample CTI file
    """
    p = tmp_path / "cti_entry_4.cti"
    p.write_bytes(cti_entry_data_4)
    return p

berhoel.ctitools.tests.test_processing.cti_entry_data_1 🔗

cti_entry_data_1() -> bytes

Return content for sample CTI file.

Returns:

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.fixture
def cti_entry_data_1() -> bytes:
    """Return content for sample CTI file.

    Returns:
        sample data
    """
    return b"""Java nur mit -server-Option

Dr. Volker Zota, Dusan Wasserb\xc7\xcfch
vza
154
10
c07

Praxis,Hotline,Java, Server, Internet, Programmierung, JAR-Archiv
Ein Artikel

Von Torsten T. Will und Ein Autor, Duzan Zivadinovic
ola
 74
 3
c08

kurz vorgestellt,Code Review, Open Source, Entwicklungssystem,Entwicklungs-Tools,Open-Source-Projekt Review Board
"""  # noqa: E501

berhoel.ctitools.tests.test_processing.cti_entry_data_2 🔗

cti_entry_data_2() -> bytes

Return test entry.

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.fixture
def cti_entry_data_2() -> bytes:
    """Return test entry."""
    return b"""Doppelt gemoppelt
\334\344\374\366\337\351
Von Torsten T. Will und Ein Autor, Duzan Zivadinovic
ola
 74
 3
c08

kurz vorgestellt,Code Review, Open Source, Entwicklungssystem,Entwicklungs-Tools,Open-Source-Projekt Review Board
"""  # noqa: E501

berhoel.ctitools.tests.test_processing.cti_entry_data_3 🔗

cti_entry_data_3() -> bytes

Provide sampe cti entries.

Returns:

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.fixture
def cti_entry_data_3() -> bytes:
    """Provide sampe cti entries.

    Returns:
        sample data
    """
    return b"""Familienleben
Digitals Alpha-Linie: Vorstellung von f\201nf 64-Bit-Rechnern in London
Behme, Henning
hb
 13
 1
i93

Markt + Trends
Schlu\341folgerungsmuster
Objektorientierte Verkn\201pfung von Wissensbasen und Datenbanken
Higa, Kunihiko/Morrison, Joline+Mike
hb
132
 1
i93

Wissen
"""

berhoel.ctitools.tests.test_processing.cti_entry_zip_1 🔗

cti_entry_zip_1(tmp_path: Path, cti_entry_data_1: str) -> Path

Return path to zipped sample CTI file.

Parameters:

  • tmp_path 🔗
    (Path) –

    directory for temporary files

  • cti_entry_data_1 🔗
    (str) –

    content for sample file

Returns:

  • Path –

    path to sample CTI file

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.fixture
def cti_entry_zip_1(tmp_path: Path, cti_entry_data_1: str) -> Path:
    """Return path to zipped sample CTI file.

    Args:
        tmp_path: directory for temporary files
        cti_entry_data_1: content for sample file

    Returns:
        path to sample CTI file
    """
    p = tmp_path / "cti_entry_1.zip"
    with zipfile.ZipFile(p, "w") as myzip:
        myzip.writestr("cti_entry_1.frm", cti_entry_data_1)
    return p

berhoel.ctitools.tests.test_processing.cti_entry_zip_2 🔗

cti_entry_zip_2(tmp_path: Path, cti_entry_data_2: str) -> Path

Provide zipped sample CTI files.

Parameters:

  • tmp_path 🔗
    (Path) –

    temporary path for storing files

  • cti_entry_data_2 🔗
    (str) –

    content for sample file

Returns:

  • Path –

    path to zipped data file

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.fixture
def cti_entry_zip_2(tmp_path: Path, cti_entry_data_2: str) -> Path:
    """Provide zipped sample CTI files.

    Args:
        tmp_path: temporary path for storing files
        cti_entry_data_2: content for sample file

    Returns:
        path to zipped data file
    """
    p = tmp_path / "cti_entry_2.zip"
    with zipfile.ZipFile(p, "w") as myzip:
        myzip.writestr("cti_entry_2.cti", cti_entry_data_2)
    return p

berhoel.ctitools.tests.test_processing.test_ctientry_1 🔗

test_ctientry_1() -> None

Check comparison operator for class CTIEntry.

Source code in src/berhoel/ctitools/tests/test_processing.py
def test_ctientry_1() -> None:
    """Check comparison operator for class `CTIEntry`."""
    assert CTIEntry(
        shorttitle="a",
        title="a",
        author=("a",),
        pages=1,
        issue="1",
        info=PaperInfo(),
        journaltitle="a",
        date="a",
        references="a",
        keywords="a",
    ) == CTIEntry(
        shorttitle="a",
        title="a",
        author=("a",),
        pages=1,
        issue="1",
        info=PaperInfo(),
        journaltitle="a",
        date="a",
        references="a",
        keywords="a",
    )

berhoel.ctitools.tests.test_processing.test_ctientry_2 🔗

test_ctientry_2() -> None

Check comparison operator for class CTIEntry.

Source code in src/berhoel/ctitools/tests/test_processing.py
def test_ctientry_2() -> None:
    """Check comparison operator for class `CTIEntry`."""
    assert CTIEntry(
        shorttitle="b",
        title="a",
        author=("a",),
        pages=1,
        issue="1",
        info=PaperInfo(),
        journaltitle="a",
        date="a",
        references="a",
        keywords="a",
    ) != CTIEntry(
        shorttitle="a",
        title="a",
        author=("a",),
        pages=1,
        issue="1",
        info=PaperInfo(),
        journaltitle="a",
        date="a",
        references="a",
        keywords="a",
    )

berhoel.ctitools.tests.test_processing.test_ctientry_4 🔗

test_ctientry_4(cti_4: CTIEntry) -> None

Check comparison operator for class CTIEntry.

Source code in src/berhoel/ctitools/tests/test_processing.py
def test_ctientry_4(cti_4: CTIEntry) -> None:
    """Check comparison operator for class `CTIEntry`."""
    assert cti_4 == CTIEntry(
        shorttitle="",
        title="Finger weg von Beta-Software",
        author=("Andre Kramer",),
        pages=3,
        issue="2024 / 21",
        info=PaperInfo(Papers.ct, 24),
        journaltitle="c't magazin für computertechnik",
        date="2024-09-20",
        references="",
        keywords="",
    )

berhoel.ctitools.tests.test_processing.test_process_author_1 🔗

test_process_author_1(cti_entry: str) -> None

Another test fopr input encoding handling.

Parameters:

  • cti_entry 🔗
    (str) –

    sample entry

Raises:

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.mark.parametrize("cti_entry", ["cti_entry_1", "cti_entry_zip_1"], indirect=True)
def test_process_author_1(cti_entry: str) -> None:
    """Another test fopr input encoding handling.

    Args:
        cti_entry: sample entry

    Raises:
        AssertionError: if test fails
    """
    probe = iter(CTI(cti_entry))
    result = next(probe).author
    reference = ("Dr. Volker Zota", "Dušan Wasserbäch")
    assert result == reference

berhoel.ctitools.tests.test_processing.test_process_author_2 🔗

test_process_author_2(cti_entry: str) -> None

Another test for processing autor entries.

Parameters:

  • cti_entry 🔗
    (str) –

    input data

Raises:

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.mark.parametrize("cti_entry", ["cti_entry_2", "cti_entry_zip_2"], indirect=True)
def test_process_author_2(cti_entry: str) -> None:
    """Another test for processing autor entries.

    Args:
        cti_entry: input data

    Raises:
        AssertionError: if test fails
    """
    probe = iter(CTI(cti_entry))
    result = next(probe).author
    reference = (
        "Torsten T. Will",
        "Ein Autor",
        "Dušan Živadinović",
    )
    assert result == reference

berhoel.ctitools.tests.test_processing.test_process_authors_ix_3 🔗

test_process_authors_ix_3(cti_entry_3: Path) -> None

Testing autor entries for iX.

Parameters:

  • cti_entry_3 🔗
    (Path) –

    Path to test file.

Source code in src/berhoel/ctitools/tests/test_processing.py
def test_process_authors_ix_3(cti_entry_3: Path) -> None:
    """Testing autor entries for iX.

    Args:
        cti_entry_3: Path to test file.
    """
    references = (
        CTIEntry(
            shorttitle="Familienleben",
            title="Digitals Alpha-Linie: Vorstellung von fünf 64-Bit-Rechnern in "
            "London",
            author=("Henning Behme",),
            pages=13,
            issue="1993 / 1",
            info=PaperInfo(Papers.iX, 93),
            journaltitle="iX",
            date="1993-01-01",
            references="",
            keywords="Markt + Trends",
        ),
        CTIEntry(
            shorttitle="Schlußfolgerungsmuster",
            title="Objektorientierte Verknüpfung von Wissensbasen und Datenbanken",
            author=("Kunihiko Higa", "Joline+Mike Morrison"),
            pages=132,
            issue="1993 / 1",
            info=PaperInfo(Papers.iX, 93),
            journaltitle="iX",
            date="1993-01-01",
            references="",
            keywords="Wissen",
        ),
    )

    data_read = False
    for probe, ref in zip(iter(CTI(cti_entry_3)), references):
        assert probe == ref
        data_read = True
    assert data_read, "No data read"

berhoel.ctitools.tests.test_processing.test_process_chars_2 🔗

test_process_chars_2(cti_entry: str) -> None

Testing handling of character encoding.

Parameters:

  • cti_entry 🔗
    (str) –

    test string

Raises:

Source code in src/berhoel/ctitools/tests/test_processing.py
@pytest.mark.parametrize("cti_entry", ["cti_entry_2", "cti_entry_zip_2"], indirect=True)
def test_process_chars_2(cti_entry: str) -> None:
    """Testing handling of character encoding.

    Args:
        cti_entry: test string

    Raises:
        AssertionError: if test fails
    """
    probe = iter(CTI(cti_entry))
    title = next(probe).title
    assert title == "Üäüößé"

berhoel.ctitools.tests.test_ct 🔗

Tests for processing c’t entries.

Functions:

  • issue_map –

    Return map from issue to corresponding data.

  • test_ct_dategen –

    Check for correct mapping from issue to issue data.

Functions🔗

berhoel.ctitools.tests.test_ct.issue_map 🔗

issue_map() -> IssueMap

Return map from issue to corresponding data.

Returns:

Source code in src/berhoel/ctitools/tests/test_ct.py
@pytest.fixture(scope="session")
def issue_map() -> ct.IssueMap:
    """Return map from issue to corresponding data.

    Returns:
        map
    """
    return ct.IssueMap()

berhoel.ctitools.tests.test_ct.test_ct_dategen 🔗

test_ct_dategen(issue: tuple, date: datetime, issue_map: IssueMap) -> None

Check for correct mapping from issue to issue data.

Parameters:

Source code in src/berhoel/ctitools/tests/test_ct.py
@pytest.mark.parametrize(
    ("issue", "date"),
    [
        ((2025, 22), DATETIME(2025, 10, 17)),
        ((2025, 21), DATETIME(2025, 10, 2)),
        ((2024, 3), DATETIME(2024, 1, 26)),
        ((2024, 2), DATETIME(2024, 1, 12)),
        ((2024, 1), DATETIME(2023, 12, 30)),
        ((2023, 29), DATETIME(2023, 12, 16)),
        ((2023, 28), DATETIME(2023, 12, 2)),
        ((2023, 27), DATETIME(2023, 11, 18)),
        ((2023, 26), DATETIME(2023, 11, 11)),
        ((2023, 13), DATETIME(2023, 5, 20)),
        ((2023, 12), DATETIME(2023, 5, 13)),
        ((2023, 11), DATETIME(2023, 5, 6)),
        ((2023, 10), DATETIME(2023, 4, 22)),
        ((2023, 9), DATETIME(2023, 4, 8)),
        ((2023, 1), DATETIME(2022, 12, 17)),
        ((2022, 27), DATETIME(2022, 11, 26)),
        ((2022, 26), DATETIME(2022, 12, 3)),
        ((2022, 25), DATETIME(2022, 11, 19)),
        ((2022, 17), DATETIME(2022, 7, 30)),
        ((2022, 16), DATETIME(2022, 7, 16)),
        ((2007, 10), DATETIME(2007, 4, 30)),
        ((2018, 27), DATETIME(2018, 10, 23)),
        ((2019, 27), DATETIME(2019, 10, 21)),
        ((2020, 27), DATETIME(2020, 10, 20)),
        ((2021, 27), DATETIME(2021, 10, 19)),
        ((2014, 15), DATETIME(2014, 6, 30)),
        ((1997, 10), DATETIME(1997, 10, 1)),
    ],
)
def test_ct_dategen(
    issue: tuple,
    date: datetime,
    issue_map: ct.IssueMap,
) -> None:
    """Check for correct mapping from issue to issue data.

    Args:
        issue: issue data to check
    """
    if issue_map(*issue) != date:
        msg = f"{issue_map(*issue)=} != {date}"
        raise AssertionError(msg)

berhoel.ctitools.cti2bibtex.tests.test_base 🔗

Basic tests for generating BibTex entries from c’t and iX articles.

Functions:

Classes🔗

Functions🔗

berhoel.ctitools.cti2bibtex.tests.test_base.test_with_shorttitle 🔗

test_with_shorttitle() -> None

Test correct generation of BiBTeX file entry.

Source code in src/berhoel/ctitools/cti2bibtex/tests/test_base.py
def test_with_shorttitle() -> None:
    """Test correct generation of BiBTeX file entry."""
    probe = BiBTeXEntry(
        CTIEntry(
            shorttitle="shorttitle",
            title="title",
            author=("author",),
            pages=42,
            issue="issue",
            info=PaperInfo(),
            journaltitle="journaltitle",
            date="date",
            references="references",
            keywords="keywords",
        ),
    )
    result = str(probe)
    reference = """@article{42:journaltitle_issue,
  title = {title},
  shorttitle = {shorttitle},
  author = {author},
  date = {date},
  journaltitle = {journaltitle},
  pages = {42},
  issue = {issue},
  keywords = {keywords},
}
"""
    if result != reference:
        msg = f"{result=} != {reference}"
        raise AssertionError(msg)

berhoel.ctitools.cti2bibtex.tests.test_base.test_without_shorttitle 🔗

test_without_shorttitle() -> None

Test correct generation of BiBTeX file entry.

Source code in src/berhoel/ctitools/cti2bibtex/tests/test_base.py
def test_without_shorttitle() -> None:
    """Test correct generation of BiBTeX file entry."""
    probe = BiBTeXEntry(
        CTIEntry(
            shorttitle=None,
            title="title",
            author=("author",),
            pages=3,
            issue="issue",
            info=PaperInfo(),
            journaltitle="journaltitle",
            date="date",
            references="references",
            keywords="keywords",
        ),
    )
    result = str(probe)
    reference = """@article{3:journaltitle_issue,
  title = {title},
  author = {author},
  date = {date},
  journaltitle = {journaltitle},
  pages = {3},
  issue = {issue},
  keywords = {keywords},
}
"""
    if result != reference:
        msg = f"{result=} != {reference=}"
        raise AssertionError(msg)

berhoel.ctitools.cti2bibtex.tests.test_generate 🔗

Check generation of BibTex output.

Functions:

Classes🔗

Functions🔗

berhoel.ctitools.cti2bibtex.tests.test_generate.bibtex_entry_1 🔗

bibtex_entry_1(cti_entry_1: CTIEntry) -> BiBTeXEntry

Provide test item for BibTeXEntry.

Parameters:

Returns:

Source code in src/berhoel/ctitools/cti2bibtex/tests/test_generate.py
@pytest.fixture
def bibtex_entry_1(cti_entry_1: CTIEntry) -> BiBTeXEntry:
    """Provide test item for `BibTeXEntry`.

    Args:
        cti_entry_1: entry to convert

    Returns:
        Sample entry
    """
    return BiBTeXEntry(cti_entry_1)

berhoel.ctitools.cti2bibtex.tests.test_generate.bibtex_entry_2 🔗

bibtex_entry_2(cti_entry_2: CTIEntry) -> BiBTeXEntry

Provide test item for BibTeXEntry.

Parameters:

Returns:

Source code in src/berhoel/ctitools/cti2bibtex/tests/test_generate.py
@pytest.fixture
def bibtex_entry_2(cti_entry_2: CTIEntry) -> BiBTeXEntry:
    """Provide test item for `BibTeXEntry`.

    Args:
        cti_entry_2: elemnent to convert

    Returns:
        Sample entry
    """
    return BiBTeXEntry(cti_entry_2)

berhoel.ctitools.cti2bibtex.tests.test_generate.cti_entry_1 🔗

cti_entry_1() -> CTIEntry

Provide test item for CTIEntry.

Returna

Sample entry

Source code in src/berhoel/ctitools/cti2bibtex/tests/test_generate.py
@pytest.fixture
def cti_entry_1() -> CTIEntry:
    """Provide test item for `CTIEntry`.

    Returna:
        Sample entry
    """
    return CTIEntry(
        shorttitle=None,
        title="Java nur mit -server-Option",
        author=("Dr. Volker Zota", "Hans T. Meier"),
        pages=154,
        issue="2007 / 10",
        info=PaperInfo(Papers.ct, 7),
        journaltitle="c't magazin für computertechnik",
        date="2007-04-30",
        references="",
        keywords="Praxis,Hotline,Java,Server,Internet,Programmierung,JAR-Archiv",
    )

berhoel.ctitools.cti2bibtex.tests.test_generate.cti_entry_2 🔗

cti_entry_2() -> CTIEntry

Provide test item for CTIEntry.

Returns:

Source code in src/berhoel/ctitools/cti2bibtex/tests/test_generate.py
@pytest.fixture
def cti_entry_2() -> CTIEntry:
    """Provide test item for `CTIEntry`.

    Returns:
        Sample entry
    """
    return CTIEntry(
        shorttitle=None,
        title="Doppelt gemoppelt",
        author=("Torsten T. Will",),
        pages=74,
        issue="2008 / 3",
        info=PaperInfo(Papers.ct, 8),
        journaltitle="c't magazin für computertechnik",
        date="2008-01-21",
        references="",
        keywords="kurz vorgestellt,Code Review,Open Source,Entwicklungssystem,"
        "Entwicklungs-Tools,Open-Source-Projekt Review Board",
    )

berhoel.ctitools.cti2bibtex.tests.test_generate.test_autor_enty_1 🔗

test_autor_enty_1(bibtex_entry_1: BiBTeXEntry) -> None

Test correct generation of BiBTeX file entry.

Parameters:

Source code in src/berhoel/ctitools/cti2bibtex/tests/test_generate.py
def test_autor_enty_1(bibtex_entry_1: BiBTeXEntry) -> None:
    """Test correct generation of BiBTeX file entry.

    Args:
        bibtex_entry_1: element to check
    """
    result = str(bibtex_entry_1)
    reference = """@article{154:c't_2007_/_10,
  title = {{J}ava nur mit -server-{O}ption},
  author = {Zota, Dr. Volker and Meier, Hans T.},
  date = {2007-04-30},
  journaltitle = {c't magazin für computertechnik},
  pages = {154},
  issue = {2007 / 10},
  keywords = {Praxis,Hotline,Java,Server,Internet,Programmierung,JAR-Archiv},
}
"""
    if result != reference:
        msg = f"{result=} != {reference=}"
        raise AssertionError(msg)

berhoel.ctitools.cti2bibtex.tests.test_generate.test_autor_enty_2 🔗

test_autor_enty_2(bibtex_entry_2: BiBTeXEntry) -> None

Test correct generation of BiBTeX file entry.

Parameters:

Source code in src/berhoel/ctitools/cti2bibtex/tests/test_generate.py
def test_autor_enty_2(bibtex_entry_2: BiBTeXEntry) -> None:
    """Test correct generation of BiBTeX file entry.

    Args:
        bibtex_entry_2: element to check
    """
    result = str(bibtex_entry_2)
    reference = """@article{74:c't_2008_/_3,
  title = {{D}oppelt gemoppelt},
  author = {Will, Torsten T.},
  date = {2008-01-21},
  journaltitle = {c't magazin für computertechnik},
  pages = {74},
  issue = {2008 / 3},
  keywords = {kurz vorgestellt,Code Review,Open Source,Entwicklungssystem,Entwicklungs-Tools,Open-Source-Projekt Review Board},
}
"""  # noqa: E501
    if result != reference:
        msg = f"{result=} != {reference=}"
        raise AssertionError(msg)