Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrige ícones de tiles no overrides.zcml. #141

Merged
merged 2 commits into from
Apr 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Alterações
buildout.cfg e as versões mais novas no momento desse release de
brasil.gov.tiles contém upgrades.

- Corrige ícones dos tiles presentes em overrides já que nas versões de
collective.cover >= 1.0a13 a estrutura dos recursos estáticos foi alterada.
(closes `#140`).
[idgserpro]

- Corrige capa quebrada quando uma notícia (collective.nitf) sem imagem é
adicionada num MediaCarouselTile. (closes `#136`).
[idgserpro]
Expand Down Expand Up @@ -273,3 +278,4 @@ Alterações
.. _`#123`: https://github.com/plonegovbr/brasil.gov.tiles/issues/123
.. _`#132`: https://github.com/plonegovbr/brasil.gov.tiles/issues/132
.. _`#136`: https://github.com/plonegovbr/brasil.gov.tiles/issues/136
.. _`#140`: https://github.com/plonegovbr/brasil.gov.tiles/issues/140
14 changes: 10 additions & 4 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ eggs =
plone.app.robotframework[ride,reload]

[versions]
# 1.0a10 possui um bug grave. Ver
# https://github.com/plonegovbr/brasil.gov.tiles/issues/130#issuecomment-117761638
collective.cover = > 1.0a10
# createcoverage 1.4.1 requer coverage>=3.7, dando conflito com a versão
# createcoverage 1.4.1 requer coverage>=3.7, dando conflito com a versão
# requerida pelo plone.
createcoverage = 1.4

Expand All @@ -59,6 +56,15 @@ zope.configuration = 3.8.0
# Products.PloneFormGen >= 1.8 requer Plone 5
Products.PloneFormGen = < 1.8

# XXX: Ao adicionar collective.cover[test] em setup.py (necessário para usar
# o tzlocal em collective.cover.setup.py, usado em nossos testes já que passo a
# herdar do Fixture de collective.cover em testing.py), recebemos o erro
# cop, cv = _parse_constraint(constraint).group(1, 2)
# AttributeError: 'NoneType' object has no attribute 'group'
# e a solução para isso é usar uma versão mais nova do buildout. Ver
# https://github.com/buildout/buildout/issues/99
zc.buildout = >= 2.2.5

# É necessário ter o precompile para gerar os '*.mo' para os testes. Os '*.mo'
# só são gerados quando a instância sobe e para executar os testes a instância
# não é levantada.
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
include_package_data=True,
zip_safe=False,
install_requires=[
'collective.cover',
# Após o commit 007adcde40d2031a15debd5122af8086a1db6fa6, necessito a
# partir dessa versão pois alterei o caminho dos recursos estáticos no
# overrides.zcml.
'collective.cover > 1.0a12',
'collective.nitf',
'collective.polls',
'collective.prettydate',
Expand Down Expand Up @@ -79,6 +82,7 @@
],
extras_require={
'test': [
'collective.cover[test]',
'mock',
'five.pt',
'plone.app.robotframework',
Expand Down
36 changes: 4 additions & 32 deletions src/brasil/gov/tiles/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from App.Common import package_home
from PIL import Image
from StringIO import StringIO
from collective.cover.testing import Fixture as CoverFixture
from plone import api
from plone.app.robotframework.testing import AUTOLOGIN_LIBRARY_FIXTURE
from plone.app.testing import FunctionalTesting
from plone.app.testing import IntegrationTesting
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import PloneSandboxLayer
from plone.testing import z2

import os
Expand Down Expand Up @@ -57,43 +57,23 @@ def generate_jpeg(width, height):
return output.getvalue()


class Fixture(PloneSandboxLayer):
class Fixture(CoverFixture):

defaultBases = (PLONE_FIXTURE,)

def setUpZope(self, app, configurationContext):
import Products.PloneFormGen
self.loadZCML(package=Products.PloneFormGen)
z2.installProduct(app, 'Products.PloneFormGen')

# Load ZCML
import collective.cover
self.loadZCML(package=collective.cover)
if 'virtual_hosting' not in app.objectIds():
# If ZopeLite was imported, we have no default virtual
# host monster
from Products.SiteAccess.VirtualHostMonster \
import manage_addVirtualHostMonster
manage_addVirtualHostMonster(app, 'virtual_hosting')
super(Fixture, self).setUpZope(app, configurationContext)
import brasil.gov.tiles
self.loadZCML(package=brasil.gov.tiles)
self.loadZCML(name='overrides.zcml', package=brasil.gov.tiles)

def setUpPloneSite(self, portal):

super(Fixture, self).setUpPloneSite(portal)
with api.env.adopt_roles(roles=['Manager']):

# Install into Plone site using portal_setup
self.applyProfile(portal, 'collective.cover:default')
self.applyProfile(portal, 'collective.cover:testfixture')
self.applyProfile(portal, 'brasil.gov.tiles:default')
self.applyProfile(portal, 'brasil.gov.tiles:testfixture')
portal['my-image'].setImage(generate_jpeg(50, 50))
portal['my-image1'].setImage(generate_jpeg(50, 50))
portal['my-image2'].setImage(generate_jpeg(50, 50))
portal['my-file'].setFile(loadFile('lorem_ipsum.txt'))
portal['my-file'].reindexObject()
portal['my-news-item'].setImage(generate_jpeg(50, 50))

api.content.create(
type='Folder',
Expand All @@ -120,14 +100,6 @@ def setUpPloneSite(self, portal):
portal['my-news-folder']['my-nitf-without-image'].reindexObject()
portal['my-news-folder']['my-nitf-with-image']['my-image'].reindexObject()

portal_workflow = portal.portal_workflow
portal_workflow.setChainForPortalTypes(['Collection'],
['plone_workflow'],)
# Prevent kss validation errors in Plone 4.2
portal_kss = getattr(portal, 'portal_kss', None)
if portal_kss:
portal_kss.getResource('++resource++plone.app.z3cform').setEnabled(False)


FIXTURE = Fixture()
INTEGRATION_TESTING = IntegrationTesting(
Expand Down
2 changes: 1 addition & 1 deletion src/brasil/gov/tiles/tests/test_banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_render_with_link(self):
self.tile.populate_with_object(obj)
rendered = self.tile()
self.assertNotIn('<img ', rendered)
self.assertIn('<a href="http://">Test link</a>', rendered)
self.assertIn('">Test link</a>', rendered)
self.assertFalse(self.tile.has_image)

def test_title(self):
Expand Down
37 changes: 37 additions & 0 deletions src/brasil/gov/tiles/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from brasil.gov.tiles.tiles.basic import BasicTile
from collective.cover.controlpanel import ICoverSettings
from collective.cover.tiles.base import IPersistentCoverTile
from plone import api
from plone.registry.interfaces import IRegistry
from zope.component import getUtility
from zope.interface.verify import verifyClass
Expand Down Expand Up @@ -77,3 +78,39 @@ def test_variacao_titulo(self):
obj = self.portal['my-image']
self.tile.populate_with_object(obj)
self.assertEqual(self.tile.variacao_titulo(), None)

def test_nova_estrutura_icon_tiles(self):
"""
FIXME: bin/instance está diferente de bin/test. Nesse contexto,
o método que retorna a tile e suas características, por algum motivo
retorna "None" no atributo 'icon' quando executamos bin/test: nesse
contexto, a template, ao receber None, popula o html com
tile-generic.png.

Com a nova versão de collective.cover 1.0a13, ele já retorna /img/tile
na template ao invés de só /tile e esse teste verifica isso, mas
renderizando o html da view.

Quando o issue

https://github.com/plone/plone.app.testing/issues/27

for finalizado, ele pode auxiliar na forma de melhorar esse teste, por
exemplo, apenas chamando o método "get_tile_metadata" de @@tile_list ao
invés de renderizar o html.

"""
with api.env.adopt_roles(roles=['Manager']):
api.content.create(
type='collective.cover.content',
title='my-cover',
id='my-cover',
container=self.portal,
template_layout='Layout A'
)
view = self.portal['my-cover'].restrictedTraverse('@@tile_list')
view.update()
html = view()
prefix_icon = '++resource++collective.cover/img/tile-'
total_in_rendered_view = html.count(prefix_icon)
self.assertTrue(len(view.tiles) == total_in_rendered_view)
4 changes: 2 additions & 2 deletions src/brasil/gov/tiles/tests/test_destaque_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ def test_crud(self):
tile = tile['test']
self.assertTrue(tile.is_empty())

def test_populate_with_uids(self):
def test_populate_with_uuids(self):
# we start with an empty tile
self.assertTrue(self.tile.is_empty())

# now we add a couple of objects to the destaque
obj1 = self.portal['my-document']
obj2 = self.portal['my-image']
self.tile.populate_with_uids([IUUID(obj1, None),
self.tile.populate_with_uuids([IUUID(obj1, None),
IUUID(obj2, None)])

# tile's data attributed is cached so we should re-instantiate the tile
Expand Down
12 changes: 7 additions & 5 deletions src/brasil/gov/tiles/tests/test_mediacarousel_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,27 @@ def test_delete_folder(self):
self.assertIn(msg, self.tile())

def test_collection_tile_render(self):
obj = self.portal['my-collection']
obj = self.portal['mandelbrot-set']
self.tile.populate_with_object(obj)

rendered = self.tile()
msg = u'Drag a folder or collection to populate the tile.'
msg = u'Mandelbrot set'
self.assertIn(msg, rendered)

def test_delete_collection(self):
obj = self.portal['my-collection']
obj = self.portal['mandelbrot-set']
self.tile.populate_with_object(obj)
self.tile.populate_with_object(obj)

rendered = self.tile()
msg = u'Drag a folder or collection to populate the tile.'
msg = u'Mandelbrot set'
self.assertIn(msg, rendered)

setRoles(self.portal, TEST_USER_ID, ['Manager', 'Editor', 'Reviewer'])
login(self.portal, TEST_USER_NAME)
self.portal.manage_delObjects(['my-collection'])
self.portal.manage_delObjects(['mandelbrot-set'])

msg = u'Drag a folder or collection to populate the tile.'

rendered = self.tile()
self.tile.is_compose_mode = Mock(return_value=True)
Expand Down
13 changes: 13 additions & 0 deletions src/brasil/gov/tiles/tests/test_mediacarousel_tile.robot
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Suite Teardown Close all browsers

*** Variables ***

${filter_items} contentchooser-content-trees
${my_news_folder} my-news-folder
${mediacarousel_tile_location} 'mediacarousel'
${collection_selector} .ui-draggable .contenttype-collection
# This xpath selector is for the <a> father of <span>my-news-folder</span>
Expand Down Expand Up @@ -129,6 +131,17 @@ Test Mediacarousel Tile
# drag&drop a folder with nitf content
Open Content Chooser
Click Link link=Content tree
# Temos um bug no robots onde ele não consegue selecionar um ícone do overlay
# "Adicionar conteúdo" se for necessário usar o scroll, era como se ele não
# conseguisse "ver" o objeto: dessa forma, uso o filtro de items para mostrar
# menos itens e evitar esse problema.
# FIXME: https://github.com/robotframework/Selenium2Library/issues/591
Input Text id=${filter_items} ${my_news_folder}
# Acontece que, ao usar o filtro, o "Drag And Drop" acaba sendo executado
# ANTES do "Input Text" ter um retorno na tela, ou seja, ele é executado com
# o scroll "ainda ativo": por isso preciso desse "Sleep" logo abaixo para
# "forçar" que o "Drag And Drop" só seja executado após o "Input Text".
Sleep 1s
Drag And Drop xpath=${my_news_folder_selector} css=${tile_selector}
Wait Until Page Contains Element css=div.mediacarousel.tile-content h2.mediacarousel-tile+div
Wait Until Page Contains ${title_nitf_with_image}
Expand Down
24 changes: 12 additions & 12 deletions src/brasil/gov/tiles/tiles/overrides.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
name="collective.cover.basic"
title="Basic Tile"
description="A tile that shows general information about objects."
icon="++resource++collective.cover/tile-basic.png"
icon="++resource++collective.cover/img/tile-basic.png"
add_permission="cmf.ModifyPortalContent"
schema=".basic.IBasicTile"
class=".basic.BasicTile"
Expand All @@ -24,7 +24,7 @@
name="collective.cover.banner"
title="Banner Tile"
description="A tile that shows an image with a link."
icon="++resource++collective.cover/tile-banner.png"
icon="++resource++collective.cover/img/tile-banner.png"
add_permission="cmf.ModifyPortalContent"
schema=".banner.IBannerTile"
class=".banner.BannerTile"
Expand All @@ -36,7 +36,7 @@
name="collective.cover.collection"
title="Collection Tile"
description="A tile that shows the result of a collection."
icon="++resource++collective.cover/tile-collection.png"
icon="++resource++collective.cover/img/tile-collection.png"
add_permission="cmf.ModifyPortalContent"
schema=".collection.ICollectionTile"
class=".collection.CollectionTile"
Expand All @@ -48,7 +48,7 @@
name="collective.cover.list"
title="List Tile"
description="A tile that shows a list of items."
icon="++resource++collective.cover/tile-list.png"
icon="++resource++collective.cover/img/tile-list.png"
add_permission="cmf.ModifyPortalContent"
schema=".list.IListTile"
class=".list.ListTile"
Expand All @@ -60,7 +60,7 @@
name="collective.cover.embed"
title="Embedding Tile"
description="A tile to embed content from a remote source."
icon="++resource++collective.cover/tile-embed.png"
icon="++resource++collective.cover/img/tile-embed.png"
add_permission="cmf.ModifyPortalContent"
schema=".embed.IEmbedTile"
class=".embed.EmbedTile"
Expand All @@ -72,7 +72,7 @@
name="collective.cover.carousel"
title="Carousel Tile"
description="A tile that shows a carousel of images."
icon="++resource++collective.cover/tile-carousel.png"
icon="++resource++collective.cover/img/tile-carousel.png"
add_permission="cmf.ModifyPortalContent"
schema=".carousel.ICarouselTile"
class=".carousel.CarouselTile"
Expand All @@ -86,7 +86,7 @@
name="collective.cover.basic"
title="Basic Tile"
description="A tile that shows general information about objects."
icon="++resource++collective.cover/tile-basic.png"
icon="++resource++collective.cover/img/tile-basic.png"
add_permission="cmf.ModifyPortalContent"
schema=".basic.IBasicTile"
class=".basic.BasicTile"
Expand All @@ -98,7 +98,7 @@
name="collective.cover.banner"
title="Banner Tile"
description="A tile that shows an image with a link."
icon="++resource++collective.cover/tile-banner.png"
icon="++resource++collective.cover/img/tile-banner.png"
add_permission="cmf.ModifyPortalContent"
schema=".banner.IBannerTile"
class=".banner.BannerTile"
Expand All @@ -110,7 +110,7 @@
name="collective.cover.collection"
title="Collection Tile"
description="A tile that shows the result of a collection."
icon="++resource++collective.cover/tile-collection.png"
icon="++resource++collective.cover/img/tile-collection.png"
add_permission="cmf.ModifyPortalContent"
schema=".collection.ICollectionTile"
class=".collection.CollectionTile"
Expand All @@ -122,7 +122,7 @@
name="collective.cover.list"
title="List Tile"
description="A tile that shows a list of items."
icon="++resource++collective.cover/tile-list.png"
icon="++resource++collective.cover/img/tile-list.png"
add_permission="cmf.ModifyPortalContent"
schema=".list.IListTile"
class=".list.ListTile"
Expand All @@ -134,7 +134,7 @@
name="collective.cover.embed"
title="Embedding Tile"
description="A tile to embed content from a remote source."
icon="++resource++collective.cover/tile-embed.png"
icon="++resource++collective.cover/img/tile-embed.png"
add_permission="cmf.ModifyPortalContent"
schema=".embed.IEmbedTile"
class=".embed.EmbedTile"
Expand All @@ -146,7 +146,7 @@
name="collective.cover.carousel"
title="Carousel Tile"
description="A tile that shows a carousel of images."
icon="++resource++collective.cover/tile-carousel.png"
icon="++resource++collective.cover/img/tile-carousel.png"
add_permission="cmf.ModifyPortalContent"
schema=".carousel.ICarouselTile"
class=".carousel.CarouselTile"
Expand Down