-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_reconstruction.py
61 lines (50 loc) · 2.62 KB
/
test_reconstruction.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
from pathlib import Path
import pytest
from reconstruct_pub_wise import *
def get_paths():
opf_path = Path(f"./tests/data/opf/PB7EAF27B/PB7EAF27B.opf")
base_path = Path(f"{opf_path}/base/00001.txt")
layers = list(Path(f"{opf_path}/layers").iterdir())
for layer in layers:
durchen_path = Path(f"{layer}/Durchen.yml")
return durchen_path, base_path
def test_derge_dip():
parma = "derge"
durchen_path, base_path = get_paths()
durchen_layer = load_yaml(durchen_path)
base_text = base_path.read_text(encoding='utf-8')
diplomatic_durchen = get_diplomatic_durchen(durchen_layer, parma)
diplomatic_text = get_diplomatic_text(base_text, diplomatic_durchen, load_yaml(durchen_path))
desired_diplomatic_text = get_desired_text_format(diplomatic_text)
expected_text = Path(f'./tests/data/{parma_dic[parma]}/D007.txt').read_text(encoding='utf-8')
assert desired_diplomatic_text == expected_text
def test_peking_dip():
parma = "peking"
durchen_path, base_path = get_paths()
durchen_layer = load_yaml(durchen_path)
base_text = base_path.read_text(encoding='utf-8')
diplomatic_durchen = get_diplomatic_durchen(durchen_layer, parma)
diplomatic_text = get_diplomatic_text(base_text, diplomatic_durchen, load_yaml(durchen_path))
desired_diplomatic_text = get_desired_text_format(diplomatic_text)
expected_text = Path(f'./tests/data/{parma_dic[parma]}/D007.txt').read_text(encoding='utf-8')
assert desired_diplomatic_text == expected_text
def test_narthang_dip():
parma = "narthang"
durchen_path, base_path = get_paths()
durchen_layer = load_yaml(durchen_path)
base_text = base_path.read_text(encoding='utf-8')
diplomatic_durchen = get_diplomatic_durchen(durchen_layer, parma)
diplomatic_text = get_diplomatic_text(base_text, diplomatic_durchen, load_yaml(durchen_path))
desired_diplomatic_text = get_desired_text_format(diplomatic_text)
expected_text = Path(f'./tests/data/{parma_dic[parma]}/D007.txt').read_text(encoding='utf-8')
assert desired_diplomatic_text == expected_text
def test_chone_dip():
parma = "chone"
durchen_path, base_path = get_paths()
durchen_layer = load_yaml(durchen_path)
base_text = base_path.read_text(encoding='utf-8')
diplomatic_durchen = get_diplomatic_durchen(durchen_layer, parma)
diplomatic_text = get_diplomatic_text(base_text, diplomatic_durchen, load_yaml(durchen_path))
desired_diplomatic_text = get_desired_text_format(diplomatic_text)
expected_text = Path(f'./tests/data/{parma_dic[parma]}/D007.txt').read_text(encoding='utf-8')
assert desired_diplomatic_text == expected_text