fix(versioning): align uuid-as-string assertions with UUIDMixin coercion

The ``@validates("uuid")`` coercion added in 46f138326b now ensures
``UUIDMixin.uuid`` always returns a ``uuid.UUID`` instance after
assignment, regardless of input type. This is the right semantic
(matches what ``UUIDType`` would emit on a fresh DB read) but it
broke three pre-existing tests that compared the attribute against
string literals — those assertions only passed before because the
post-INSERT refresh path either didn't run or ran inconsistently for
the model under test.

Update those three assertions to compare ``UUID`` to ``UUID`` so the
test contract matches the now-consistent attribute shape:

* ``test_import_database`` and ``test_import_database_no_creds`` —
  ``database.uuid`` now matches the coerced ``UUID`` literal.
* ``test_load_parquet_table_sets_uuid_on_new_table`` — ``tbl.uuid``
  same treatment.

Also harden the validator to pass non-UUID-shaped strings through
unchanged (instead of raising), so test mocks that use placeholder
strings like ``"dashboard-uuid-7"`` keep working — the SQL bind layer
will surface a clearer error if such a value is ever written to the
DB.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mike Bridge
2026-05-25 15:19:07 -06:00
parent 279d6a4484
commit 3314c2cd4b
3 changed files with 13 additions and 5 deletions

View File

@@ -16,6 +16,7 @@
# under the License.
"""Tests for generic_loader.py UUID threading functionality."""
import uuid
from unittest.mock import MagicMock, patch
@@ -54,7 +55,7 @@ def test_load_parquet_table_sets_uuid_on_new_table(mock_db, mock_get_db):
uuid=test_uuid,
)
assert tbl.uuid == test_uuid
assert tbl.uuid == uuid.UUID(test_uuid)
@patch("superset.examples.generic_loader.get_example_database")