Skip to content

Module app.tests.test_text

View Source
import pytest

from .. import utils

LINES_SLUG = [

    (["hello world"], "hello_world"),

    (["?%#/&\\"], "~q~p~h~s~a~b"),

    (["a/b", "c"], "a~sb/c"),

    (["variable_name"], "variable__name"),

    (["variable-name"], "variable--name"),

    (["foo\nbar"], "foo~nbar"),

    (["def data() -> Dict"], "def_data()_-->_Dict"),

    (['That\'s not how "this" works'], "That's_not_how_''this''_works"),

]

@pytest.mark.parametrize(("lines", "slug"), LINES_SLUG)

def test_encode(expect, lines, slug):

    expect(utils.text.encode(lines)) == slug

@pytest.mark.parametrize(("lines", "slug"), LINES_SLUG)

def test_decode(expect, lines, slug):

    expect(utils.text.decode(slug)) == lines

def test_decode_dashes(expect):

    expect(utils.text.decode("hello-world")) == ["hello world"]

Variables

LINES_SLUG

Functions

test_decode

def test_decode(
    expect,
    lines,
    slug
)
View Source
@pytest.mark.parametrize(("lines", "slug"), LINES_SLUG)

def test_decode(expect, lines, slug):

    expect(utils.text.decode(slug)) == lines

test_decode_dashes

def test_decode_dashes(
    expect
)
View Source
def test_decode_dashes(expect):

    expect(utils.text.decode("hello-world")) == ["hello world"]

test_encode

def test_encode(
    expect,
    lines,
    slug
)
View Source
@pytest.mark.parametrize(("lines", "slug"), LINES_SLUG)

def test_encode(expect, lines, slug):

    expect(utils.text.encode(lines)) == slug