# Path: magnate/savegame/base_types.py
# def type_name(value):
# def _generic_types_validator(type_enum, value):
# def load_base_types(datadir):
# def init_base_types(datadir):
# DATA_TYPES_SCHEMA = v.Schema({'version': '0.1',
#                               'types': {type_name: [str]}, },
#                              required=True)


import enum
import re
import pytest
from unittest.mock import mock_open, patch
from voluptuous.error import Error as VError
from magnate.savegame import base_types


INVALID_DATA = (
        ('''{version: "1.0", types: {CommodityType: []}}''', VError,
            ("not a valid value for dictionary value @ data\\['version']. Got '1.0'",)),
        ('''{version: "0.1", tpyes: {}}''', VError,
            ("extra keys not allowed @ data\\['tpyes']",
             "required key not provided @ data\\['types']")),
        ('''{version: "0.1", types: []}''', VError,
            ("expected a dictionary for dictionary value @ data\\['types']",)),
        ('''{version: "0.1", types: {10: []}}''', VError,
            ("extra keys not allowed @ data\\['types']\\[10]",)),
        ('''{version: "0.1", types: {Commodity: []}}''', VError,
            ("extra keys not allowed @ data\\['types']\\['Commodity']",)),
        ('''{version: "0.1", types: {commodityType: []}}''', VError,
            ("extra keys not allowed @ data\\['types']\\['commodityType']",)),
        )


@pytest.fixture
def test_type(clean_context):
    data = """---
    version: "0.1"
    types:
      TestType:
        - test_one
        - test_two
    """

    with patch('builtins.open', mock_open(read_data=data)):

# Path: magnate/savegame/base_types.py
# def type_name(value):
# def _generic_types_validator(type_enum, value):
# def load_base_types(datadir):
# def init_base_types(datadir):
# DATA_TYPES_SCHEMA = v.Schema({'version': '0.1',
#                               'types': {type_name: [str]}, },
#                              required=True)


# Path: tests/units/savegame/test_base_types.py
import enum
import re
import pytest
from unittest.mock import mock_open, patch
from voluptuous.error import Error as VError
from magnate.savegame import base_types



INVALID_DATA = (
        ('''{version: "1.0", types: {CommodityType: []}}''', VError,
            ("not a valid value for dictionary value @ data\\['version']. Got '1.0'",)),
        ('''{version: "0.1", tpyes: {}}''', VError,
            ("extra keys not allowed @ data\\['tpyes']",
             "required key not provided @ data\\['types']")),
        ('''{version: "0.1", types: []}''', VError,
            ("expected a dictionary for dictionary value @ data\\['types']",)),
        ('''{version: "0.1", types: {10: []}}''', VError,
            ("extra keys not allowed @ data\\['types']\\[10]",)),
        ('''{version: "0.1", types: {Commodity: []}}''', VError,
            ("extra keys not allowed @ data\\['types']\\['Commodity']",)),
        ('''{version: "0.1", types: {commodityType: []}}''', VError,
            ("extra keys not allowed @ data\\['types']\\['commodityType']",)),
        )


@pytest.fixture
def test_type(clean_context):
    data = """---
    version: "0.1"
    types:
      TestType:
        - test_one
        - test_two
    """

    with patch('builtins.open', mock_open(read_data=data)):

        base_types.init_base_types("123")