-
-
Notifications
You must be signed in to change notification settings - Fork 64
/
test_legacy.py
163 lines (120 loc) · 5.15 KB
/
test_legacy.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
"""Legacy tests"""
import pytest
import os
import tscribe
def test_multiple_speakers():
"""
Test output exists with multiple speaker input
# GIVEN a sample file containing multiple speakers
# WHEN calling tscribe.write(...)
# THEN produce the .docx without errors
"""
# Setup
input_file = "sample_material/03-speaker-identification.json"
output_file = "sample_material/03-speaker-identification.docx"
assert os.access(input_file, os.F_OK), "Input file not found"
# Function
tscribe.write(input_file)
assert os.access(output_file, os.F_OK), "Output file not found"
# Teardown
os.remove(output_file)
os.remove("sample_material/chart.png")
def test_multiple_speakers_with_save_as():
"""
Test output exists with multiple speaker input, and save_as defined
# GIVEN a sample file containing multiple speakers, and an output filename
# WHEN calling tscribe.write(...)
# THEN produce the .docx, named correctly, without errors
"""
# Setup
input_file = "sample_material/03-speaker-identification.json"
output_file = "sample_material/test_sample.docx"
assert os.access(input_file, os.F_OK), "Input file not found"
# Function
tscribe.write(input_file, save_as=output_file)
assert os.access(output_file, os.F_OK), "Output file not found"
# Teardown
os.remove(output_file)
os.remove("sample_material/chart.png")
# SKIPPED - chart now writes to same directory as output through use of the Path parent
# This works on the assumption that if you have permission to write to the dir for the
# output docx, you should have permission to write an image to that dir too
# Therefore no need to explicitly specify where the chart is written to, seperate to the docx
@pytest.mark.xfail(reason="Deprecated")
def test_multiple_speakers_with_save_as_with_tmp_dir():
"""
Test output exists with multiple speaker input, and save_as defined, and tmp_dir defined
# GIVEN a sample file containing multiple speakers, and an output filename, and a writable tmp directory
# WHEN calling tscribe.write(...)
# THEN produce the .docx, with a chart, named correctly, without errors
"""
# Setup
input_file = "sample_multiple.json"
output_file = "test_sample.docx"
tmp_dir = "/tmp/"
assert os.access(input_file, os.F_OK), "Input file not found"
# Function
tscribe.write(input_file, save_as=output_file, tmp_dir=tmp_dir)
assert os.access(tmp_dir + "chart.png", os.F_OK), "Chart file not found"
assert os.access(output_file, os.F_OK), "Output file not found"
# Teardown
os.remove(output_file)
os.remove(tmp_dir + "chart.png")
def test_single_speaker():
"""
Test output exists with single speaker input
# GIVEN a sample file containing single speaker
# WHEN calling tscribe.write(...)
# THEN produce the .docx without errors
"""
# Setup
input_file = "sample_material/01-plain.json"
output_file = "sample_material/01-plain.docx"
assert os.access(input_file, os.F_OK), "Input file not found"
# Function
tscribe.write(input_file)
assert os.access(output_file, os.F_OK), "Output file not found"
# Teardown
os.remove(output_file)
os.remove("sample_material/chart.png")
def test_single_speaker_with_save_as():
"""
Test output exists with single speaker input, and save_as defined
# GIVEN a sample file containing single speaker, and an output filename
# WHEN calling tscribe.write(...)
# THEN produce the .docx, named correctly, without errors
"""
# Setup
input_file = "sample_material/01-plain.json"
output_file = "sample_material/test_sample.docx"
assert os.access(input_file, os.F_OK), "Input file not found"
# Function
tscribe.write(input_file, save_as=output_file)
assert os.access(output_file, os.F_OK), "Output file not found"
# Teardown
os.remove(output_file)
os.remove("sample_material/chart.png")
# SKIPPED - chart now writes to same directory as output through use of the Path parent
# This works on the assumption that if you have permission to write to the dir for the
# output docx, you should have permission to write an image to that dir too
# Therefore no need to explicitly specify where the chart is written to, seperate to the docx
@pytest.mark.xfail(reason="Deprecated")
def test_single_speaker_with_save_as_with_tmp_dir():
"""
Test output exists with single speaker input, and save_as defined, and tmp_dir defined
# GIVEN a sample file containing single speaker, and an output filename, and a writable tmp directory
# WHEN calling tscribe.write(...)
# THEN produce the .docx, with a chart, named correctly, without errors
"""
# Setup
input_file = "sample_single.json"
output_file = "test_sample.docx"
tmp_dir = "/tmp/"
assert os.access(input_file, os.F_OK), "Input file not found"
# Function
tscribe.write(input_file, save_as=output_file, tmp_dir=tmp_dir)
assert os.access(tmp_dir + "chart.png", os.F_OK), "Chart file not found"
assert os.access(output_file, os.F_OK), "Output file not found"
# Teardown
os.remove(output_file)
os.remove(tmp_dir + "chart.png")