Skip to content

Commit ed8e87b

Browse files
chore: add test for reading from file
1 parent d302f6b commit ed8e87b

File tree

2 files changed

+107
-1
lines changed

2 files changed

+107
-1
lines changed

tests/test_aliasor.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1+
from __future__ import unicode_literals
2+
3+
import os
4+
from distutils import dir_util
5+
16
from pango_aliasor.aliasor import Aliasor
7+
from pytest import fixture
8+
9+
10+
@fixture
11+
def datadir(tmpdir, request):
12+
'''
13+
Fixture responsible for searching a folder with the same name of test
14+
module and, if available, moving all contents to a temporary directory so
15+
tests can use them freely.
16+
'''
17+
filename = request.module.__file__
18+
test_dir, _ = os.path.splitext(filename)
19+
20+
if os.path.isdir(test_dir):
21+
dir_util.copy_tree(test_dir,str(tmpdir))
22+
23+
return tmpdir
224

325
def test_pango_designation_init():
426
aliasor = Aliasor()
@@ -33,4 +55,8 @@ def test_double_alias_compression():
3355

3456
def test_double_alias_uncompression():
3557
aliasor = Aliasor()
36-
assert aliasor.uncompress('BE.1') == 'B.1.1.529.5.3.1.1'
58+
assert aliasor.uncompress('BE.1') == 'B.1.1.529.5.3.1.1'
59+
60+
def test_read_from_file(datadir):
61+
aliasor = Aliasor(datadir.join('alias_key.json'))
62+
assert aliasor.compress('B.1.1.529.1') == 'BA.1'

tests/test_aliasor/alias_key.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"A": "",
3+
"B": "",
4+
"C": "B.1.1.1",
5+
"D": "B.1.1.25",
6+
"G": "B.1.258.2",
7+
"K": "B.1.1.277",
8+
"L": "B.1.1.10",
9+
"M": "B.1.1.294",
10+
"N": "B.1.1.33",
11+
"P": "B.1.1.28",
12+
"Q": "B.1.1.7",
13+
"R": "B.1.1.316",
14+
"S": "B.1.1.217",
15+
"U": "B.1.177.60",
16+
"V": "B.1.177.54",
17+
"W": "B.1.177.53",
18+
"Y": "B.1.177.52",
19+
"Z": "B.1.177.50",
20+
"AA": "B.1.177.15",
21+
"AB": "B.1.160.16",
22+
"AC": "B.1.1.405",
23+
"AD": "B.1.1.315",
24+
"AE": "B.1.1.306",
25+
"AF": "B.1.1.305",
26+
"AG": "B.1.1.297",
27+
"AH": "B.1.1.241",
28+
"AJ": "B.1.1.240",
29+
"AK": "B.1.1.232",
30+
"AL": "B.1.1.231",
31+
"AM": "B.1.1.216",
32+
"AN": "B.1.1.200",
33+
"AP": "B.1.1.70",
34+
"AQ": "B.1.1.39",
35+
"AS": "B.1.1.317",
36+
"AT": "B.1.1.370",
37+
"AU": "B.1.466.2",
38+
"AV": "B.1.1.482",
39+
"AW": "B.1.1.464",
40+
"AY": "B.1.617.2",
41+
"AZ": "B.1.1.318",
42+
"BA": "B.1.1.529",
43+
"BB": "B.1.621.1",
44+
"BC": "B.1.1.529.1.1.1",
45+
"BD": "B.1.1.529.1.17.2",
46+
"BE": "B.1.1.529.5.3.1",
47+
"BF": "B.1.1.529.5.2.1",
48+
"BG": "B.1.1.529.2.12.1",
49+
"XA": ["B.1.1.7","B.1.177"],
50+
"XB": ["B.1.634","B.1.631"],
51+
"XC": ["AY.29","B.1.1.7"],
52+
"XD": ["B.1.617.2*","BA.1*"],
53+
"XE": ["BA.1*","BA.2*"],
54+
"XF": ["B.1.617.2*","BA.1*"],
55+
"XG": ["BA.1*","BA.2*"],
56+
"XH": ["BA.1*","BA.2*"],
57+
"XJ": ["BA.1*","BA.2*"],
58+
"XK": ["BA.1*","BA.2*"],
59+
"XL": ["BA.1*","BA.2*"],
60+
"XM": ["BA.1.1*","BA.2*"],
61+
"XN": ["BA.1*","BA.2*"],
62+
"XP": ["BA.1.1*","BA.2*"],
63+
"XQ": ["BA.1.1*","BA.2*"],
64+
"XR": ["BA.1.1*","BA.2*"],
65+
"XS": ["B.1.617.2*","BA.1.1*"],
66+
"XT": ["BA.2*","BA.1*"],
67+
"XU": ["BA.1*","BA.2*"],
68+
"XV": ["BA.1*","BA.2*"],
69+
"XW": ["BA.1*","BA.2*"],
70+
"XY": ["BA.1*","BA.2*"],
71+
"XZ": ["BA.2*","BA.1*"],
72+
"XAA": ["BA.1*","BA.2*"],
73+
"XAB": ["BA.1*","BA.2*"],
74+
"XAC": ["BA.2*","BA.1*","BA.2*"],
75+
"XAD": ["BA.2*","BA.1*"],
76+
"XAE": ["BA.2*","BA.1*"],
77+
"XAF": ["BA.1*","BA.2*"],
78+
"XAG": ["BA.1*","BA.2*"],
79+
"XAH": ["BA.2*","BA.1*"]
80+
}

0 commit comments

Comments
 (0)