Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
modified code, adjusted tests. relates to #257 and #258.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrasca committed Jan 5, 2016
1 parent e3a4574 commit 45b0f0c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions bauble/plugins/plants/species_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ def search_view_markup_pair(self):
', '.join([str(v) for v in self.vernacular_names])))
else:
substring = '%s' % self.genus.family
trail = (' <span weight="light">%s</span>' %
utils.xml_safe(self.sp_author or ''))
trail = self.sp_author and (' <span weight="light">%s</span>' %
utils.xml_safe(self.sp_author)) or ''
if self.accepted:
trail += ('<span foreground="#555555" size="small" '
'weight="light"> - ' + _("synonym of %s") + "</span>"
Expand Down
23 changes: 10 additions & 13 deletions bauble/plugins/plants/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1686,10 +1686,6 @@ def test_cantinsertsametwice_warnonce(self):
raise SkipTest('Not Implemented') # presenter uses view internals


from bauble.plugins.plants.species import (
species_markup_func, vernname_markup_func)


class GlobalFunctionsTest(PlantTestCase):
def test_species_markup_func(self):
eCo = Species.retrieve_or_create(
Expand All @@ -1706,21 +1702,22 @@ def test_species_markup_func(self):
'rank': 'species',
'epithet': u'lobata'},
create=False, update=False)
first, second = species_markup_func(eCo)
self.assertEquals(remove_zws(first), u'<i>Maxillaria</i> <i>variabilis</i>')
first, second = eCo.search_view_markup_pair()
self.assertTrue(remove_zws(first).startswith(
u'<i>Maxillaria</i> <i>variabilis</i>'))
expect = '<i>Maxillaria</i> <i>variabilis</i> <span weight="light">'\
'Bateman ex Lindl.</span><span foreground="#555555" size="small" '\
'weight="light"> - synonym of <i>Encyclia</i> <i>cochleata</i> '\
'(L.) Lemée</span>'
self.assertEquals(remove_zws(first), expect)
self.assertEquals(second, u'Orchidaceae -- SomeName, SomeName 2')
first, second = species_markup_func(model)
first, second = model.search_view_markup_pair()
self.assertEquals(remove_zws(first), u'<i>Laelia</i> <i>lobata</i>')
self.assertEquals(second, u'Orchidaceae')

def test_species_markup_func_none(self):
first, second = species_markup_func(None)
self.assertEquals(first, u'...')
self.assertEquals(second, u'...')

def test_vername_markup_func(self):
vName = self.session.query(VernacularName).filter_by(id=1).one()
first, second = vernname_markup_func(vName)
first, second = vName.search_view_markup_pair()
self.assertEquals(remove_zws(second), u'<i>Maxillaria</i> <i>variabilis</i>')
self.assertEquals(first, u'SomeName')

Expand Down

0 comments on commit 45b0f0c

Please sign in to comment.