-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from reclosedev/fix-lc-column-args
Fix LowCardinalityColumn keys column exception
- Loading branch information
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
|
||
from asynch.proto.columns import get_column_by_spec | ||
from asynch.proto.columns.lowcardinalitycolumn import LowCardinalityColumn | ||
from asynch.proto.columns.stringcolumn import String | ||
|
||
COLUMN_SPEC = "LowCardinality(String)" | ||
|
||
|
||
@pytest.fixture | ||
def low_cardinality_column(column_options): | ||
column = get_column_by_spec(COLUMN_SPEC, column_options) | ||
return column | ||
|
||
|
||
def test_create_lc_column(low_cardinality_column): | ||
assert isinstance(low_cardinality_column, LowCardinalityColumn) | ||
assert isinstance(low_cardinality_column.nested_column, String) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_lc_column_write_data(low_cardinality_column): | ||
await low_cardinality_column.write_data("") | ||
assert len(low_cardinality_column.writer.buffer) == 0 | ||
|
||
await low_cardinality_column.write_data(["1234567890"]) | ||
assert len(low_cardinality_column.writer.buffer) == 36 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_lc_column_read_data(low_cardinality_column, mocker): | ||
s = "1234567890" | ||
await low_cardinality_column.write_data([s]) | ||
mocker.patch.object( | ||
low_cardinality_column.reader.reader, | ||
"read", | ||
return_value=low_cardinality_column.writer.buffer, | ||
) | ||
resp = await low_cardinality_column.read_data(1) | ||
assert resp[0] == s |
File renamed without changes.
File renamed without changes.