Skip to content

Commit

Permalink
fix wrong typing
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinAV committed Jan 13, 2025
1 parent 349b047 commit e7f370f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
2 changes: 1 addition & 1 deletion taipy/core/config/data_node_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
66 changes: 65 additions & 1 deletion tests/core/config/checkers/test_data_node_config_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# specific language governing permissions and limitations under the License.

from copy import copy
from datetime import timedelta
from datetime import timedelta, datetime

import pytest

Expand Down Expand Up @@ -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

0 comments on commit e7f370f

Please sign in to comment.