31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
import pytest
|
|
|
|
from personal_data.fetchers.myanimelist import parse_name
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
'input_str, expected_group1, expected_group2',
|
|
[
|
|
('"Soundscape"', 'Soundscape', None),
|
|
('"Soundscape (サウンドスケープ)"', 'Soundscape', 'サウンドスケーブ'),
|
|
('1: "Soundscape"', 'Soundscape', None),
|
|
('2: "Soundscape (サウンドスケーブ)"', 'Soundscape', 'サウンドスケーブ'),
|
|
],
|
|
)
|
|
def test_parse_name(input_str, expected_group1, expected_group2):
|
|
m = parse_name(input_str)
|
|
assert m is not None, f'parse_name returned None for input: {input_str}'
|
|
actual_group1 = m.group(1).strip() if m.group(1) is not None else None
|
|
actual_group2 = m.group(2).strip() if m.group(2) is not None else None
|
|
assert actual_group1 == expected_group1, (
|
|
f'Expected group(1): {expected_group1} but got: {actual_group1}'
|
|
)
|
|
if expected_group2 is None:
|
|
assert actual_group2 is None, (
|
|
f'Expected group(2) to be None but got: {actual_group2}'
|
|
)
|
|
else:
|
|
assert actual_group2 == expected_group2, (
|
|
f'Expected group(2): {expected_group2} but got: {actual_group2}'
|
|
)
|