File size: 2,345 Bytes
bb3fbf9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import numpy as np

from engine.models.card import MemberCard
from engine.models.enums import Group, Unit, ensure_group_list, ensure_unit_list

# --- Group Tests ---


def test_ensure_group_list_multiline():
    input_str = (
        "ラブライブ!虹ヶ咲学園スクールアイドル同好会\nラブライブ!スーパースター!!\n蓮ノ空女学院スクールアイドルクラブ"
    )
    groups = ensure_group_list(input_str)

    assert len(groups) == 3
    assert Group.NIJIGASAKI in groups
    assert Group.LIELLA in groups
    assert Group.HASUNOSORA in groups


def test_member_card_parsing_multiline():
    card = MemberCard(
        card_id=1,
        card_no="TEST-multi",
        name="Multi Group Card",
        cost=1,
        hearts=np.zeros(6),
        blade_hearts=np.zeros(7),
        blades=1,
        groups="ラブライブ!\nラブライブ!サンシャイン!!",  # type: ignore
    )

    assert len(card.groups) == 2
    assert Group.MUSE in card.groups
    assert Group.AQOURS in card.groups


# --- Unit Tests ---


def test_unit_enum_parsing():
    # Test specific requested mappings
    assert Unit.from_japanese_name("スリーズブーケ") == Unit.CERISE_BOUQUET
    assert Unit.from_japanese_name("みらくらぱーく!") == Unit.MIRA_CRA_PARK
    assert Unit.from_japanese_name("5yncri5e!") == Unit.SYNCRISE
    assert Unit.from_japanese_name("CYaRon!") == Unit.CYARON
    assert Unit.from_japanese_name("GuiltyKiss") == Unit.GUILTY_KISS
    assert Unit.from_japanese_name("EdelNote") == Unit.EDEL_NOTE

    # Test existing ones
    assert Unit.from_japanese_name("Printemps") == Unit.PRINTEMPS
    assert Unit.from_japanese_name("A・ZU・NA") == Unit.A_ZU_NA

    # Test unknown
    assert Unit.from_japanese_name("UnknownUnit") == Unit.OTHER


def test_ensure_unit_list():
    # Test multi-line
    input_str = "スリーズブーケ\nEdelNote"
    units = ensure_unit_list(input_str)
    assert len(units) == 2
    assert Unit.CERISE_BOUQUET in units
    assert Unit.EDEL_NOTE in units

    # Test list input
    input_list = ["GuiltyKiss", Unit.AZALEA]
    units_list = ensure_unit_list(input_list)
    assert len(units_list) == 2
    assert Unit.GUILTY_KISS in units_list
    assert Unit.AZALEA in units_list