Ejemplo n.º 1
0
 def test_add_one_no_optionals(self):
     """Add a Cultivar to the Cultivars worksheet."""
     messages = StringIO()
     wb = Workbook()
     ws = wb.active
     cvws = CultivarsWorksheet(ws)
     cvws.setup()
     cv = Cultivar(name='Foxy')
     cv.common_name = CommonName(name='Foxglove')
     cv.common_name.index = Index(name='Perennial')
     cvws.add_one(cv, stream=messages)
     assert cvws.cell(2, cvws.cols['Index']).value == 'Perennial'
     assert cvws.cell(2, cvws.cols['Common Name']).value == 'Foxglove'
     assert cvws.cell(2, cvws.cols['Cultivar Name']).value == 'Foxy'
     assert cvws.cell(2, cvws.cols['Section']).value is None
     assert cvws.cell(2, cvws.cols['Botanical Name']).value is None
     assert cvws.cell(2, cvws.cols['Thumbnail Filename']).value is None
     assert cvws.cell(2, cvws.cols['Description']).value is None
     assert cvws.cell(2, cvws.cols['Synonyms']).value is None
     assert cvws.cell(2, cvws.cols['New Until']).value is None
     assert cvws.cell(2, cvws.cols['In Stock']).value == 'False'
     assert cvws.cell(2, cvws.cols['Active']).value == 'False'
     messages.seek(0)
     msgs = messages.read()
     assert ('Adding data from <Cultivar "Foxy Foxglove"> to row #2 of '
             'cultivars worksheet.') in msgs
Ejemplo n.º 2
0
 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()]
Ejemplo n.º 3
0
 def test_add_one_not_cultivar(self):
     """Raise a TypeError given non-Cultivar data."""
     wb = Workbook()
     ws = wb.active
     cvws = CultivarsWorksheet(ws)
     cvws.setup()
     with pytest.raises(TypeError):
         cvws.add_one(42)
     with pytest.raises(TypeError):
         cvws.add_one(Section(name='Spurious'))
Ejemplo n.º 4
0
 def test_add_one_with_synonyms(self):
     """Add a Cultivar with synonyms to worksheet."""
     wb = Workbook()
     ws = wb.active
     cvws = CultivarsWorksheet(ws)
     cvws.setup()
     cv = Cultivar(name='Foxy')
     cv.common_name = CommonName(name='Foxglove')
     cv.common_name.index = Index(name='Perennial')
     cv.synonyms_string = 'Vulpine'
     cvws.add_one(cv)
     assert cvws.cell(2, cvws.cols['Synonyms']).value == 'Vulpine'
Ejemplo n.º 5
0
 def test_add_one_with_thumbnail_filename(self):
     """Add a Cultivar with a Thumbnail Filename to worksheet."""
     wb = Workbook()
     ws = wb.active
     cvws = CultivarsWorksheet(ws)
     cvws.setup()
     cv = Cultivar(name='Foxy')
     cv.common_name = CommonName(name='Foxglove')
     cv.common_name.index = Index(name='Perennial')
     cv.thumbnail = Image(filename='foo.jpg')
     cvws.add_one(cv)
     assert cvws.cell(2, cvws.cols['Thumbnail Filename']).value == 'foo.jpg'
Ejemplo n.º 6
0
 def test_add_one_with_section(self):
     """Add a Cultivar with Section to worksheet."""
     wb = Workbook()
     ws = wb.active
     cvws = CultivarsWorksheet(ws)
     cvws.setup()
     cv = Cultivar(name='Petra')
     cv.common_name = CommonName(name='Foxglove')
     cv.common_name.index = Index(name='Perennial')
     cv.section = Section(name='Polkadot')
     cvws.add_one(cv)
     assert cvws.cell(2, cvws.cols['Section']).value == 'Polkadot'
Ejemplo n.º 7
0
 def test_add_one_with_description(self):
     """Add a Cultivar with a description to worksheet."""
     wb = Workbook()
     ws = wb.active
     cvws = CultivarsWorksheet(ws)
     cvws.setup()
     cv = Cultivar(name='Foxy')
     cv.common_name = CommonName(name='Foxglove')
     cv.common_name.index = Index(name='Perennial')
     cv.description = 'Like a lady!'
     cvws.add_one(cv)
     assert cvws.cell(
         2, cvws.cols['Description']
     ).value == 'Like a lady!'
Ejemplo n.º 8
0
 def test_add_one_with_botanical_name(self):
     """Add a Cultivar with a Botanical Name to worksheet."""
     wb = Workbook()
     ws = wb.active
     cvws = CultivarsWorksheet(ws)
     cvws.setup()
     cv = Cultivar(name='Foxy')
     cv.common_name = CommonName(name='Foxglove')
     cv.common_name.index = Index(name='Perennial')
     cv.botanical_name = BotanicalName(name='Digitalis purpurea')
     cvws.add_one(cv)
     assert cvws.cell(
         2, cvws.cols['Botanical Name']
     ).value == 'Digitalis purpurea'
Ejemplo n.º 9
0
 def test_add_one_active(self):
     """Add an active Cultivar to worksheet."""
     wb = Workbook()
     ws = wb.active
     cvws = CultivarsWorksheet(ws)
     cvws.setup()
     cv = Cultivar(name='Foxy')
     cv.common_name = CommonName(name='Foxglove')
     cv.common_name.index = Index(name='Perennial')
     cv.active = True
     cvws.add_one(cv)
     assert cvws.cell(2, cvws.cols['Active']).value == 'True'
     cv2 = Cultivar(name='Soulmate')
     cv2.common_name = CommonName(name='Butterfly Weed')
     cv2.common_name.index = Index(name='Perennial')
     cv2.active = False
     cvws.add_one(cv2)
     assert cvws.cell(3, cvws.cols['Active']).value == 'False'
Ejemplo n.º 10
0
    def test_add_one_with_new_until(self):
        """Add a Cultivar with New Until to worksheet.

        New Until values should be dates formatted MM/DD/YYYY because 'murica.
        """
        dt = datetime.date(2012, 12, 21)
        wb = Workbook()
        ws = wb.active
        cvws = CultivarsWorksheet(ws)
        cvws.setup()
        cv = Cultivar(name='Foxy')
        cv.common_name = CommonName(name='Foxglove')
        cv.common_name.index = Index(name='Perennial')
        cv.new_until = dt
        cvws.add_one(cv)
        assert cvws.cell(
            2, cvws.cols['New Until']
        ).value == dt.strftime('%m/%d/%Y')
Ejemplo n.º 11
0
 def test_setup_new(self, m_s):
     """Run _setup with the titles for the Cultivars worksheet."""
     wb = Workbook()
     ws = wb.active
     cvws = CultivarsWorksheet(ws)
     cvws.setup()
     titles = ('Index',
               'Common Name',
               'Cultivar Name',
               'Section',
               'Botanical Name',
               'Thumbnail Filename',
               'Description',
               'Synonyms',
               'New Until',
               'In Stock',
               'Active',
               'Visible')
     m_s.assert_called_with(titles)