Skip to content

Commit

Permalink
Merge 5a1c373 into 07799c1
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed May 31, 2018
2 parents 07799c1 + 5a1c373 commit f653436
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exclude_paths:
- bootstrap.py
- setup.py
22 changes: 13 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ python: 2.7
sudo: false
cache:
directories:
- $HOME/.pylint.d
- eggs
- parts/node
addons:
firefox: 45.8.0esr
env:
- PLONE_VERSION=4.3 TEST_EGGS=collective.cover[test]
- PLONE_VERSION=4.3 TEST_EGGS=plone.app.contenttypes
- PLONE_VERSION=5.0
- PLONE_VERSION=5.1
matrix:
allow_failures:
- env: PLONE_VERSION=5.0
- env: PLONE_VERSION=5.1
fast_finish: true
before_install:
# FIXME: I have no idea how and why six==1.11.0 is being installed
- pip uninstall -y six
install:
- sed -ie "s#test-4.3#test-$PLONE_VERSION#" buildout.cfg
- sed -ie "s#versions-4.3#versions-$PLONE_VERSION#" buildout.cfg
Expand All @@ -30,14 +32,16 @@ before_script:
script:
- bin/code-analysis
- bin/test
- bin/pylint --py3k --disable=no-absolute-import src/collective/nitf || true
after_success:
- bin/createcoverage -t "--layer=!Robot"
- pip install coverage
- coverage run bin/test --layer=\!Robot
# Coveralls
- pip install coveralls
- coveralls
after_script:
# Firefox complains: GConf-WARNING **: Got Disconnected from DBus.
# And then it keeps hanging, causing a failed job after 30-50 minutes.
# So we just kill Firefox.
- pkill -9 firefox
# Codacy
- coverage xml
- pip install codacy-coverage
- python-codacy-coverage -r coverage.xml
notifications:
irc: irc.freenode.org#simplesconsultoria
irc: irc.freenode.org#plone-testing
10 changes: 5 additions & 5 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ package-extras = [test]

parts +=
code-analysis
createcoverage
i18ndude
node
omelette
pylint
rebuild_i18n-sh
robot
zopepy
Expand Down Expand Up @@ -45,6 +45,10 @@ eggs = i18ndude
recipe = collective.recipe.omelette
eggs = ${test:eggs}

[pylint]
recipe = zc.recipe.egg
eggs = pylint < 2.0

[robot]
recipe = zc.recipe.egg
eggs =
Expand All @@ -54,10 +58,6 @@ scripts =
robot
robot-server

[versions]
# use latest version of coverage
coverage =

[zopepy]
recipe = zc.recipe.egg
eggs = ${instance:eggs}
Expand Down
8 changes: 3 additions & 5 deletions src/collective/nitf/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@


class INITFLayer(Interface):
""" A layer specific for this add-on product.
"""
""" A layer specific for this add-on product."""


class INITF(model.Schema):

"""A News Article based on the News Industry Text Format specification."""

# title = schema.TextLine()
Expand Down Expand Up @@ -71,7 +69,7 @@ class INITF(model.Schema):
u'object, not specifically its content.',
),
vocabulary=u'collective.nitf.AvailableGenres',
defaultFactory=genre_default_value
defaultFactory=genre_default_value,
)

urgency = schema.Choice(
Expand All @@ -80,5 +78,5 @@ class INITF(model.Schema):
description=_(u'help_urgency',
default=u'News importance.'),
vocabulary=u'collective.nitf.Urgencies',
defaultFactory=urgency_default_value
defaultFactory=urgency_default_value,
)
4 changes: 2 additions & 2 deletions src/collective/nitf/tests/test_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def setUp(self):
self.folder = api.content.create(
type='Folder',
title='test-folder',
container=self.portal
container=self.portal,
)
self.n1 = api.content.create(
type='collective.nitf.content',
title='n1',
container=self.folder
container=self.folder,
)

def test_byline_feed_adapter(self):
Expand Down
32 changes: 16 additions & 16 deletions src/collective/nitf/tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def setUp(self):
{
'i': 'portal_type',
'o': 'plone.app.querystring.operation.selection.is',
'v': ['collective.nitf.content']
}
'v': ['collective.nitf.content'],
},
])

def test_urgency_filter(self, ):
def test_urgency_filter(self):
self.assertEqual(len(self.c1.queryCatalog()), 0)

n1 = api.content.create(self.folder, 'collective.nitf.content', 'n1')
Expand All @@ -50,13 +50,13 @@ def test_urgency_filter(self, ):
{
'i': 'portal_type',
'o': 'plone.app.querystring.operation.selection.is',
'v': ['collective.nitf.content']
'v': ['collective.nitf.content'],
},
{
'i': 'urgency',
'o': 'plone.app.querystring.operation.intselection.is',
'v': [c.LOW]
}
'v': [c.LOW],
},
])
self.assertEqual(len(self.c1.queryCatalog()), 1)
expected = self.c1.queryCatalog()[0].getObject()
Expand All @@ -66,13 +66,13 @@ def test_urgency_filter(self, ):
{
'i': 'portal_type',
'o': 'plone.app.querystring.operation.selection.is',
'v': ['collective.nitf.content']
'v': ['collective.nitf.content'],
},
{
'i': 'urgency',
'o': 'plone.app.querystring.operation.intselection.is',
'v': [c.NORMAL]
}
'v': [c.NORMAL],
},
])
self.assertEqual(len(self.c1.queryCatalog()), 1)
expected = self.c1.queryCatalog()[0].getObject()
Expand All @@ -82,13 +82,13 @@ def test_urgency_filter(self, ):
{
'i': 'portal_type',
'o': 'plone.app.querystring.operation.selection.is',
'v': ['collective.nitf.content']
'v': ['collective.nitf.content'],
},
{
'i': 'urgency',
'o': 'plone.app.querystring.operation.intselection.is',
'v': [c.HIGH]
}
'v': [c.HIGH],
},
])
self.assertEqual(len(self.c1.queryCatalog()), 1)
expected = self.c1.queryCatalog()[0].getObject()
Expand All @@ -98,19 +98,19 @@ def test_urgency_filter(self, ):
{
'i': 'portal_type',
'o': 'plone.app.querystring.operation.selection.is',
'v': ['collective.nitf.content']
'v': ['collective.nitf.content'],
},
{
'i': 'urgency',
'o': 'plone.app.querystring.operation.intselection.is',
'v': [c.NORMAL, c.HIGH]
}
'v': [c.NORMAL, c.HIGH],
},
])
self.assertEqual(len(self.c1.queryCatalog()), 2)
expected = [b.getObject() for b in self.c1.queryCatalog()]
self.assertEqual([n2, n3], expected)

def test_render_view_methods(self, ):
def test_render_view_methods(self):
# https://github.com/collective/collective.nitf/issues/178
from collective.nitf.testing import get_image
from collective.nitf.testing import IMAGES
Expand Down
3 changes: 1 addition & 2 deletions src/collective/nitf/upgrades/v1008/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def fix_collections(context):
fixed_query.append(fixed_item)
obj.setQuery(fixed_query)
logger.info(
'Collection {0} at {1} updated'.format(col.id, col.getPath())
)
'Collection {0} at {1} updated'.format(col.id, col.getPath()))
logger.info('Done')


Expand Down
17 changes: 8 additions & 9 deletions src/collective/nitf/upgrades/v2000/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_valid_objects(brains):

if obj is None: # warn on broken entries in the catalog
logger.warn(
u'Invalid reference in the catalog: {0}'.format(b.getPath()))
'Invalid reference in the catalog: {0}'.format(b.getPath()))
continue
yield obj

Expand All @@ -36,15 +36,15 @@ def apply_profile(setup_tool):

def update_layouts(setup_tool):
# update existing objects
logger.info(u'Updating layout of news articles')
logger.info('Updating layout of news articles')
results = api.content.find(portal_type='collective.nitf.content')
logger.info(u'Found {0} news articles'.format(len(results)))
logger.info('Found {0} news articles'.format(len(results)))
i = 0
for obj in get_valid_objects(results):
if obj.getLayout() == 'nitf_galleria':
obj.setLayout('slideshow_view')
i += 1
logger.info(u'{0} news articles updated'.format(i))
logger.info('{0} news articles updated'.format(i))


def install_new_dependencies(setup_tool):
Expand All @@ -53,7 +53,7 @@ def install_new_dependencies(setup_tool):
for p in dependencies:
if not qi.isProductInstalled(p):
qi.installProducts([p])
logger.info(u'{0} installed'.format(p))
logger.info('{0} installed'.format(p))


def update_configlet(setup_tool):
Expand All @@ -80,12 +80,11 @@ def reindex_news_articles(setup_tool):
"""Reindex news articles to fix interfaces."""
test = 'test' in setup_tool.REQUEST # used to ignore transactions on tests
logger.info(
u'Reindexing the catalog. '
u'This process could take a long time on large sites. Be patient.'
)
'Reindexing the catalog. '
'This process could take a long time on large sites. Be patient.')
catalog = api.portal.get_tool('portal_catalog')
results = api.content.find(portal_type='collective.nitf.content')
logger.info(u'Found {0} news articles'.format(len(results)))
logger.info('Found {0} news articles'.format(len(results)))
n = 0
for obj in get_valid_objects(results):
catalog.catalog_object(obj, idxs=['object_provides'], update_metadata=False)
Expand Down
2 changes: 1 addition & 1 deletion src/collective/nitf/upgrades/v2002/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def reindex_searchable_text(setup_tool):
logger.info('Reindexing the catalog')
catalog = api.portal.get_tool('portal_catalog')
results = catalog(portal_type='collective.nitf.content')
logger.info(u'Found {0} news articles'.format(len(results)))
logger.info('Found {0} news articles'.format(len(results)))
for n, obj in enumerate(get_valid_objects(results), start=1):
catalog.catalog_object(obj, idxs=['SearchableText'])
if n % 1000 == 0:
Expand Down

0 comments on commit f653436

Please sign in to comment.