From b7e99bc9815fc5b52586f64f568d4993660e6db4 Mon Sep 17 00:00:00 2001 From: Ethan Ho <53266718+ethho@users.noreply.github.com> Date: Sun, 22 Sep 2024 14:02:17 -0500 Subject: [PATCH] Rename enable_hidden_attributes to add_hidden_timestamp sed -i 's/enable_hidden_attributes/add_hidden_timestamp/g' ./**/*.py --- datajoint/declare.py | 2 +- datajoint/settings.py | 2 +- tests/test_declare.py | 40 +++++++++++++++------------------------- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/datajoint/declare.py b/datajoint/declare.py index d813374a..b1194880 100644 --- a/datajoint/declare.py +++ b/datajoint/declare.py @@ -312,7 +312,7 @@ def declare(full_table_name, definition, context): external_stores, ) = prepare_declare(definition, context) - if config.get("enable_hidden_attributes", False): + if config.get("add_hidden_timestamp", False): metadata_attr_sql = [ "`_{full_table_name}_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" ] diff --git a/datajoint/settings.py b/datajoint/settings.py index e1779859..cdf27891 100644 --- a/datajoint/settings.py +++ b/datajoint/settings.py @@ -47,7 +47,7 @@ "display.show_tuple_count": True, "database.use_tls": None, "enable_python_native_blobs": True, # python-native/dj0 encoding support - "enable_hidden_attributes": False, + "add_hidden_timestamp": False, "filepath_checksum_size_limit": None, # file size limit for when to disable checksums } ) diff --git a/tests/test_declare.py b/tests/test_declare.py index dc60deb9..1b186778 100644 --- a/tests/test_declare.py +++ b/tests/test_declare.py @@ -7,21 +7,21 @@ @pytest.fixture(scope="function") -def enable_hidden_attributes(): - orig_config_val = config.get("enable_hidden_attributes") - config["enable_hidden_attributes"] = True +def enable_add_hidden_timestamp(): + orig_config_val = config.get("add_hidden_timestamp") + config["add_hidden_timestamp"] = True yield if orig_config_val is not None: - config["enable_hidden_attributes"] = orig_config_val + config["add_hidden_timestamp"] = orig_config_val @pytest.fixture(scope="function") -def disable_hidden_attributes(): - orig_config_val = config.get("enable_hidden_attributes") - config["enable_hidden_attributes"] = False +def disable_add_hidden_timestamp(): + orig_config_val = config.get("add_hidden_timestamp") + config["add_hidden_timestamp"] = False yield if orig_config_val is not None: - config["enable_hidden_attributes"] = orig_config_val + config["add_hidden_timestamp"] = orig_config_val def test_schema_decorator(schema_any): @@ -392,17 +392,15 @@ class Table_With_Underscores(dj.Manual): schema_any(Table_With_Underscores) -def test_hidden_attributes_default_value(): - config_val = config.get("enable_hidden_attributes") +def test_add_hidden_timestamp_default_value(): + config_val = config.get("add_hidden_timestamp") assert ( config_val is not None and not config_val - ), "Default value for enable_hidden_attributes is not False" + ), "Default value for add_hidden_timestamp is not False" -def test_hidden_attributes_enabled(enable_hidden_attributes, schema_any): - orig_config_val = config.get("enable_hidden_attributes") - config["enable_hidden_attributes"] = True - +def test_add_hidden_timestamp_enabled(enable_add_hidden_timestamp, schema_any): + assert config["add_hidden_timestamp"], "add_hidden_timestamp is not enabled" msg = f"{Experiment().heading._attributes=}" assert any( a.name.endswith("_timestamp") for a in Experiment().heading._attributes.values() @@ -413,14 +411,9 @@ def test_hidden_attributes_enabled(enable_hidden_attributes, schema_any): assert any(a.is_hidden for a in Experiment().heading._attributes.values()), msg assert not any(a.is_hidden for a in Experiment().heading.attributes.values()), msg - if orig_config_val is not None: - config["enable_hidden_attributes"] = orig_config_val - - -def test_hidden_attributes_disabled(disable_hidden_attributes, schema_any): - orig_config_val = config.get("enable_hidden_attributes") - config["enable_hidden_attributes"] = False +def test_add_hidden_timestamp_disabled(disable_add_hidden_timestamp, schema_any): + assert not config["add_hidden_timestamp"], "expected add_hidden_timestamp to be False" msg = f"{Experiment().heading._attributes=}" assert not any( a.name.endswith("_timestamp") for a in Experiment().heading._attributes.values() @@ -430,6 +423,3 @@ def test_hidden_attributes_disabled(disable_hidden_attributes, schema_any): ), msg assert not any(a.is_hidden for a in Experiment().heading._attributes.values()), msg assert not any(a.is_hidden for a in Experiment().heading.attributes.values()), msg - - if orig_config_val is not None: - config["enable_hidden_attributes"] = orig_config_val