Team Ai
Modelpublic

spreadsheethurts/backend

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
test_excel.py60 linesDownload Raw Back to software
1from pathlib import Path2from datetime import date3 4import pandas as pd5import pytest6 7from wizard.cell import Cell8from wizard.software.excel import Excel9 10 11@pytest.fixture(scope="session")12def dummy_excel():13    return Excel("host", "port", Path("/tmp"), "single")14 15 16def assert_type(series: pd.Series, type: str):17    for index, value in series.items():18        if index == type:19            assert value20        else:21            assert not value22 23 24def test_encode_type(dummy_excel: Excel):25    integer = Cell(value=1)26    error = Cell(value="#DIV/0!")27    text = Cell(value="hello world")28    datetime = Cell(value=date.today())29    bool = Cell(value=True)30 31    assert_type(dummy_excel.encode_type(integer), "number")32    assert_type(dummy_excel.encode_type(error), "error")33    assert_type(dummy_excel.encode_type(text), "text")34    assert_type(dummy_excel.encode_type(datetime), "datetime")35    assert_type(dummy_excel.encode_type(bool), "bool")36 37 38def test_is_encoding_eq(dummy_excel: Excel):39    integer = dummy_excel.encode_type(Cell(value=1))40    float = dummy_excel.encode_type(Cell(value=1.0))41    datetime = dummy_excel.encode_type(Cell(value=date.today()))42    assert dummy_excel.is_encoding_eq(integer, float)43    assert dummy_excel.is_encoding_eq(integer, datetime)44 45    error1 = dummy_excel.encode_type(Cell(value="#DIV/0!"))46    error2 = dummy_excel.encode_type(Cell(value="#NAME?"))47    assert dummy_excel.is_encoding_eq(error1, error2)48 49    string1 = dummy_excel.encode_type(Cell(value="hello world"))50    string2 = dummy_excel.encode_type(Cell(value="Hello World"))51    assert dummy_excel.is_encoding_eq(string1, string2)52 53    true = dummy_excel.encode_type(Cell(value=True))54    false = dummy_excel.encode_type(Cell(value=False))55    assert dummy_excel.is_encoding_eq(true, false)56 57    assert not dummy_excel.is_encoding_eq(integer, error1)58    assert not dummy_excel.is_encoding_eq(datetime, string1)59    assert not dummy_excel.is_encoding_eq(true, error1)60