def test_defaults() -> None:
    reference = Reference(ID, TYPE)

    assert reference.pages == ""
    assert reference.notes == ""
    assert reference.lines_cited == tuple()
    assert reference.document is None
Example #2
0
def test_bibliography_part() -> None:
    pages = "12-49"
    part = BibliographyPart.of(BIBLIOGRAPHY_ID, pages)

    assert part.reference == Reference(BIBLIOGRAPHY_ID,
                                       ReferenceType.DISCUSSION, pages, "",
                                       tuple())
def create_reference_with_document(bibliography_entry) -> Reference:
    return Reference(
        bibliography_entry["id"], TYPE, PAGES, NOTES, LINES_CITED, bibliography_entry
    )
from ebl.bibliography.application.reference_schema import (
    ApiReferenceSchema,
    ReferenceSchema,
)
from ebl.bibliography.domain.reference import BibliographyId, Reference, ReferenceType
from ebl.tests.factories.bibliography import BibliographyEntryFactory

ID = BibliographyId("RN.1")
TYPE: ReferenceType = ReferenceType.EDITION
PAGES = "1-6"
NOTES = "some notes"
LINES_CITED = ("o. 1", "r. iii! 2a.2", "9'")

REFERENCE = Reference(ID, TYPE, PAGES, NOTES, LINES_CITED)

SERIALIZED_REFERENCE: dict = {
    "id": ID,
    "type": TYPE.name,
    "pages": PAGES,
    "notes": NOTES,
    "linesCited": list(LINES_CITED),
}


def create_reference_with_document(bibliography_entry) -> Reference:
    return Reference(
        bibliography_entry["id"], TYPE, PAGES, NOTES, LINES_CITED, bibliography_entry
    )


def test_reference() -> None:
Example #5
0
def test_invalid_reference(type, pages, note, lines) -> None:
    with (pytest.raises(ValueError)):
        BibliographyPart(Reference(BIBLIOGRAPHY_ID, type, pages, note, lines))
    LanguagePart,
    MarkupPart,
    StringPart,
    rstrip,
    title_case,
    to_title,
)
from ebl.transliteration.domain.sign_tokens import Divider, Reading

PUNCTUATION = ";,:.-–—"
TEXT = "sed nec tortor varius, iaculis."
LANGUAGE_PART = LanguagePart(
    Language.AKKADIAN,
    [Reading.of_name("kur"), Divider.of(":")])
BIBLIOGRAPHY_PART = BibliographyPart(
    Reference(BibliographyId("1"), ReferenceType.DISCUSSION,
              TEXT + PUNCTUATION))


@pytest.mark.parametrize(  # pyre-ignore[56]
    "part,expected",
    [
        (
            StringPart(f"{PUNCTUATION}A{PUNCTUATION}A{PUNCTUATION}"),
            StringPart(f"{PUNCTUATION}A{PUNCTUATION}A"),
        ),
        (
            EmphasisPart(f"{PUNCTUATION}A{PUNCTUATION}A{PUNCTUATION}"),
            EmphasisPart(f"{PUNCTUATION}A{PUNCTUATION}A"),
        ),
        (LANGUAGE_PART, LANGUAGE_PART),
        (BIBLIOGRAPHY_PART, BIBLIOGRAPHY_PART),
Example #7
0
 def make_reference(self, data, **kwargs) -> Reference:
     data["id"] = BibliographyId(data["id"])
     data["lines_cited"] = tuple(data["lines_cited"])
     data["document"] = data["document"] and create_object_entry(
         data["document"])
     return Reference(**data)
         "type": "NoteLine",
         "prefix": "#note: ",
         "parts": [
             {"type": "StringPart", "text": "a note "},
             {"type": "EmphasisPart", "text": "italic"},
             {
                 "type": "LanguagePart",
                 "language": Language.AKKADIAN.name,
                 "tokens": [
                     OneOfTokenSchema().dump(Word.of([Reading.of_name("bu")]))
                 ],
             },
             {
                 "type": "BibliographyPart",
                 "reference": ReferenceSchema().dump(
                     Reference(BibliographyId("A"), ReferenceType.DISCUSSION, "1-4")
                 ),
             },
         ],
         "content": OneOfTokenSchema().dump(
             [
                 ValueToken.of("a note "),
                 ValueToken.of("@i{italic}"),
                 ValueToken.of("@akk{bu}"),
                 ValueToken.of("@bib{A@1-4}"),
             ],
             many=True,
         ),
     },
 ),
 (