def test_step_row_slice_with_start_and_step(): source = Resource("data/transform.csv") target = transform( source, steps=[ steps.row_slice(start=1, stop=3, step=2), ], ) assert target.schema == { "fields": [ { "name": "id", "type": "integer" }, { "name": "name", "type": "string" }, { "name": "population", "type": "integer" }, ] } assert target.read_rows() == [ { "id": 2, "name": "france", "population": 66 }, ]
def test_step_row_slice_with_start_and_step(): source = Resource(path="data/transform.csv") source.infer() target = transform( source, steps=[ steps.row_slice(start=1, stop=3, step=2), ], ) assert target.schema == source.schema assert target.read_rows() == [ {"id": 2, "name": "france", "population": 66}, ]
def test_step_row_slice_with_tail(): source = Resource(path="data/transform.csv") source.infer() target = transform( source, steps=[ steps.row_slice(tail=2), ], ) assert target.schema == source.schema assert target.read_rows() == [ {"id": 2, "name": "france", "population": 66}, {"id": 3, "name": "spain", "population": 47}, ]
def test_step_row_slice_with_head(): source = Resource(path="data/transform.csv") source.infer() target = transform( source, steps=[ steps.row_slice(head=2), ], ) assert target.schema == source.schema assert target.read_rows() == [ {"id": 1, "name": "germany", "population": 83}, {"id": 2, "name": "france", "population": 66}, ]