Skip to content

Commit

Permalink
Test mixing tables and arrays.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielballan committed Feb 24, 2024
1 parent 517a633 commit 5a767c6
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tiled/_tests/test_writing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from ..client import Context, from_context, record_history
from ..queries import Key
from ..server.app import build_app
from ..structures.array import ArrayStructure
from ..structures.core import Spec, StructureFamily
from ..structures.data_source import DataSource
from ..structures.sparse import COOStructure
Expand Down Expand Up @@ -509,3 +510,63 @@ def test_union_two_tables_colliding_keys(tree):
],
key="x",
)


def test_union_two_tables_two_arrays(tree):
with Context.from_app(build_app(tree)) as context:
client = from_context(context)
df1 = pandas.DataFrame({"A": [], "B": []})
df2 = pandas.DataFrame({"C": [], "D": [], "E": []})
arr1 = numpy.array([], dtype=numpy.float64)
arr2 = numpy.array([], dtype=numpy.int8)
structure1 = TableStructure.from_pandas(df1)
structure2 = TableStructure.from_pandas(df2)
structure3 = ArrayStructure.from_array(arr1)
structure4 = ArrayStructure.from_array(arr2)
client.create_union(
[
DataSource(
structure_family=StructureFamily.table,
structure=structure1,
),
DataSource(
structure_family=StructureFamily.table,
structure=structure2,
),
DataSource(
structure_family=StructureFamily.array,
structure=structure3,
key="F",
),
DataSource(
structure_family=StructureFamily.array,
structure=structure4,
key="G",
),
],
key="x",
)


def test_union_table_column_array_key_collision(tree):
with Context.from_app(build_app(tree)) as context:
client = from_context(context)
df = pandas.DataFrame({"A": [], "B": []})
arr = numpy.array([], dtype=numpy.float64)
structure1 = TableStructure.from_pandas(df)
structure2 = ArrayStructure.from_array(arr)
with fail_with_status_code(422):
client.create_union(
[
DataSource(
structure_family=StructureFamily.table,
structure=structure1,
),
DataSource(
structure_family=StructureFamily.array,
structure=structure2,
key="B",
),
],
key="x",
)

0 comments on commit 5a767c6

Please sign in to comment.