def test_slugify_topic_if_slug_is_empty(discussion): from assembl.lib.utils import slugify from assembl.models.discussion import slugify_topic_if_slug_is_empty slugify_topic_if_slug_is_empty(discussion, discussion.topic, "oldvalue", "initiator") assert discussion.slug != str(slugify(discussion.topic)) discussion.slug = "" slugify_topic_if_slug_is_empty(discussion, discussion.topic, "oldvalue", "initiator") assert (discussion.slug) == str(slugify(discussion.topic))
def test_slugify_topic_if_slug_is_empty(discussion): from assembl.lib.utils import slugify from assembl.models.discussion import slugify_topic_if_slug_is_empty slugify_topic_if_slug_is_empty( discussion, discussion.topic, "oldvalue", "initiator") assert discussion.slug != str(slugify(discussion.topic)) discussion.slug = "" slugify_topic_if_slug_is_empty( discussion, discussion.topic, "oldvalue", "initiator") assert (discussion.slug) == str(slugify(discussion.topic))
def slugify_topic_if_slug_is_empty(discussion, topic, oldvalue, initiator): """ if the target doesn't have a slug, slugify the topic and use that. """ if not discussion.slug: discussion.slug = slugify(topic)