from pymasep.common.initializer import Initializer
from test.unit.mocks.game_mock import GameMock


def test_init_should_init():
    game = GameMock()

    initializer = Initializer(game, {'name': 'OneInitializer', 'value_type': "int"})

    assert initializer.name == 'OneInitializer'
    assert initializer.value_type == int


def test_init_with_sub_initializer_should_init():
    game = GameMock()

    game.add_initializer(Initializer(game, {'name': 'subinit1', 'value_type': "int"}))
    game.add_initializer(Initializer(game, {'name': 'subinit2', 'value_type': "str"}))

    initializer = Initializer(game, {'name': 'OneInitializer',
                                     'value_type': "dict",
                                     'subclass_initializer': {'subelement1': 'subinit1',
                                                              'subelement2': 'subinit2'}})

    assert initializer.subclass_initializer['subelement1'] == game.initializers['subinit1']
    assert initializer.subclass_initializer['subelement2'] == game.initializers['subinit2']
