-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
60 lines (42 loc) · 2.01 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from pycldf import Wordlist
from lexibank_numerals import CHANURL
from pynumerals.numerals_utils import split_form_table
channumerals = split_form_table(Wordlist.from_metadata("tests/cldf-metadata.json"))
def test_valid(cldf_dataset, cldf_logger):
assert cldf_dataset.validate(log=cldf_logger)
def test_languages(cldf_dataset):
assert any(l['SourceFile'] == 'Abua.htm' for l in cldf_dataset["LanguageTable"])
def test_forms(cldf_dataset):
assert any(f["Other_Form"] == "een" for f in cldf_dataset["FormTable"])
class TestUtil:
@staticmethod
def test_split_forms():
"""
This is likely going to break with changes to the upstream data. However, I'd rather see
this fail in the tests first.
"""
assert len(channumerals) == 7
assert channumerals[0][0]["ID"] == "aari1239-1-1-1"
assert channumerals[0][0]["Language_ID"] == "aari1239-1"
assert channumerals[-1][0]["ID"] == "zuoj1238-1-1-1"
@staticmethod
def test_index_link():
from pynumerals.numerals_utils import make_index_link
assert "* []()" == make_index_link("")
assert "* [Path/to/file](Path/to/file)" == make_index_link("Path/to/file")
assert "* [Spaces Spaces](Spaces%20Spaces)" == make_index_link("Spaces Spaces")
@staticmethod
def test_chan_link():
from pynumerals.numerals_utils import make_chan_link
assert " ([Source]({0}))".format(CHANURL) == make_chan_link("", CHANURL)
assert " ([Source]({0}Bateri.htm))".format(CHANURL) == make_chan_link("Bateri.htm", CHANURL)
@staticmethod
def test_check_problems():
from pynumerals.numerals_utils import check_for_problems
assert "" == check_for_problems(channumerals[0])
assert " **(Problems)**" == check_for_problems(channumerals[3])
@staticmethod
def test_language_name():
from pynumerals.numerals_utils import make_language_name
assert "" == make_language_name()
assert " (Sindarin)" == make_language_name("Sindarin")