Skip to content

Commit

Permalink
added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Sep 14, 2016
1 parent e79ba3d commit 548dbe4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/collective/solr/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE
from plone.app.testing import FunctionalTesting
from plone.app.testing import IntegrationTesting
try:
try: # pragma: no cover
from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE as PLONE_FIXTURE # noqa
HAS_PAC = True
except ImportError:
except ImportError: # pragma: no cover
from plone.app.testing.bbb import PTC_FIXTURE as PLONE_FIXTURE
HAS_PAC = False
from plone.app.testing import PloneSandboxLayer
Expand All @@ -31,10 +31,10 @@

BIN_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))

try:
try: # pragma: no cover
pkg_resources.get_distribution('Products.LinguaPlone')
HAS_LINGUAPLONE = True
except pkg_resources.DistributionNotFound:
except pkg_resources.DistributionNotFound: # pragma: no cover
HAS_LINGUAPLONE = False


Expand Down Expand Up @@ -270,7 +270,7 @@ def tearDown(self):
pass


def set_attributes(context, values):
def set_attributes(context, values): # pragma: no cover
if HAS_PAC:
for key, value in values.iteritems():
setattr(context, key, value)
Expand Down
25 changes: 19 additions & 6 deletions src/collective/solr/tests/test_contentlisting.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from collective.solr.flare import PloneFlare
from collective.solr.testing import LEGACY_COLLECTIVE_SOLR_INTEGRATION_TESTING

from DateTime import DateTime


class ContentListingTests(TestCase):

Expand All @@ -26,9 +28,9 @@ def setUp(self):
'Description': 'Flare Description',
'Subject': 'Flare Subject',
'Date': 'Flare Date',
'expires': '1.1.2099',
'created': '31.12.1969',
'modified': '27.07.2016',
'expires': DateTime('1.1.2099'),
'created': DateTime('31.12.1969'),
'modified': DateTime('27.07.2016'),
'Language': 'de',
'portal_type': 'NewsItem',
'Type': 'Flare NewsItem',
Expand Down Expand Up @@ -90,17 +92,20 @@ def test_Date(self):
self.assertEqual(self.flare.Date(), 'Flare Date')

def test_CreationDate(self):
self.assertEqual(self.flare.CreationDate(), '31.12.1969')
self.assertEqual(self.flare.CreationDate().ISO(),
'1969-12-31T00:00:00')

def test_EffectiveDate(self):
self.assertEqual(self.flare.EffectiveDate(),
self.layer['portal']['news'].EffectiveDate())

def test_ExpirationDate(self):
self.assertEqual(self.flare.ExpirationDate(), '1.1.2099')
self.assertEqual(self.flare.ExpirationDate().ISO(),
'2099-01-01T00:00:00')

def test_ModificationDate(self):
self.assertEqual(self.flare.ModificationDate(), '27.07.2016')
self.assertEqual(self.flare.ModificationDate().ISO(),
'2016-07-27T00:00:00')

def test_Format(self):
self.assertRaises(NotImplementedError, self.flare.Format)
Expand Down Expand Up @@ -141,3 +146,11 @@ def test_Author(self):

def test_CroppedDescription(self):
self.assertEqual(self.flare.CroppedDescription(), 'Flare Description')

def test_pretty_title(self):
self.assertEqual(self.flare.flare.pretty_title_or_id(),
'Flare Title')

def test_creation_date(self):
self.assertTrue(
self.flare.flare.CreationDate.startswith('1969-12-31T'))

0 comments on commit 548dbe4

Please sign in to comment.