Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/_data/** filter=lfs diff=lfs merge=lfs -text
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ __pycache__/
.pytest_cache/

flow/record/version.py
tests/docs/api
tests/docs/build
tests/_docs/api
tests/_docs/build
.tox/
File renamed without changes.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ select = [
ignore = ["E203", "B904", "UP024", "ANN002", "ANN003", "ANN204", "ANN401", "SIM105", "TRY003", "TRY400"]

[tool.ruff.lint.per-file-ignores]
"tests/docs/**" = ["INP001"]
"tests/_docs/**" = ["INP001"]

[tool.ruff.lint.isort]
known-first-party = ["flow.record"]
Expand Down
Empty file added tests/_data/.gitkeep
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added tests/adapter/__init__.py
Empty file.
51 changes: 50 additions & 1 deletion tests/test_avro.py → tests/adapter/test_avro.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

import pytest

from flow.record import RecordDescriptor, RecordReader
from flow.record import RecordDescriptor, RecordReader, RecordWriter
from flow.record.adapter.avro import AvroReader, AvroWriter
from flow.record.base import HAS_AVRO
from tests._utils import generate_plain_records

if TYPE_CHECKING:
from collections.abc import Iterator
Expand Down Expand Up @@ -68,3 +69,51 @@ def test_avrostream_filelike_object(tmp_path: Path) -> None:
assert rec.name == f"record{index}"
assert rec.foo == "bar"
assert rec.bar == "baz"


def test_avro_adapter(tmpdir: Path) -> None:
json_file = tmpdir.join("records.avro")
record_adapter_path = f"avro://{json_file}"
writer = RecordWriter(record_adapter_path)
nr_records = 1337

for record in generate_plain_records(nr_records):
writer.write(record)
writer.flush()

nr_received_records = 0
reader = RecordReader(record_adapter_path)
for _ in reader:
nr_received_records += 1

assert nr_records == nr_received_records


def test_avro_adapter_contextmanager(tmpdir: Path) -> None:
json_file = tmpdir.join("records.avro")
record_adapter_path = f"avro://{json_file}"
with RecordWriter(record_adapter_path) as writer:
nr_records = 1337
for record in generate_plain_records(nr_records):
writer.write(record)

nr_received_records = 0
with RecordReader(record_adapter_path) as reader:
for _ in reader:
nr_received_records += 1

assert nr_records == nr_received_records


def test_avro_adapter_empty(tmpdir: Path) -> None:
json_file = tmpdir.join("records.avro")
record_adapter_path = f"avro://{json_file}"
with RecordWriter(record_adapter_path):
pass

nr_received_records = 0
with RecordReader(record_adapter_path) as reader:
for _ in reader:
nr_received_records += 1

assert nr_received_records == 0
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import pytest

from flow.record import RecordReader, RecordWriter

from ._utils import generate_records
from tests._utils import generate_records

if TYPE_CHECKING:
from pathlib import Path
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added tests/fieldtypes/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
Empty file added tests/packer/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
Empty file added tests/record/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
ZSTD_MAGIC,
)
from flow.record.selector import CompiledSelector, Selector

from ._utils import generate_records
from tests._utils import generate_records

if TYPE_CHECKING:
from pathlib import Path
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added tests/selector/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
19 changes: 0 additions & 19 deletions tests/standalone_test.py

This file was deleted.

58 changes: 0 additions & 58 deletions tests/test_avro_adapter.py

This file was deleted.

File renamed without changes.
Empty file added tests/tools/__init__.py
Empty file.
File renamed without changes.
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ deps =
sphinx-design
furo
commands =
make -C tests/docs clean
make -C tests/docs html
make -C tests/_docs clean
make -C tests/_docs html

[testenv:docs-linkcheck]
allowlist_externals = make
deps = {[testenv:docs-build]deps}
commands =
make -C tests/docs clean
make -C tests/docs linkcheck
make -C tests/_docs clean
make -C tests/_docs linkcheck
Loading