Exemple #1
0
 def test_setup_existing(self, m_s):
     """Call _setup with no data if titles row already populated."""
     wb = Workbook()
     ws = wb.active
     sws = SeedsWorksheet(ws)
     sws.set_column_titles(('One', 'Two', 'Three'))
     cnws = CommonNamesWorksheet(sws._ws)
     cnws.setup()
     assert m_s.call_args_list == [mock.call()]
Exemple #2
0
 def test_setup_new(self, m_s):
     """Call _setup with titles for Common Names worksheet."""
     wb = Workbook()
     ws = wb.active
     cnws = CommonNamesWorksheet(ws)
     cnws.setup()
     titles = ('Index',
               'Common Name',
               'Description',
               'Planting Instructions',
               'Synonyms',
               'Visible')
     m_s.assert_called_with(titles)
Exemple #3
0
 def test_add_one_not_common_name(self):
     """Raise a TypeError given data that isn't a CommonName."""
     wb = Workbook()
     ws = wb.active
     cnws = CommonNamesWorksheet(ws)
     cnws.setup()
     with pytest.raises(TypeError):
         cnws.add_one(42)
     with pytest.raises(TypeError):
         cnws.add_one(Index(name='Perennial'))
Exemple #4
0
 def test_add_one_no_optionals(self):
     """Add a common name (with no optional data) to Common Names sheet."""
     messages = StringIO()
     wb = Workbook()
     ws = wb.active
     cnws = CommonNamesWorksheet(ws)
     cnws.setup()
     cn = CommonName(name='Foxglove')
     cn.index = Index(name='Perennial')
     cnws.add_one(cn, stream=messages)
     assert cnws.cell(2, cnws.cols['Index']).value == 'Perennial'
     assert cnws.cell(2, cnws.cols['Common Name']).value == 'Foxglove'
     assert cnws.cell(2, cnws.cols['Description']).value is None
     assert cnws.cell(2, cnws.cols['Planting Instructions']).value is None
     assert cnws.cell(2, cnws.cols['Synonyms']).value is None
     messages.seek(0)
     msgs = messages.read()
     assert ('Adding data from <CommonName "Foxglove"> to row #2 of '
             'common names worksheet.') in msgs
Exemple #5
0
 def test_add_one_with_optionals(self):
     """Add a common name with optionals to Common Names sheet."""
     wb = Workbook()
     ws = wb.active
     cnws = CommonNamesWorksheet(ws)
     cnws.setup()
     cn = CommonName(name='Foxglove',
                     description='Spotty.',
                     instructions='Just add water!')
     cn.index = Index(name='Perennial')
     cn.synonyms_string = 'Digitalis'
     cnws.add_one(cn)
     assert cnws.cell(2, cnws.cols['Description']).value == 'Spotty.'
     assert cnws.cell(
         2, cnws.cols['Planting Instructions']
     ).value == 'Just add water!'
     assert cnws.cell(2, cnws.cols['Synonyms']).value == 'Digitalis'