예제 #1
0
def test_str_truncation_over_limit(db, settings):
    """
    Model str should be truncated to X words when over the limit from setting
    ``BLOCKS_MODEL_TRUNCATION_LENGTH``.
    """
    limit = settings.BLOCKS_MODEL_TRUNCATION_LENGTH + 3

    title = get_fake_words(length=limit)
    album = Album(title=title, template="Dummy")
    album.save()

    assert len(title) > len(str(album))
    assert str(album).endswith(settings.BLOCKS_MODEL_TRUNCATION_CHR)

    title = get_fake_words(length=limit)
    item = AlbumItem(
        album=album,
        title=title,
        order=42,
        image="ping.jpg",
    )
    item.save()

    assert len(title) > len(str(item))
    assert str(item).endswith(settings.BLOCKS_MODEL_TRUNCATION_CHR)
예제 #2
0
def test_str_truncation_under_limit(db, settings):
    """
    Model str should be equal to save string when under the limit.
    """
    content = get_fake_words(length=settings.BLOCKS_MODEL_TRUNCATION_LENGTH)
    instance = Card(content=content, template="Dummy")
    instance.save()

    assert content == str(instance)
예제 #3
0
def test_str_truncation_under_limit(db, settings):
    """
    Model str should be equal to saved string when under the limit.
    """
    title = get_fake_words(length=settings.BLOCKS_MODEL_TRUNCATION_LENGTH)
    album = Album(title=title, template="Dummy")
    album.save()

    assert title == str(album)

    title = get_fake_words(length=settings.BLOCKS_MODEL_TRUNCATION_LENGTH)
    item = AlbumItem(
        album=album,
        title=title,
        order=42,
        image="ping.jpg",
    )
    item.save()

    assert title == str(item)
예제 #4
0
def test_str_truncation_over_limit(db, settings):
    """
    Model str should be truncated to X words when over the limit from setting
    ``BLOCKS_MODEL_TRUNCATION_LENGTH``.
    """
    content = get_fake_words(length=(settings.BLOCKS_MODEL_TRUNCATION_LENGTH +
                                     3))
    instance = Card(content=content, template="Dummy")
    instance.save()

    assert len(content) > len(str(instance))
    assert str(instance).endswith(settings.BLOCKS_MODEL_TRUNCATION_CHR)