def test_array_field():
    """
    If the requested field is an array, prettify each element.
    """

    text = Text(authors=[
        'david mcclure',
        'joe karaganis',
    ])

    assert text.pretty('authors') == [
        prettify('david mcclure'),
        prettify('joe karaganis'),
    ]
def test_array_field():

    """
    If the requested field is an array, prettify each element.
    """

    text = Text(authors=[
        'david mcclure',
        'joe karaganis',
    ])

    assert text.pretty('authors') == [
        prettify('david mcclure'),
        prettify('joe karaganis'),
    ]
def test_string_field():
    """
    Text#pretty() should return a prettified version of the field.
    """

    text = Text(title='war and peace')

    assert text.pretty('title') == prettify('war and peace')
def test_string_field():

    """
    Text#pretty() should return a prettified version of the field.
    """

    text = Text(title='war and peace')

    assert text.pretty('title') == prettify('war and peace')
    def pretty(self, field):
        """
        Prettify a field.

        Args:
            field (str)

        Returns: str|list
        """

        value = getattr(self, field)

        if not value:
            return None

        elif type(value) is list:
            return [prettify(v) for v in value]

        else:
            return prettify(value)
Example #6
0
    def pretty(self, field):

        """
        Prettify a field.

        Args:
            field (str)

        Returns: str|list
        """

        value = getattr(self, field)

        if not value:
            return None

        elif type(value) is list:
            return [prettify(v) for v in value]

        else:
            return prettify(value)
def test_parse_domain(ugly, pretty):
    assert prettify(ugly) == pretty
def test_parse_domain(ugly, pretty):
    assert prettify(ugly) == pretty