Skip to content

Commit

Permalink
adjust table lifecycle tests to apiSupport being added by API
Browse files Browse the repository at this point in the history
  • Loading branch information
hemidactylus committed Dec 19, 2024
1 parent f01df72 commit 36fc42b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
26 changes: 22 additions & 4 deletions tests/base/integration/tables/test_table_lifecycle_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

import pytest

Expand Down Expand Up @@ -43,6 +43,21 @@
from astrapy import AsyncDatabase


def _remove_apisupport(def_dict: dict[str, Any]) -> dict[str, Any]:
"""
Strip apiSupport keys from columns since its presence
is != between sending and receiving.
"""

def _clean_col(col_dict: dict[str, Any]) -> dict[str, Any]:
return {k: v for k, v in col_dict.items() if k != "apiSupport"}

return {
k: v if k != "columns" else {colk: _clean_col(colv) for colk, colv in v.items()}
for k, v in def_dict.items()
}


class TestTableLifecycle:
@pytest.mark.describe("test of create/verify/delete tables, async")
async def test_table_basic_crd_async(
Expand Down Expand Up @@ -184,9 +199,11 @@ async def test_table_basic_crd_async(
)

# definition and info
atf_def = await atable_fluent.definition()
assert (
await atable_fluent.definition()
).as_dict() == table_whole_obj_definition.as_dict()
_remove_apisupport(atf_def.as_dict())
== table_whole_obj_definition.as_dict()
)
if IS_ASTRA_DB:
fl_info = await atable_fluent.info()
assert fl_info.name == "table_fluent"
Expand Down Expand Up @@ -382,6 +399,7 @@ async def test_alter_tableindex_async(
operation=AlterTableDropVectorize.coerce({"columns": ["p_vector"]})
)
# back to the original table:
assert (await atable.definition()).as_dict() == orig_table_def.as_dict()
adef = await atable.definition()
assert _remove_apisupport(adef.as_dict()) == orig_table_def.as_dict()
finally:
await atable.drop()
25 changes: 22 additions & 3 deletions tests/base/integration/tables/test_table_lifecycle_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

import pytest

Expand Down Expand Up @@ -43,6 +43,21 @@
from astrapy import Database


def _remove_apisupport(def_dict: dict[str, Any]) -> dict[str, Any]:
"""
Strip apiSupport keys from columns since its presence
is != between sending and receiving.
"""

def _clean_col(col_dict: dict[str, Any]) -> dict[str, Any]:
return {k: v for k, v in col_dict.items() if k != "apiSupport"}

return {
k: v if k != "columns" else {colk: _clean_col(colv) for colk, colv in v.items()}
for k, v in def_dict.items()
}


class TestTableLifecycle:
@pytest.mark.describe("test of create/verify/delete tables, sync")
def test_table_basic_crd_sync(
Expand Down Expand Up @@ -185,7 +200,8 @@ def test_table_basic_crd_sync(

# definition and info
assert (
table_fluent.definition().as_dict() == table_whole_obj_definition.as_dict()
_remove_apisupport(table_fluent.definition().as_dict())
== table_whole_obj_definition.as_dict()
)
if IS_ASTRA_DB:
fl_info = table_fluent.info()
Expand Down Expand Up @@ -382,6 +398,9 @@ def test_alter_tableindex_sync(
operation=AlterTableDropVectorize.coerce({"columns": ["p_vector"]})
)
# back to the original table:
assert table.definition().as_dict() == orig_table_def.as_dict()
assert (
_remove_apisupport(table.definition().as_dict())
== orig_table_def.as_dict()
)
finally:
table.drop()

0 comments on commit 36fc42b

Please sign in to comment.