def ser_name_ref_fixture(self, request, series_data_, categories_): cat_depth, series_index, expected_value = request.param workbook_writer = CategoryWorkbookWriter(None) series_data_.categories = categories_ categories_.depth = cat_depth series_data_.index = series_index return workbook_writer, series_data_, expected_value
def populate_fixture(self, request, chart_data_, workbook_, worksheet_, categories_): levels, cat_call_args, ser_data, ser_call_args = request.param workbook_writer = CategoryWorkbookWriter(chart_data_) sers = [] for idx, (name, values) in enumerate(ser_data): ser = instance_mock(request, CategorySeriesData, index=idx, values=values) ser.name = name sers.append(ser) expected_calls = [call.write(*args) for args in cat_call_args] for name_args, col_args in ser_call_args: expected_calls.extend( [call.write(*name_args), call.write_column(*col_args)]) chart_data_.categories = categories_ categories_.depth = len(levels) categories_.levels = levels chart_data_.__iter__.return_value = iter(sers) return workbook_writer, workbook_, worksheet_, expected_calls
def values_ref_fixture(self, request, series_data_, categories_): cat_depth, ser_idx, val_count, expected_value = request.param workbook_writer = CategoryWorkbookWriter(None) series_data_.categories = categories_ categories_.depth = cat_depth series_data_.index = ser_idx series_data_.__len__.return_value = val_count return workbook_writer, series_data_, expected_value
def write_cat_fixture(self, worksheet_): workbook_writer = CategoryWorkbookWriter(None) col, level = 6, ([0, "Foo"], [1, "Bar"]) num_format = object() calls = [ call.set_column(col, col, 10), call.write(1, col, "Foo", num_format), call.write(2, col, "Bar", num_format), ] return workbook_writer, worksheet_, col, level, num_format, calls
def write_sers_fixture(self, request, chart_data_, workbook_, worksheet_, categories_): workbook_writer = CategoryWorkbookWriter(chart_data_) num_format = workbook_.add_format.return_value calls = [ call.write(0, 1, "S1"), call.write_column(1, 1, (42, 24), num_format) ] ser = instance_mock(request, CategorySeriesData, values=(42, 24)) ser.name = "S1" chart_data_.categories = categories_ categories_.depth = 1 chart_data_.__iter__.return_value = iter([ser]) return workbook_writer, workbook_, worksheet_, calls
def write_cats_fixture(self, request, chart_data_, workbook_, worksheet_, categories_, _write_cat_column_): levels = request.param workbook_writer = CategoryWorkbookWriter(chart_data_) number_format = categories_.number_format = '$#0.#' num_format = workbook_.add_format.return_value _depth = len(levels) calls = [ call(workbook_writer, worksheet_, _depth-idx-1, level, num_format) for (idx, level) in enumerate(levels) ] chart_data_.categories = categories_ categories_.depth = len(levels) categories_.levels = levels return workbook_writer, workbook_, worksheet_, number_format, calls
def _workbook_writer(self): """ The worksheet writer object to which layout and writing of the Excel worksheet for this chart will be delegated. """ return CategoryWorkbookWriter(self)
def cat_ref_raises_fixture(self, request, chart_data_, categories_): workbook_writer = CategoryWorkbookWriter(chart_data_) chart_data_.categories = categories_ categories_.depth = 0 return workbook_writer
def categories_ref_fixture(self, request, chart_data_, categories_): depth, leaf_count, expected_value = request.param workbook_writer = CategoryWorkbookWriter(chart_data_) chart_data_.categories = categories_ categories_.depth, categories_.leaf_count = depth, leaf_count return workbook_writer, expected_value
def populate_fixture(self, workbook_, worksheet_, _write_categories_, _write_series_): workbook_writer = CategoryWorkbookWriter(None) return workbook_writer, workbook_, worksheet_
def it_raises_on_col_number_out_of_range(self, raises_fixture): col_num = raises_fixture with pytest.raises(ValueError): CategoryWorkbookWriter._column_reference(col_num)
def it_calculates_a_column_reference_to_help(self, col_ref_fixture): col_num, expected_value = col_ref_fixture column_reference = CategoryWorkbookWriter._column_reference(col_num) assert column_reference == expected_value
def it_raises_on_col_number_out_of_range(self, raises_fixture): col_num = raises_fixture with pytest.raises(ValueError): CategoryWorkbookWriter._column_reference(col_num)
def it_calculates_a_column_reference_to_help(self, col_ref_fixture): col_num, expected_value = col_ref_fixture column_reference = CategoryWorkbookWriter._column_reference(col_num) assert column_reference == expected_value