def test_duplicate_ids_are_invalid():
    with pytest.raises(ValueError):
        Chapter(
            TEXT_ID,
            manuscripts=(
                Manuscript(MANUSCRIPT_ID, siglum_disambiguator="a"),
                Manuscript(MANUSCRIPT_ID, siglum_disambiguator="b"),
            ),
        )
def test_invalid_extent() -> None:
    with pytest.raises(ValueError):
        Chapter(
            TextId(GENRE, 0, 0),
            manuscripts=(Manuscript(MANUSCRIPT_ID), ),
            lines=(Line(
                LineNumber(1),
                (LINE_VARIANT_1, ),
                translation=(TranslationLine(tuple(),
                                             extent=Extent(LineNumber(2))), ),
            ), ),
        )
def test_duplicate_sigla_are_invalid():
    with pytest.raises(ValueError):
        Chapter(
            TEXT_ID,
            manuscripts=(
                Manuscript(
                    MANUSCRIPT_ID,
                    siglum_disambiguator=SIGLUM_DISAMBIGUATOR,
                    period=PERIOD,
                    provenance=PROVENANCE,
                    type=TYPE,
                ),
                Manuscript(
                    MANUSCRIPT_ID + 1,
                    siglum_disambiguator=SIGLUM_DISAMBIGUATOR,
                    period=PERIOD,
                    provenance=PROVENANCE,
                    type=TYPE,
                ),
            ),
        )
def test_extant_lines() -> None:
    manuscript = Manuscript(MANUSCRIPT_ID)
    manuscript_line = LINE_VARIANT_1.manuscripts[0]
    chapter = Chapter(
        TEXT_ID,
        manuscripts=(manuscript, ),
        lines=(
            Line(LineNumber(1), (LINE_VARIANT_1, )),
            Line(LineNumber(2), (LINE_VARIANT_2, )),
        ),
    )
    assert chapter.extant_lines == {
        manuscript.siglum: {
            manuscript_line.labels:
            [ExtantLine(manuscript_line.labels, LineNumber(1), True)]
        }
    }
def test_missing_manuscripts_are_invalid():
    with pytest.raises(ValueError):
        Chapter(
            TEXT_ID,
            manuscripts=(Manuscript(MANUSCRIPT_ID), ),
            lines=(Line(
                LINE_NUMBER,
                (LineVariant(
                    LINE_RECONSTRUCTION,
                    NOTE,
                    (ManuscriptLine(MANUSCRIPT_ID + 1, LABELS,
                                    MANUSCRIPT_TEXT_1), ),
                ), ),
                IS_SECOND_LINE_OF_PARALLELISM,
                IS_BEGINNING_OF_SECTION,
            ), ),
        )
 def make_manuscript(self, data: dict, **kwargs) -> Manuscript:
     return Manuscript(
         data["id"],
         data["siglum_disambiguator"],
         data["museum_number"],
         data["accession"],
         data["period_modifier"],
         data["period"],
         data["provenance"],
         data["type"],
         data["notes"],
         data["colophon"],
         data["unplaced_lines"],
         tuple(data["references"]),
         data["joins"],
         data["is_in_fragmentarium"],
     )
def test_overlapping_languages() -> None:
    Chapter(
        TextId(GENRE, 0, 0),
        manuscripts=(Manuscript(MANUSCRIPT_ID), ),
        lines=(
            Line(
                LineNumber(1),
                (LINE_VARIANT_1, ),
                translation=(TranslationLine(tuple(), "en",
                                             Extent(LineNumber(2))), ),
            ),
            Line(
                LineNumber(2),
                (LINE_VARIANT_2, ),
                translation=(TranslationLine(tuple(), "de"), ),
            ),
        ),
    )
Beispiel #8
0
def test_extant_lines_schema() -> None:
    manuscript = Manuscript(1)
    manuscript_line = ManuscriptLine(1, LABELS, MANUSCRIPT_TEXT_1)
    variant = LineVariant(tuple(), manuscripts=(manuscript_line, ))
    text_line = Line(LineNumber(1), (variant, ))
    chapter = Chapter(TextId(Genre.LITERATURE, 0, 0),
                      manuscripts=(manuscript, ),
                      lines=(text_line, ))
    assert ExtantLinesSchema().dump(chapter) == {
        "extantLines": {
            str(manuscript.siglum): {
                " ".join(label.to_value() for label in manuscript_line.labels):
                [{
                    "isSideBoundary": False,
                    "lineNumber":
                    OneOfLineNumberSchema().dump(text_line.number),
                }]
            }
        }
    }
def test_extant_lines_mixed_sides() -> None:
    manuscript = Manuscript(
        MANUSCRIPT_ID,
        siglum_disambiguator="1",
        period_modifier=PeriodModifier.NONE,
        period=Period.LATE_BABYLONIAN,
        provenance=Provenance.BABYLON,
        type=ManuscriptType.SCHOOL,
    )
    manuscript_line = ManuscriptLine(
        MANUSCRIPT_ID,
        LABELS,
        TextLine(
            LineNumberRange(LineNumber(1), LineNumber(3, suffix_modifier="b")),
            (UnknownNumberOfSigns.of(), ),
        ),
        PARATEXT,
        OMITTED_WORDS,
    )
    manuscript_line2 = ManuscriptLine(
        MANUSCRIPT_ID,
        tuple(),
        TextLine(LineNumber(2), (UnknownNumberOfSigns.of(), )),
        PARATEXT,
        OMITTED_WORDS,
    )
    manuscript_line3 = ManuscriptLine(
        MANUSCRIPT_ID,
        LABELS,
        TextLine(LineNumber(3), (UnknownNumberOfSigns.of(), )),
        PARATEXT,
        OMITTED_WORDS,
    )
    chapter = Chapter(
        TEXT_ID,
        manuscripts=(manuscript, ),
        lines=(
            Line(
                LineNumber(1),
                (LineVariant(LINE_RECONSTRUCTION, NOTE,
                             (manuscript_line, ), PARALLEL_LINES), ),
            ),
            Line(
                LineNumber(2),
                (LineVariant(LINE_RECONSTRUCTION, NOTE,
                             (manuscript_line2, ), PARALLEL_LINES), ),
            ),
            Line(
                LineNumber(3),
                (LineVariant(LINE_RECONSTRUCTION, NOTE,
                             (manuscript_line3, ), PARALLEL_LINES), ),
            ),
        ),
    )
    assert chapter.extant_lines == {
        manuscript.siglum: {
            manuscript_line.labels: [
                ExtantLine(manuscript_line.labels, LineNumber(1), True),
                ExtantLine(manuscript_line3.labels, LineNumber(3), False),
            ],
            manuscript_line2.labels:
            [ExtantLine(manuscript_line2.labels, LineNumber(2), False)],
        }
    }
TEXT_ID = TextId(GENRE, CATEGORY, INDEX)
CHAPTER = Chapter(
    TEXT_ID,
    CLASSIFICATION,
    STAGE,
    VERSION,
    CHAPTER_NAME,
    ORDER,
    (Manuscript(
        MANUSCRIPT_ID,
        SIGLUM_DISAMBIGUATOR,
        MUSEUM_NUMBER,
        ACCESSION,
        PERIOD_MODIFIER,
        PERIOD,
        PROVENANCE,
        TYPE,
        NOTES,
        COLOPHON,
        UNPLACED_LINES,
        REFERENCES,
    ), ),
    (MUSEUM_NUMBER, ),
    (LINE_1, LINE_2, LINE_3),
    SIGNS,
    RECORD,
)


def test_constructor_sets_correct_fields():
    assert CHAPTER.text_id == TextId(GENRE, CATEGORY, INDEX)
Beispiel #11
0
def test_giving_museum_number_and_accession_is_invalid():
    with pytest.raises(ValueError):
        Manuscript(
            1, museum_number=MuseumNumber("BM", "x"), accession="accession not allowed"
        )
Beispiel #12
0
def test_invalid_siglum(provenance, period, type_) -> None:
    with pytest.raises(ValueError):
        Manuscript(1, provenance=provenance, period=period, type=type_)
Beispiel #13
0
                ), ),
            ),
        ),
    ],
)
def test_merge_line(old: Line, new: Line, expected: Line) -> None:
    assert old.merge(new) == expected


TEXT_ID = TextId(Genre.LITERATURE, 0, 0)
CLASSIFICATION = Classification.ANCIENT
STAGE = Stage.NEO_BABYLONIAN
VERSION = "A"
CHAPTER_NAME = "I"
ORDER = 1
MANUSCRIPT = Manuscript(MANUSCRIPT_ID)
MUSEUM_NUMBER = MuseumNumber.of("K.1")
CHAPTER = Chapter(
    TEXT_ID,
    CLASSIFICATION,
    STAGE,
    VERSION,
    CHAPTER_NAME,
    ORDER,
    (MANUSCRIPT, ),
    (MUSEUM_NUMBER, ),
    (LINE, ),
)

NEW_CLASSIFICATION = Classification.MODERN
NEW_STAGE = Stage.MIDDLE_ASSYRIAN