#  Copyright (c) 2025  Jeffrey Hsu - JITToolBox
#  #
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#  #
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  #
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <https://www.gnu.org/licenses/>.
from toolbox.models.config import AESConfig, SingleExcelConfigItem, RangeExcelConfigItem
from toolbox.tests import TEST_FILE_PATH


def test_config_model():
    aesc = AESConfig(TEST_FILE_PATH / 'test_config_model_01.json')

    a = aesc.get_config('A')
    assert isinstance(a, SingleExcelConfigItem)
    assert a.position == 'H1'

    b = aesc.get_config('B')
    assert isinstance(b, SingleExcelConfigItem)
    assert b.position == 'D10'

    c = aesc.get_config('C')
    assert isinstance(c, RangeExcelConfigItem)
    assert c.position == 'K'
    assert c.fposition.format(1) == 'K1'
    assert c.start == 2
    assert c.end == 5

    d = aesc.get_config('D')
    assert isinstance(d, RangeExcelConfigItem)
    assert d.position == 'Q'
    assert d.fposition.format(d.start) == 'Q22'
    assert d.end is None
