Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase testing of generic types storage #282

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions tests/integration/test_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@


@dataclass
class Foo:
class Nested:
first: str
second: bool | None


@dataclass
class Nested:
foo: Foo
class NestedWithDict:
name: str
other: dict[str, str] | None


@dataclass
class Nesting:
nested: Nested
since: datetime.date
created: datetime.datetime
mapping: dict[str, int]
array: list[int]
int_array: list[int]
struct_array: list[NestedWithDict]


def test_appends_complex_types(ws, env_or_skip, make_random) -> None:
Expand All @@ -27,10 +34,10 @@ def test_appends_complex_types(ws, env_or_skip, make_random) -> None:
sql_backend.save_table(
full_name,
[
Nested(Foo("a", True), today, now, {"a": 1, "b": 2}, [1, 2, 3]),
Nested(Foo("b", False), today, now, {"c": 3, "d": 4}, [4, 5, 6]),
Nesting(Nested("a", True), today, now, {"a": 1, "b": 2}, [1, 2, 3], [NestedWithDict("s", {"f1": "v1", "f2": "v2"})]),
Nesting(Nested("b", False), today, now, {"c": 3, "d": 4}, [4, 5, 6], []),
],
Nested,
Nesting,
)
rows = list(sql_backend.fetch(f"SELECT * FROM {full_name}"))
assert len(rows) == 2
Loading