plesna/tests/compute/test_consume_flux.py

44 lines
1.2 KiB
Python
Raw Normal View History

from plesna.compute.consume_flux import consume_flux
from plesna.models.flux import Flux
from plesna.models.storage import Table
from plesna.models.transformation import Transformation
def test_consume_flux():
sources = {
2025-01-03 14:56:29 +00:00
"src1": Table(
2025-01-04 20:33:05 +00:00
id="src1", repo_id="test", schema_id="test", name="test", value="here", datas=["d"]
2025-01-03 14:56:29 +00:00
),
"src2": Table(
2025-01-04 20:33:05 +00:00
id="src2", repo_id="test", schema_id="test", name="test", value="here", datas=["d"]
2025-01-03 14:56:29 +00:00
),
}
targets = {
2025-01-03 14:56:29 +00:00
"tgt1": Table(
2025-01-04 20:33:05 +00:00
id="tgt1", repo_id="test", schema_id="test", name="test", value="this", datas=["d"]
2025-01-03 14:56:29 +00:00
),
"tgt2": Table(
2025-01-04 20:33:05 +00:00
id="tgt2", repo_id="test", schema_id="test", name="test", value="that", datas=["d"]
2025-01-03 14:56:29 +00:00
),
}
def func(sources, targets, **kwrds):
return {
"sources": len(sources),
"targets": len(targets),
"kwrds": len(kwrds),
}
flux = Flux(
sources=sources,
targets=targets,
transformation=Transformation(function=func, extra_kwrds={"extra": "super"}),
)
meta = consume_flux(flux)
assert meta.data == {
"sources": 2,
"targets": 2,
"kwrds": 1,
}