Skip to content

Commit

Permalink
Add enumeration repr test
Browse files Browse the repository at this point in the history
  • Loading branch information
kounelisagis committed Mar 26, 2024
1 parent 6121a6a commit bd34cdb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tiledb/tests/test_enumeration.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

import numpy as np
import pytest
from numpy.testing import assert_array_equal
Expand Down Expand Up @@ -37,6 +39,27 @@ def test_attribute_enumeration(self):
attr.enum = "enum"
assert attr.enum == "enum"

def test_enumeration_repr(self):
"""Doesn't check exact string, just makes sure each component is matched, in case order is changed in the future."""
enmr = tiledb.Enumeration("e", False, [1, 2, 3])
# Get its string representation
repr_str = repr(enmr)

# Define patterns to match each component in the representation
patterns = {
"Enumeration": r"Enumeration",
"name": r"name='e'",
"dtype": r"dtype=int64",
"dtype_name": r"dtype_name='int64'",
"cell_val_num": r"cell_val_num=1",
"ordered": r"ordered=False",
"values": r"values=\[1, 2, 3\]",
}

# Check that each pattern is found in the representation string
for key, pattern in patterns.items():
assert re.search(pattern, repr_str), f"{key} not found or incorrect in repr"

def test_array_schema_enumeration(self):
uri = self.path("test_array_schema_enumeration")
dom = tiledb.Domain(tiledb.Dim(domain=(1, 8), tile=1))
Expand Down

0 comments on commit bd34cdb

Please sign in to comment.