def test_list_validation(): dv = DataValidation(ValidationType.LIST, formula1='"Dog,Cat,Fish"') eq_(dv.formula1, '"Dog,Cat,Fish"') eq_(dv.generate_attributes_map()['type'], 'list') eq_(dv.generate_attributes_map()['allowBlank'], '0') eq_(dv.generate_attributes_map()['showErrorMessage'], '1') eq_(dv.generate_attributes_map()['showInputMessage'], '1')
def test_prompt_message(): dv = DataValidation(ValidationType.LIST, formula1='"Dog,Cat,Fish"') dv.set_prompt_message('Please enter a value') eq_(dv.generate_attributes_map()['promptTitle'], 'Validation Prompt') eq_(dv.generate_attributes_map()['prompt'], 'Please enter a value')
def test_error_message(): dv = DataValidation(ValidationType.LIST, formula1='"Dog,Cat,Fish"') dv.set_error_message('You done bad') eq_(dv.generate_attributes_map()['errorTitle'], 'Validation Error') eq_(dv.generate_attributes_map()['error'], 'You done bad')
def initial_operations_template(building): wb = Workbook() ws = wb.worksheets[0] ws.title = u'Solduri inițiale' ws.cell(row=0, column=0).value = 'ID intern' ws.cell(row=0, column=1).value = 'Apartament' ws.cell(row=0, column=2).value = 'Sold' ws.cell(row=0, column=3).value = 'Data' def attr_validator(attr): l = (str(getattr(ap, attr)) for ap in building.apartments()) formula = '"' + ','.join(l) + '"' validator = DataValidation(ValidationType.LIST, formula1=formula, allow_blank=False) return validator id_validator = attr_validator('id') ws.add_data_validation(id_validator) name_validator = attr_validator('name') ws.add_data_validation(name_validator) decimal_validator = DataValidation(ValidationType.DECIMAL, allow_blank=True) decimal_validator.set_error_message('Introduceți un număr zecimal', 'Eroare de validare') ws.add_data_validation(decimal_validator) date_validator = DataValidation(ValidationType.DATE, allow_blank=True) date_validator.set_error_message('Introduceți o dată', 'Eroare de validare') ws.add_data_validation(date_validator) row = 1 now = datetime.now() for ap in building.apartments(): cell_id = ws.cell(row=row, column=0) cell_id.value = ap.id id_validator.add_cell(cell_id) cell_name = ws.cell(row=row, column=1) cell_name.value = ap.name name_validator.add_cell(cell_name) cell_balance = ws.cell(row=row, column=2) cell_balance.style.fill.fill_type = Fill.FILL_SOLID cell_balance.style.fill.start_color.index = Color.YELLOW decimal_validator.add_cell(cell_balance) cell_date = ws.cell(row=row, column=3) cell_date.value = now cell_date.style.number_format.format_code = 'yyyy-mm-dd' cell_date.style.fill.fill_type = Fill.FILL_SOLID cell_date.style.fill.start_color.index = Color.YELLOW date_validator.add_cell(cell_date) row += 1 ws.column_dimensions['A'].visible = False ws.column_dimensions['B'].width = 20.0 ws.column_dimensions['C'].width = 20.0 ws.column_dimensions['D'].width = 20.0 temp = tempfile.NamedTemporaryFile() wb.save(temp) return temp
print 'Creating the EMFAC 2014 User Defined Input Workbook and Worksheets' book = Workbook() sheet_settings = book.active sheet_settings.title = 'Settings' sheet_scen_vmt = book.create_sheet() sheet_scen_vmt.title = ('Daily_VMT_By_Veh_Tech') sheet_scen_speed = book.create_sheet() sheet_scen_speed.title = 'Hourly_Fraction_Veh_Tech_Speed' ####WRITE REGIONAL SCENARIOS SHEETS#### #Write Column Headers for Regional Scenarios Sheet print 'Writing header row for Settings worksheet' dv = DataValidation( validation_type="list", formula1= '"Annual,Summer,Winter,January,February,March,April,May,June,July,August,September,October,November,December"', allow_blank=True) sheet_settings.add_data_validation(dv) sheet_settings.cell(row=0, column=0).value = 'Parameter' sheet_settings.cell(row=0, column=1).value = 'Value' sheet_settings.cell(row=1, column=0).value = 'Date' sheet_settings.cell(row=1, column=1).value = datetime.now().strftime('%x %X') sheet_settings.cell(row=2, column=0).value = 'Season/Month' sheet_settings.cell(row=2, column=1).value = season dv.add_cell(sheet_settings.cell(row=2, column=1)) sheet_settings.cell(row=3, column=0).value = 'SB375 Run'