import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'packages' / 'agromatrix-tools'))
import os
from agromatrix_tools import tool_spreadsheet


def test_create_and_read(tmp_path):
    path = tmp_path / "test.xlsx"
    spec = {"sheets": [{"name": "Data", "data": [["A", "B"], [1, 2]]}]}
    tool_spreadsheet.create_workbook(str(path), spec)
    result = tool_spreadsheet.read_range(str(path), "Data", "A1:B2")
    assert result["values"][0] == ["A", "B"]
