def test_assumption_spec_deref(): assumption = {"name": "<<A1>>", "label": "something"} workbook = openpyxl.Workbook() sheet = workbook.active sheet['A1'] = 'hello' dereferator = Dereferator.template_to_spec(workbook=workbook, anchor=CellLocation( sheet.title, 'A2')) assumption_spec = AssumptionSpec.from_dict(assumption).deref(dereferator) assert assumption_spec.name == 'hello'
def test_deref_recursive(): wb = openpyxl.Workbook() sheet = wb.active for i in range(10): sheet.cell(i + 1, 1).value = i + 1 dereferator = Dereferator.template_to_spec(workbook=wb, anchor=CellLocation( sheet_name=sheet.title, coordinate='A1')) assert dereferator.deref(['a', '<<A2>>']) == ['a', 2]
def test_deref_pre_spec(workbook): dereferator = Dereferator.template_to_spec(workbook, CellLocation('SHEET1', 'A5')) assert dereferator.deref_text('<<A1>>') == 1 assert dereferator.deref_text('<<A2>> world') == 'hello world' assert dereferator.deref_text('the value is <<A1>>') == 'the value is 1'