diff --git a/taipy/core/config/data_node_config.py b/taipy/core/config/data_node_config.py index 540d55bf53..c451c7baca 100644 --- a/taipy/core/config/data_node_config.py +++ b/taipy/core/config/data_node_config.py @@ -11,7 +11,7 @@ import json from copy import copy -from datetime import timedelta, datetime +from datetime import datetime, timedelta from typing import Any, Callable, Dict, List, Optional, Union import numpy @@ -41,7 +41,7 @@ class DataNodeConfig(Section): """ name = "DATA_NODE" - _ALL_TYPES = (str, int, float, bool, list, dict, tuple, set, type(None), callable, datetime, timedelta) + _ALL_TYPES = (str, int, float, bool, list, dict, tuple, set, type(None), type(callable), datetime, timedelta) _STORAGE_TYPE_KEY = "storage_type" _STORAGE_TYPE_VALUE_PICKLE = "pickle" _STORAGE_TYPE_VALUE_SQL_TABLE = "sql_table" diff --git a/tests/core/config/checkers/test_data_node_config_checker.py b/tests/core/config/checkers/test_data_node_config_checker.py index e6a669ed0a..84d5a47251 100644 --- a/tests/core/config/checkers/test_data_node_config_checker.py +++ b/tests/core/config/checkers/test_data_node_config_checker.py @@ -10,7 +10,7 @@ # specific language governing permissions and limitations under the License. from copy import copy -from datetime import timedelta +from datetime import datetime, timedelta import pytest @@ -710,3 +710,67 @@ def test_check_exposed_types(self, caplog): config._sections[DataNodeConfig.name]["default"].properties = {"exposed_type": MyCustomClass} Config.check() assert len(Config._collector.errors) == 0 + + def test_check_property_types(self, caplog): + config = Config._applied_config + Config._compile_configs() + config._sections[DataNodeConfig.name]["default"].storage_type = "pickle" + config._sections[DataNodeConfig.name]["default"].properties = {"default_data": "string"} + Config._collector = IssueCollector() + Config.check() + assert len(Config._collector.errors) == 0 + + config._sections[DataNodeConfig.name]["default"].properties = {"default_data": 1} + Config._collector = IssueCollector() + Config.check() + assert len(Config._collector.errors) == 0 + + config._sections[DataNodeConfig.name]["default"].properties = {"default_data": 1.} + Config._collector = IssueCollector() + Config.check() + assert len(Config._collector.errors) == 0 + + config._sections[DataNodeConfig.name]["default"].properties = {"default_data": True} + Config._collector = IssueCollector() + Config.check() + assert len(Config._collector.errors) == 0 + + config._sections[DataNodeConfig.name]["default"].properties = {"default_data": ["foo", "bar"]} + Config._collector = IssueCollector() + Config.check() + assert len(Config._collector.errors) == 0 + + config._sections[DataNodeConfig.name]["default"].properties = {"default_data": ("foo", "bar")} + Config._collector = IssueCollector() + Config.check() + assert len(Config._collector.errors) == 0 + + config._sections[DataNodeConfig.name]["default"].properties = {"default_data": {"foo": "bar"}} + Config._collector = IssueCollector() + Config.check() + assert len(Config._collector.errors) == 0 + + config._sections[DataNodeConfig.name]["default"].properties = {"default_data": {"foo", "bar"}} + Config._collector = IssueCollector() + Config.check() + assert len(Config._collector.errors) == 0 + + config._sections[DataNodeConfig.name]["default"].properties = {"default_data": None} + Config._collector = IssueCollector() + Config.check() + assert len(Config._collector.errors) == 0 + + config._sections[DataNodeConfig.name]["default"].properties = {"default_data": print} + Config._collector = IssueCollector() + Config.check() + assert len(Config._collector.errors) == 0 + + config._sections[DataNodeConfig.name]["default"].properties = {"default_data": datetime(2021, 7, 26)} + Config._collector = IssueCollector() + Config.check() + assert len(Config._collector.errors) == 0 + + config._sections[DataNodeConfig.name]["default"].properties = {"default_data": timedelta(7)} + Config._collector = IssueCollector() + Config.check() + assert len(Config._collector.errors) == 0