def test_setup_existing(self, m_s): """Run _setup with no args on setup of sheet with titles.""" wb = Workbook() ws = wb.active sws = SeedsWorksheet(ws) sws.set_column_titles(('One', 'Two', 'Three')) pws = PacketsWorksheet(sws._ws) pws.setup() assert m_s.call_args_list == [mock.call()]
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()]
def test_setup_existing(self, m_s): """Run _setup with no arguments if titles already exist.""" wb = Workbook() ws = wb.active sws = SeedsWorksheet(ws) sws.set_column_titles(('One', 'Two', 'Three')) cvws = CultivarsWorksheet(sws._ws) cvws.setup() assert m_s.call_args_list == [mock.call()]
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()]
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()]
def test_set_column_titles_existing_sheet(self): """Raise a ValueError if there is already data in the top row.""" wb = Workbook() ws = wb.active sws = SeedsWorksheet(ws) titles = ['One', 'Two', 'Three', 'Four'] sws._ws.append(titles) with pytest.raises(ValueError): sws.set_column_titles(titles)
def test_set_column_titles(self): """Set the top row of the worksheet to a list of titles.""" wb = Workbook() ws = wb.active sws = SeedsWorksheet(ws) titles = ['One', 'Two', 'Three', 'Four'] sws.set_column_titles(titles) assert sws._ws['A1'].value == 'One' assert sws._ws['B1'].value == 'Two' assert sws._ws['C1'].value == 'Three' assert sws._ws['D1'].value == 'Four'
def test_populate_cols_dict(self): """Set cols keys to values in first row, and vals to col numbers.""" wb = Workbook() ws = wb.active sws = SeedsWorksheet(ws) titles = ['One', 'Two', 'Three', 'Four'] sws.set_column_titles(titles) sws.populate_cols_dict() assert sws.cols['One'] == 1 assert sws.cols['Two'] == 2 assert sws.cols['Three'] == 3 assert sws.cols['Four'] == 4