예제 #1
0
def test_cache(caching_api, api):
    lang = api.languoid('abcd1234')
    assert lang is not api.languoid('abcd1234')

    lang = caching_api.languoid('abcd1234')
    assert lang is caching_api.languoid('abcd1234')
    assert caching_api.languoid('aaa') is lang
    l2 = caching_api.languoid('abc')
    assert l2.id == 'abcd1235'
    assert l2.ancestors
예제 #2
0
def test_descendants_from_nodemap(api):
    nodemap = {n.id: n for n in api.languoids()}
    l = api.languoid('abcd1234')
    assert len(l.descendants_from_nodemap(nodemap)) == 2
    assert len(l.descendants_from_nodemap(nodemap, level=api.languoid_levels.language)) == 1
    assert len(l.descendants_from_nodemap(nodemap, level='dialect')) == 1

    with pytest.raises(ValueError):
        l.descendants_from_nodemap(nodemap, level='dialects')
예제 #3
0
def test_descendants_from_nodemap(api):
    nodemap = {n.id: n for n in api.languoids()}
    l = api.languoid('abcd1234')
    assert len(l.descendants_from_nodemap(nodemap)) == 2
    assert len(
        l.descendants_from_nodemap(nodemap,
                                   level=api.languoid_levels.language)) == 1
    assert len(
        l.descendants_from_nodemap(nodemap,
                                   level=api.languoid_levels.dialect)) == 1
예제 #4
0
def test_languoid(api):
    assert api.languoid('abc').name == 'language'