Esempio n. 1
0
def test_listing_texts(client, bibliography, sign_repository, signs,
                       text_repository):
    first_text = TextFactory.build(chapters=tuple(), references=tuple())
    second_text = TextFactory.build(chapters=tuple(), references=tuple())
    text_repository.create(first_text)
    text_repository.create(second_text)

    get_result = client.simulate_get("/texts")

    assert get_result.status == falcon.HTTP_OK
    assert get_result.json == [create_dto(first_text), create_dto(second_text)]
Esempio n. 2
0
def test_get_text(client, bibliography, sign_repository, signs,
                  text_repository):
    text = TextFactory.build(chapters=tuple(), references=tuple())
    text_repository.create(text)

    get_result = client.simulate_get(
        f"/texts/{text.genre.value}/{text.category}/{text.index}")

    assert get_result.status == falcon.HTTP_OK
    assert get_result.json == create_dto(text)
Esempio n. 3
0
def test_chapter_display_of_chapter() -> None:
    text = TextFactory.build()
    chapter = ChapterFactory.build()

    chapter_display = ChapterDisplay.of_chapter(text, chapter)

    assert chapter_display == ChapterDisplay(
        chapter.id_,
        text.name,
        text.has_doi,
        not text.has_multiple_stages,
        tuple(LineDisplay.of_line(line) for line in chapter.lines),
        chapter.record,
    )
    assert chapter_display.title == make_title(chapter.lines[0].translation)
def test_has_multiple_stages(chapters, expected) -> None:
    text = TextFactory.build(chapters=chapters)
    assert text.has_multiple_stages == expected
Esempio n. 5
0
def text(chapter: Chapter) -> Text:
    return TextFactory.build(
        genre=chapter.text_id.genre,
        category=chapter.text_id.category,
        index=chapter.text_id.index,
    )
    ChapterFactory,
    LineFactory,
    ManuscriptFactory,
    TextFactory,
)
from ebl.tests.factories.fragment import FragmentFactory
from ebl.transliteration.domain.genre import Genre
from ebl.transliteration.domain.transliteration_query import TransliterationQuery

TEXTS_COLLECTION = "texts"
CHAPTERS_COLLECTION = "chapters"
JOINS_COLLECTION = "joins"
MANUSCRIPT_ID = 1
MUSEUM_NUMBER = MuseumNumber("X", "1")
UNCERTAIN_FRAGMET = MuseumNumber("X", "2")
TEXT = TextFactory.build()
CHAPTER = ChapterFactory.build(
    text_id=TEXT.id,
    stage=TEXT.chapters[0].stage,
    name=TEXT.chapters[0].name,
    manuscripts=(ManuscriptFactory.build(id=1,
                                         museum_number=MUSEUM_NUMBER,
                                         accession="",
                                         references=tuple()), ),
    lines=(LineFactory.build(manuscript_id=1,
                             translation=TEXT.chapters[0].translation), ),
    uncertain_fragments=tuple(),
)


def when_text_in_collection(database, text=TEXT) -> None: