2023-07-23 16:11:29 +02:00
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2023-07-23 16:20:28 +02:00
|
|
|
from conftest import convert
|
2023-07-23 16:11:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('id_song,err_msg', [
|
2023-07-23 17:23:51 +02:00
|
|
|
['basic_song', None],
|
2023-07-23 18:15:05 +02:00
|
|
|
['missing_score', None],
|
|
|
|
['missing_balloon', "Not enough values for 'BALLOON:"],
|
|
|
|
['missing_course', "Invalid COURSE value:"],
|
|
|
|
['missing_level', "Invalid LEVEL value:"]
|
2023-07-23 16:11:29 +02:00
|
|
|
])
|
|
|
|
def test_expected_errors(id_song, err_msg, tmp_path, entry_point):
|
|
|
|
# Define the testing directory
|
|
|
|
path_test = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
|
|
|
# Define the working directory
|
|
|
|
path_temp = os.path.join(tmp_path, id_song)
|
|
|
|
os.mkdir(path_temp)
|
|
|
|
|
|
|
|
# Copy input TJA to working directory
|
|
|
|
path_tja = os.path.join(path_test, "data", "dummy_tjas", f"{id_song}.tja")
|
|
|
|
path_tja_tmp = os.path.join(path_temp, f"{id_song}.tja")
|
|
|
|
shutil.copy(path_tja, path_tja_tmp)
|
|
|
|
|
|
|
|
# Try to convert TJA file to fumen files, then check the error traceback
|
2023-07-23 16:20:28 +02:00
|
|
|
tb = convert(path_test, path_tja_tmp, entry_point, err_msg)
|
2023-07-23 16:11:29 +02:00
|
|
|
if err_msg:
|
|
|
|
assert err_msg in tb
|
|
|
|
else:
|
|
|
|
assert tb == ''
|