Пример #1
0
def test_languoids(api):
    assert len(list(api.languoids())) == 7
    assert len(list(api.languoids(maxlevel=api.languoid_levels.family))) == 2
    assert len(list(api.languoids(maxlevel=api.languoid_levels.language))) == 5
    assert len(api.languoids_by_code()) == 10
    assert api.languoids_by_code(nodes={}) == {}
    assert 'NOCODE_Family-name' in api.languoids_by_code()
Пример #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_newick_tree(api):
    assert api.newick_tree(start='abcd1235') == \
        "('dialect [abcd1236]':1)'language [abcd1235][abc]-l-':1;"
    assert api.newick_tree(start='abcd1235') == \
        api.newick_tree(start='abcd1235', nodes={l.id: l for l in api.languoids()})
    assert api.newick_tree(start='abcd1235', template='{l.id}') == "(abcd1236:1)abcd1235:1;"
    assert set(api.newick_tree().split('\n')) == {
        "(('isolate {dialect} [dial1234]':1)'isolate [isol1234]-l-':1)'isolate [isol1234]':1;",
        "(('dialect [abcd1236]':1)'language [abcd1235][abc]-l-':1)'family [abcd1234][aaa]':1;"
    }
Пример #5
0
def test_languoids(api):
    assert len(list(api.languoids())) == 4
    assert len(list(api.languoids(maxlevel=languoids.Level.family))) == 1
    assert len(list(api.languoids(maxlevel=languoids.Level.language))) == 3
    assert len(api.languoids_by_code()) == 7
    assert 'NOCODE_Family-name' in api.languoids_by_code()