예제 #1
0
파일: test_db.py 프로젝트: tomgross/lektor
def test_alt_fallback(pad):
    # page that is missing a german tranlation
    wolf_page = pad.get("/projects/wolf", alt="de")

    # Falls back to primary
    assert wolf_page.alt == "de"
    assert wolf_page["_source_alt"] == "_primary"
    assert wolf_page["name"] == "Wolf"

    # If we ask for the alts of that page, we will only get english
    assert get_alts(wolf_page) == ["en"]

    # Unless we include fallbacks in which case we will also see german
    # show up in the list.
    assert get_alts(wolf_page, fallback=True) == ["en", "de"]
예제 #2
0
def test_alt_fallback(pad):
    # page that is missing a german tranlation
    wolf_page = pad.get('/projects/wolf', alt='de')

    # Falls back to primary
    assert wolf_page.alt == 'de'
    assert wolf_page['_source_alt'] == '_primary'
    assert wolf_page['name'] == 'Wolf'

    # If we ask for the alts of that page, we will only get english
    assert get_alts(wolf_page) == ['en']

    # Unless we include fallbacks in which case we will also see german
    # show up in the list.
    assert get_alts(wolf_page, fallback=True) == ['en', 'de']
예제 #3
0
파일: test_db.py 프로젝트: sunliwen/lektor
def test_alt_fallback(pad):
    # page that is missing a german tranlation
    wolf_page = pad.get('/projects/wolf', alt='de')

    # Falls back to primary
    assert wolf_page.alt == 'de'
    assert wolf_page['_source_alt'] == '_primary'
    assert wolf_page['name'] == 'Wolf'

    # If we ask for the alts of that page, we will only get english
    assert get_alts(wolf_page) == ['en']

    # Unless we include fallbacks in which case we will also see german
    # show up in the list.
    assert get_alts(wolf_page, fallback=True) == ['en', 'de']
예제 #4
0
def test_url_matching_with_customized_slug_in_alt(pad):
    en = pad.resolve_url_path('/projects/slave/')
    assert en.alt == 'en'
    assert en['_source_alt'] == '_primary'
    assert en.path == '/projects/slave'

    de = pad.resolve_url_path('/de/projects/sklave/')
    assert de.alt == 'de'
    assert de['_source_alt'] == 'de'
    assert de.path == '/projects/slave'

    assert get_alts(en) == ['en', 'de']
예제 #5
0
파일: test_db.py 프로젝트: tomgross/lektor
def test_url_matching_with_customized_slug_in_alt(pad):
    en = pad.resolve_url_path("/projects/slave/")
    assert en.alt == "en"
    assert en["_source_alt"] == "_primary"
    assert en.path == "/projects/slave"

    de = pad.resolve_url_path("/de/projects/sklave/")
    assert de.alt == "de"
    assert de["_source_alt"] == "de"
    assert de.path == "/projects/slave"

    assert get_alts(en) == ["en", "de"]
예제 #6
0
파일: test_db.py 프로젝트: sunliwen/lektor
def test_url_matching_with_customized_slug_in_alt(pad):
    en = pad.resolve_url_path('/projects/slave/')
    assert en.alt == 'en'
    assert en['_source_alt'] == '_primary'
    assert en.path == '/projects/slave'

    de = pad.resolve_url_path('/de/projects/sklave/')
    assert de.alt == 'de'
    assert de['_source_alt'] == 'de'
    assert de.path == '/projects/slave'

    assert get_alts(en) == ['en', 'de']
예제 #7
0
def test_basic_alts(pad):
    with Context(pad=pad):
        assert get_alts() == ['en', 'de']
예제 #8
0
파일: test_db.py 프로젝트: tomgross/lektor
def test_basic_alts(pad):
    with Context(pad=pad):
        assert get_alts() == ["en", "de"]
예제 #9
0
파일: test_db.py 프로젝트: sunliwen/lektor
def test_basic_alts(pad):
    with Context(pad=pad):
        assert get_alts() == ['en', 'de']