示例#1
0
 def test_setup_new(self, m_s):
     """Call _setup with titles for Indexes sheet."""
     wb = Workbook()
     ws = wb.active
     iws = IndexesWorksheet(ws)
     iws.setup()
     m_s.assert_called_with(('Index', 'Description'))
示例#2
0
 def test_add_one_bad_type(self):
     """Raise a TypeError given non-Index data."""
     wb = Workbook()
     ws = wb.active
     iws = IndexesWorksheet(ws)
     iws.setup()
     with pytest.raises(TypeError):
         iws.add_one('Frogs!')
示例#3
0
 def test_setup_existing(self, m_s):
     """Call _setup with no data if sheet titles already populated."""
     wb = Workbook()
     ws = wb.active
     sws = SeedsWorksheet(ws)
     sws.set_column_titles(('Index', 'Description'))
     iws = IndexesWorksheet(sws._ws)
     iws.setup()
     assert m_s.call_args_list == [mock.call()]
示例#4
0
 def test_add_one(self):
     """Add a single Index to worksheet."""
     messages = StringIO()
     wb = Workbook()
     ws = wb.active
     iws = IndexesWorksheet(ws)
     iws.setup()
     idx = Index(name='Perennial', description='Built to last.')
     iws.add_one(idx, stream=messages)
     assert iws.cell(2, iws.cols['Index']).value == 'Perennial'
     assert iws.cell(
         2, iws.cols['Description']
     ).value == 'Built to last.'
     messages.seek(0)
     msgs = messages.read()
     assert ('Adding data from <Index "Perennial"> to row #2 of indexes '
             'worksheet.') in msgs