Skip to content
Snippets Groups Projects
Commit af044176e815 authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

flake8

parent 63f8548dad12
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
:copyright: 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :copyright: 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
""" """
__docformat__ = "restructuredtext en"
from cubicweb.entities import AnyEntity, fetch_config from cubicweb.entities import AnyEntity, fetch_config
...@@ -8,6 +7,7 @@ ...@@ -8,6 +7,7 @@
from cubicweb.entities import AnyEntity, fetch_config from cubicweb.entities import AnyEntity, fetch_config
class Link(AnyEntity): class Link(AnyEntity):
"""customized class for Link entities""" """customized class for Link entities"""
__regid__ = 'Link' __regid__ = 'Link'
...@@ -15,4 +15,3 @@ ...@@ -15,4 +15,3 @@
def dc_title(self): def dc_title(self):
return u'%s (%s)' % (self.title, self.url) return u'%s (%s)' % (self.title, self.url)
from cubicweb.predicates import is_instance from cubicweb.predicates import is_instance
from cubicweb.sobjects.notification import ContentAddedView from cubicweb.sobjects.notification import ContentAddedView
class LinkAddedView(ContentAddedView): class LinkAddedView(ContentAddedView):
"""get notified from new links""" """get notified from new links"""
__select__ = is_instance('Link') __select__ = is_instance('Link')
......
from yams.buildobjs import EntityType, RelationType, String, Boolean, RichString
_ = unicode _ = unicode
...@@ -2,4 +1,5 @@ ...@@ -2,4 +1,5 @@
_ = unicode _ = unicode
from yams.buildobjs import EntityType, String, RichString
class Link(EntityType): class Link(EntityType):
"""a link to an external internet resource""" """a link to an external internet resource"""
...@@ -7,5 +7,4 @@ ...@@ -7,5 +7,4 @@
url = String(required=True, fulltextindexed=True, maxsize=512, url = String(required=True, fulltextindexed=True, maxsize=512,
description=_("link's url")) description=_("link's url"))
description = RichString(fulltextindexed=True, description = RichString(fulltextindexed=True,
description=_("description of the linked page's content")) description=_("description of the linked page's content"))
LINK_ICON = data('icon_link.gif') LINK_ICON = data('icon_link.gif') # noqa: F821
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
from cubicweb.view import EntityView from cubicweb.view import EntityView
from cubicweb.web import formwidgets from cubicweb.web import formwidgets
from cubicweb.web import action from cubicweb.web import action
from cubicweb.web.views import uicfg, primary, baseviews, xbel, bookmark from cubicweb.web.views import uicfg, primary, baseviews, xbel
for attr in ('title', 'url'): for attr in ('title', 'url'):
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
self.w(u'<a href="%(url)s" title="%(description)s">%(title)s</a>' self.w(u'<a href="%(url)s" title="%(description)s">%(title)s</a>'
% values) % values)
class XbelItemLinkView(xbel.XbelItemView): class XbelItemLinkView(xbel.XbelItemView):
__select__ = is_instance('Link') __select__ = is_instance('Link')
......
from logilab.common.testlib import unittest_main from logilab.common.testlib import unittest_main
from cubicweb.devtools.testlib import AutomaticWebTest from cubicweb.devtools.testlib import AutomaticWebTest
class AutomaticWebTest(AutomaticWebTest): class AutomaticWebTest(AutomaticWebTest):
def to_test_etypes(self): def to_test_etypes(self):
...@@ -9,5 +10,6 @@ ...@@ -9,5 +10,6 @@
def list_startup_views(self): def list_startup_views(self):
return () return ()
if __name__ == '__main__': if __name__ == '__main__':
unittest_main() unittest_main()
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
afs = uicfg.autoform_section afs = uicfg.autoform_section
class LinkTC(CubicWebTC): class LinkTC(CubicWebTC):
def setup_database(self): def setup_database(self):
...@@ -33,11 +34,11 @@ ...@@ -33,11 +34,11 @@
with self.admin_access.web_request() as req: with self.admin_access.web_request() as req:
e = self.vreg["etypes"].etype_class('Link')(req) e = self.vreg["etypes"].etype_class('Link')(req)
self.assertEqual(rbc(afs.relations_by_section(e, 'main', 'attributes', 'update')), self.assertEqual(rbc(afs.relations_by_section(e, 'main', 'attributes', 'update')),
[('title', 'subject'), ('url', 'subject'), [('title', 'subject'), ('url', 'subject'),
('description', 'subject')]) ('description', 'subject')])
with self.admin_access.repo_cnx() as cnx: with self.admin_access.repo_cnx() as cnx:
self.create_user(cnx, u'toto') self.create_user(cnx, u'toto')
with self.new_access(u'toto').web_request() as req: with self.new_access(u'toto').web_request() as req:
# create a new instance with the new connection # create a new instance with the new connection
e = self.vreg["etypes"].etype_class('Link')(req) e = self.vreg["etypes"].etype_class('Link')(req)
self.assertEqual(rbc(afs.relations_by_section(e, 'main', 'attributes', 'update')), self.assertEqual(rbc(afs.relations_by_section(e, 'main', 'attributes', 'update')),
...@@ -38,11 +39,12 @@ ...@@ -38,11 +39,12 @@
with self.admin_access.repo_cnx() as cnx: with self.admin_access.repo_cnx() as cnx:
self.create_user(cnx, u'toto') self.create_user(cnx, u'toto')
with self.new_access(u'toto').web_request() as req: with self.new_access(u'toto').web_request() as req:
# create a new instance with the new connection # create a new instance with the new connection
e = self.vreg["etypes"].etype_class('Link')(req) e = self.vreg["etypes"].etype_class('Link')(req)
self.assertEqual(rbc(afs.relations_by_section(e, 'main', 'attributes', 'update')), self.assertEqual(rbc(afs.relations_by_section(e, 'main', 'attributes', 'update')),
[('title', 'subject'), ('url', 'subject'), [('title', 'subject'), ('url', 'subject'),
('description', 'subject')]) ('description', 'subject')])
if __name__ == '__main__': if __name__ == '__main__':
from unittest import main from unittest import main
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment