def test_extract_data_dict(self): col = SheetColumn('bar') assert col.extract_data({ 'foo': 1, 'bar': 'something', 'baz': 'else' }) == 'something'
def test_extract_data_attr(self): col = SheetColumn('bar') assert col.extract_data( BlankObject( foo=1, bar='something', baz='else', )) == 'something'
def test_extract_data_attr(self): col = SheetColumn('bar') assert col.extract_data( BlankObject( foo=1, bar='something', baz='else', ) ) == 'something'
def test_extract_data_string(self): col = SheetColumn('bar') assert col.extract_data({'foo': 1, 'baz': 'else'}) == 'bar'
def test_extract_data_dict(self): col = SheetColumn('bar') assert col.extract_data({'foo': 1, 'bar': 'something', 'baz': 'else'}) == 'something'
def test_extract_data_no_key(self): col = SheetColumn() assert col.extract_data({}) == ''
def test_extract_data_combined_float(self): col = SheetColumn((9.5, 8, operator.add)) assert col.extract_data({}) == 17.5
def test_extract_data_combined_sacol(self): person = Person.testing_create(intcol=8, floatcol=9) col = SheetColumn((Person.intcol, Person.floatcol, operator.add)) assert col.extract_data(person) == 17
def test_extract_data_combined_string(self): col = SheetColumn(('foo', 'bar', operator.add)) assert col.extract_data({'foo': 9, 'bar': 8}) == 17
def test_extract_data_sacol_altcolname(self): person = Person.testing_create(lastname=u'foo') col = SheetColumn(Person.lastname) assert col.extract_data(person) == 'foo'
def test_extract_data_sacol(self): person = Person.testing_create() col = SheetColumn(Person.firstname) assert col.extract_data(person) == person.firstname
class TestSheet(ReportSheet): def fetch_records(self): return [] pre_data_rows = 3 SheetColumn('key', header_2='foo', header_4='bar')
def test_width(self): col = SheetColumn('key') col.register_col_width('something') col.register_col_width('something else') assert col.xls_computed_width == 14