Exemplo n.º 1
0
 def test_setup_existing(self, m_s):
     """Call _setup with no data if titles already present."""
     wb = Workbook()
     ws = wb.active
     sws = SeedsWorksheet(ws)
     sws.set_column_titles(('One', 'Two', 'Three'))
     bnws = BotanicalNamesWorksheet(sws._ws)
     bnws.setup()
     assert m_s.call_args_list == [mock.call()]
Exemplo n.º 2
0
 def test_setup_new(self, m_s):
     """Call _setup with titles for Botanical Names worksheet."""
     wb = Workbook()
     ws = wb.active
     bnws = BotanicalNamesWorksheet(ws)
     bnws.setup()
     titles = ('Common Names (JSON)',
               'Botanical Name',
               'Synonyms')
     m_s.assert_called_with(titles)
Exemplo n.º 3
0
 def test_add_one_not_botanical_name(self):
     """Raise a TypeError given non-BotanicalName data."""
     wb = Workbook()
     ws = wb.active
     bnws = BotanicalNamesWorksheet(ws)
     bnws.setup()
     with pytest.raises(TypeError):
         bnws.add_one(42)
     with pytest.raises(TypeError):
         bnws.add_one(CommonName(name='Spurious'))
Exemplo n.º 4
0
 def test_add_one_with_synonyms(self):
     """Add a BotanicalName with synonyms to Botanical Names sheet."""
     wb = Workbook()
     ws = wb.active
     bnws = BotanicalNamesWorksheet(ws)
     bnws.setup()
     bn = BotanicalName(name='Innagada davida')
     cn = CommonName(name='Rock')
     cn.index = Index(name='Music')
     bn.common_names = [cn]
     bn.synonyms_string = 'Iron butterfly'
     bnws.add_one(bn)
     assert bnws.cell(2, bnws.cols['Synonyms']).value == 'Iron butterfly'
Exemplo n.º 5
0
 def test_add_one_no_optionals(self):
     """Add a BotanicalName object to Botanical Names sheet."""
     messages = StringIO()
     wb = Workbook()
     ws = wb.active
     bnws = BotanicalNamesWorksheet(ws)
     bnws.setup()
     bn = BotanicalName(name='Innagada davida')
     cn = CommonName(name='Rock')
     cn.index = Index(name='Music')
     bn.common_names = [cn]
     bnws.add_one(bn, stream=messages)
     assert bnws.cell(
         2, bnws.cols['Common Names (JSON)']
     ).value == queryable_dicts_to_json([cn])
     assert bnws.cell(
         2, bnws.cols['Botanical Name']
     ).value == 'Innagada davida'
     assert bnws.cell(2, bnws.cols['Synonyms']).value is None
     messages.seek(0)
     msgs = messages.read()
     assert ('Adding data from <BotanicalName "Innagada davida"> to row '
             '#2 of botanical names worksheet.') in msgs