Пример #1
0
def test_top_level_doc():
    """A DocumentBaseSource with a top-level slug has no parent."""
    source = DocumentBaseSource('/locale/docs/slug')
    assert source.path == '/locale/docs/slug'
    assert source.locale == 'locale'
    assert source.slug == 'slug'
    assert source.parent_slug is None
    assert source.parent_path is None
Пример #2
0
def test_child_doc():
    """A DocumentBaseSource with a child-level slug has a parent."""
    source = DocumentBaseSource('/locale/docs/parent/child')
    assert source.path == '/locale/docs/parent/child'
    assert source.locale == 'locale'
    assert source.slug == 'parent/child'
    assert source.parent_slug == 'parent'
    assert source.parent_path == '/locale/docs/parent'
Пример #3
0
def test_top_level_doc():
    """A DocumentBaseSource with a top-level slug has no parent."""
    source = DocumentBaseSource("/locale/docs/slug")
    assert source.path == "/locale/docs/slug"
    assert source.locale == "locale"
    assert source.slug == "slug"
    assert source.parent_slug is None
    assert source.parent_path is None
Пример #4
0
def test_child_doc():
    """A DocumentBaseSource with a child-level slug has a parent."""
    source = DocumentBaseSource("/locale/docs/parent/child")
    assert source.path == "/locale/docs/parent/child"
    assert source.locale == "locale"
    assert source.slug == "parent/child"
    assert source.parent_slug == "parent"
    assert source.parent_path == "/locale/docs/parent"
def test_zone_doc():
    """A DocumentBaseSource with a zone slug starts un-normalized."""
    source = DocumentBaseSource('/locale/zone')
    assert source.path == '/locale/zone'
    assert source.locale is None
    assert source.slug is None
    assert source.normalized_path is None
    assert source.parent_slug is None
    assert source.parent_path is None
Пример #6
0
def test_url_escaped_raises():
    """Initializing with a URL-encoded path raises an exception."""
    with pytest.raises(ValueError):
        DocumentBaseSource('/en-US/docs/traducci%C3%B3n')