Spaces:
Running
Running
alessandro trinca tornidor
commited on
Commit
·
0c5bb13
1
Parent(s):
ad83407
test: fix the test execution on Windows
Browse files
README.md
CHANGED
@@ -92,6 +92,14 @@ Then execute the tests again:
|
|
92 |
pytest --cov=aip_trainer --cov-report=term-missing && coverage html
|
93 |
```
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
### E2E tests with playwright
|
96 |
|
97 |
Normally I use Visual Studio Code to write and execute my playwright tests, however it's always possible to run them from cli (from the `static` folder, using a node package manager like `npm` or `pnpm`):
|
|
|
92 |
pytest --cov=aip_trainer --cov-report=term-missing && coverage html
|
93 |
```
|
94 |
|
95 |
+
### Backend tests execution on Windows
|
96 |
+
|
97 |
+
On Windows the tests suite needs the env variable `PYTHONUTF8=1` to avoid an UnicodeDecodeError:
|
98 |
+
|
99 |
+
```cmd
|
100 |
+
PYTHONUTF8=1 pytest --cov=aip_trainer --cov-report=term-missing && coverage html
|
101 |
+
```
|
102 |
+
|
103 |
### E2E tests with playwright
|
104 |
|
105 |
Normally I use Visual Studio Code to write and execute my playwright tests, however it's always possible to run them from cli (from the `static` folder, using a node package manager like `npm` or `pnpm`):
|
aip_trainer/lambdas/lambdaSpeechToScore.py
CHANGED
@@ -208,10 +208,10 @@ def get_splitted_audio_file(audiotmpfile: str | Path, start_time: list[float], e
|
|
208 |
return audio_files, audio_durations
|
209 |
|
210 |
|
211 |
-
def get_file_with_custom_suffix(basefile: str | Path, custom_suffix: str) ->
|
212 |
pathname = Path(basefile)
|
213 |
dirname, filename_no_ext, filename_ext = pathname.parent, pathname.stem, pathname.suffix
|
214 |
-
output_file = dirname / f"{filename_no_ext}_{custom_suffix}.{filename_ext}"
|
215 |
return output_file
|
216 |
|
217 |
|
|
|
208 |
return audio_files, audio_durations
|
209 |
|
210 |
|
211 |
+
def get_file_with_custom_suffix(basefile: str | Path, custom_suffix: str) -> Path:
|
212 |
pathname = Path(basefile)
|
213 |
dirname, filename_no_ext, filename_ext = pathname.parent, pathname.stem, pathname.suffix
|
214 |
+
output_file = Path(dirname) / f"{filename_no_ext}_{custom_suffix}.{filename_ext}"
|
215 |
return output_file
|
216 |
|
217 |
|
tests/lambdas/constants_lambdaSpeechToScore.py
CHANGED
@@ -68,11 +68,11 @@ expected_get_speech_to_score = {
|
|
68 |
expected_with_audio_files_splitted_list = {
|
69 |
"de": {
|
70 |
"audio_files": [
|
71 |
-
f
|
72 |
-
f
|
73 |
-
f
|
74 |
-
f
|
75 |
-
f
|
76 |
],
|
77 |
"audio_durations": [
|
78 |
0.328,
|
@@ -95,11 +95,11 @@ expected_with_audio_files_splitted_list = {
|
|
95 |
},
|
96 |
"en": {
|
97 |
"audio_files": [
|
98 |
-
f
|
99 |
-
f
|
100 |
-
f
|
101 |
-
f
|
102 |
-
f
|
103 |
],
|
104 |
"audio_durations": [
|
105 |
0.3353125,
|
@@ -124,11 +124,11 @@ expected_with_audio_files_splitted_list = {
|
|
124 |
expected_with_selected_word_valid_index = {
|
125 |
"de": {
|
126 |
"audio_files": [
|
127 |
-
f
|
128 |
-
f
|
129 |
-
f
|
130 |
-
f
|
131 |
-
f
|
132 |
],
|
133 |
"audio_durations": [
|
134 |
0.4733125,
|
@@ -151,11 +151,11 @@ expected_with_selected_word_valid_index = {
|
|
151 |
},
|
152 |
"en": {
|
153 |
"audio_files": [
|
154 |
-
f
|
155 |
-
f
|
156 |
-
f
|
157 |
-
f
|
158 |
-
f
|
159 |
],
|
160 |
"audio_durations": [
|
161 |
0.1625,
|
|
|
68 |
expected_with_audio_files_splitted_list = {
|
69 |
"de": {
|
70 |
"audio_files": [
|
71 |
+
f'{EVENTS_FOLDER / "test_de__part0_start0.0_end0.328..wav"}',
|
72 |
+
f'{EVENTS_FOLDER / "test_de__part1_start0.3075_end0.6458125..wav"}',
|
73 |
+
f'{EVENTS_FOLDER / "test_de__part2_start1.5785625_end2.15525..wav"}',
|
74 |
+
f'{EVENTS_FOLDER / "test_de__part3_start2.1346875_end2.4730625..wav"}',
|
75 |
+
f'{EVENTS_FOLDER / "test_de__part4_start2.1346875_end2.4730625..wav"}',
|
76 |
],
|
77 |
"audio_durations": [
|
78 |
0.328,
|
|
|
95 |
},
|
96 |
"en": {
|
97 |
"audio_files": [
|
98 |
+
f'{EVENTS_FOLDER / "test_en__part0_start0.2245625_end0.559875..wav"}',
|
99 |
+
f'{EVENTS_FOLDER / "test_en__part1_start1.3228125_end1.658125..wav"}',
|
100 |
+
f'{EVENTS_FOLDER / "test_en__part2_start0.852125_end1.14825..wav"}',
|
101 |
+
f'{EVENTS_FOLDER / "test_en__part3_start1.04825_end1.344375..wav"}',
|
102 |
+
f'{EVENTS_FOLDER / "test_en__part4_start1.3228125_end1.658125..wav"}',
|
103 |
],
|
104 |
"audio_durations": [
|
105 |
0.3353125,
|
|
|
124 |
expected_with_selected_word_valid_index = {
|
125 |
"de": {
|
126 |
"audio_files": [
|
127 |
+
f'{EVENTS_FOLDER / "test_de_easy__part0_start0.0_end0.4733125..wav"}',
|
128 |
+
f'{EVENTS_FOLDER / "test_de_easy__part1_start0.3733125_end0.70425..wav"}',
|
129 |
+
f'{EVENTS_FOLDER / "test_de_easy__part2_start0.60425_end0.8966875..wav"}',
|
130 |
+
f'{EVENTS_FOLDER / "test_de_easy__part3_start0.7966875_end1.089125..wav"}',
|
131 |
+
f'{EVENTS_FOLDER / "test_de_easy__part4_start0.989125_end1.3200625..wav"}',
|
132 |
],
|
133 |
"audio_durations": [
|
134 |
0.4733125,
|
|
|
151 |
},
|
152 |
"en": {
|
153 |
"audio_files": [
|
154 |
+
f'{EVENTS_FOLDER / "test_en_easy__part0_start0.0_end0.1625..wav"}',
|
155 |
+
f'{EVENTS_FOLDER / "test_en_easy__part1_start0.0625_end0.3875..wav"}',
|
156 |
+
f'{EVENTS_FOLDER / "test_en_easy__part2_start0.2875_end0.575..wav"}',
|
157 |
+
f'{EVENTS_FOLDER / "test_en_easy__part3_start0.475_end0.8..wav"}',
|
158 |
+
f'{EVENTS_FOLDER / "test_en_easy__part4_start0.7_end0.9875..wav"}',
|
159 |
],
|
160 |
"audio_durations": [
|
161 |
0.1625,
|
tests/lambdas/test_lambdaTTS.py
CHANGED
@@ -39,18 +39,32 @@ def assert_raises_get_tts(
|
|
39 |
|
40 |
class TestLambdaTTS(unittest.TestCase):
|
41 |
def test_lambdaTTS_en_ok(self):
|
42 |
-
|
|
|
43 |
"Hi there, how are you?",
|
44 |
"en",
|
45 |
b'6rZkDkF/Jc/7S5aTBlyNvntMng1+N81Flndx3WM5U0g='
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
def test_lambdaTTS_de_ok(self):
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
def test_lambdaTTS_empty_text(self):
|
56 |
assert_raises_get_tts(self, "", "fake language", ValueError, "cannot read an empty/None text: ''...")
|
|
|
39 |
|
40 |
class TestLambdaTTS(unittest.TestCase):
|
41 |
def test_lambdaTTS_en_ok(self):
|
42 |
+
try:
|
43 |
+
exec_test_lambda_tts(
|
44 |
"Hi there, how are you?",
|
45 |
"en",
|
46 |
b'6rZkDkF/Jc/7S5aTBlyNvntMng1+N81Flndx3WM5U0g='
|
47 |
+
)
|
48 |
+
except AssertionError:
|
49 |
+
exec_test_lambda_tts(
|
50 |
+
"Hi there, how are you?",
|
51 |
+
"en",
|
52 |
+
b'S7ADQbzBhmtBhYy1lLTQysv9ScAy2A0WUhG3RtWwvws='
|
53 |
+
)
|
54 |
|
55 |
def test_lambdaTTS_de_ok(self):
|
56 |
+
try:
|
57 |
+
exec_test_lambda_tts(
|
58 |
+
"Ich bin Alex!",
|
59 |
+
"de",
|
60 |
+
b'4CCWiz7DOOHSmyYcS8KTBvk2E3zHtaX5umtksVln5VA='
|
61 |
+
)
|
62 |
+
except AssertionError:
|
63 |
+
exec_test_lambda_tts(
|
64 |
+
"Ich bin Alex!",
|
65 |
+
"de",
|
66 |
+
b'vNsDzs4ULJI2Ml0qyIrVaegI+7jK79btoq+O5FjuMEo='
|
67 |
+
)
|
68 |
|
69 |
def test_lambdaTTS_empty_text(self):
|
70 |
assert_raises_get_tts(self, "", "fake language", ValueError, "cannot read an empty/None text: ''...")
|
tests/utils/test_split_cosmic_ray_report.py
CHANGED
@@ -17,7 +17,10 @@ class TestSplitCosmicRayReport(unittest.TestCase):
|
|
17 |
|
18 |
# Verify the filtered content
|
19 |
hash_output = utilities.hash_calculate(output_filename, True)
|
20 |
-
|
|
|
|
|
|
|
21 |
|
22 |
output_filename.unlink(missing_ok=False)
|
23 |
|
@@ -33,7 +36,10 @@ class TestSplitCosmicRayReport(unittest.TestCase):
|
|
33 |
|
34 |
# Verify the filtered content
|
35 |
hash_output = utilities.hash_calculate(output_filename, True)
|
36 |
-
|
|
|
|
|
|
|
37 |
|
38 |
output_filename.unlink(missing_ok=False)
|
39 |
|
|
|
17 |
|
18 |
# Verify the filtered content
|
19 |
hash_output = utilities.hash_calculate(output_filename, True)
|
20 |
+
try:
|
21 |
+
self.assertEqual(hash_output, b'HqzO5Hq50Z1CIz/8rGE8Hpt4wSRM5Xm86pv+9FOYbUg=')
|
22 |
+
except AssertionError:
|
23 |
+
self.assertEqual(hash_output, b'KAEGrZdO8cY9sXoKYQFtsc4FF/tLavzDJbqO5+pyCSw=')
|
24 |
|
25 |
output_filename.unlink(missing_ok=False)
|
26 |
|
|
|
36 |
|
37 |
# Verify the filtered content
|
38 |
hash_output = utilities.hash_calculate(output_filename, True)
|
39 |
+
try:
|
40 |
+
self.assertEqual(hash_output, b'Fk0KDWCbc8mPoZllQ7HfgMjuWQVvUdNl+eR56eJeSxg=')
|
41 |
+
except AssertionError:
|
42 |
+
self.assertEqual(hash_output, b'1s0Gvw4Y972Gkw/oojf69rXK3CVlPfKjATGJ14WzFw8=')
|
43 |
|
44 |
output_filename.unlink(missing_ok=False)
|
45 |
|