From ada012429f767eac6ab5b22b5ba36d4a7c48854d Mon Sep 17 00:00:00 2001 From: hvelarde Date: Mon, 29 Jan 2018 13:36:29 -0200 Subject: [PATCH] Fix code analysis --- src/brasil/gov/vcge/at/extender.py | 13 ++++---- src/brasil/gov/vcge/browser/viewlets.py | 2 +- src/brasil/gov/vcge/dx/widget.py | 25 +++++++--------- src/brasil/gov/vcge/tests/test_behavior.py | 10 +++---- .../vcge/tests/test_contentrules_action.py | 30 ++++++++----------- .../vcge/tests/test_contentrules_condition.py | 23 +++++++------- src/brasil/gov/vcge/tests/test_setup.py | 4 +-- src/brasil/gov/vcge/tests/test_viewlet.py | 4 +-- 8 files changed, 50 insertions(+), 61 deletions(-) diff --git a/src/brasil/gov/vcge/at/extender.py b/src/brasil/gov/vcge/at/extender.py index 0eb29ef..bf03f61 100644 --- a/src/brasil/gov/vcge/at/extender.py +++ b/src/brasil/gov/vcge/at/extender.py @@ -31,12 +31,13 @@ class VCGEExtender(object): layer = IVCGEInstalado fields = [ - ExtensionLinesField('skos', - schemata='categorization', - vocabulary_factory='brasil.gov.vcge', - enforceVocabulary=True, - widget=AcMSW(label=_(u'VCGE'), - description=_(u'vcge_desc'),)) + ExtensionLinesField( + 'skos', + schemata='categorization', + vocabulary_factory='brasil.gov.vcge', + enforceVocabulary=True, + widget=AcMSW(label=_(u'VCGE'), description=_(u'vcge_desc')), + ), ] def __init__(self, context): diff --git a/src/brasil/gov/vcge/browser/viewlets.py b/src/brasil/gov/vcge/browser/viewlets.py index 8a80f3a..1ad4f4c 100644 --- a/src/brasil/gov/vcge/browser/viewlets.py +++ b/src/brasil/gov/vcge/browser/viewlets.py @@ -38,7 +38,7 @@ def skos(self): 'title': title, 'url': '{0}/@@search?{1}'.format( self.nav_root_url, - params + params, )}) return skos diff --git a/src/brasil/gov/vcge/dx/widget.py b/src/brasil/gov/vcge/dx/widget.py index 15b4dd9..c446244 100644 --- a/src/brasil/gov/vcge/dx/widget.py +++ b/src/brasil/gov/vcge/dx/widget.py @@ -76,21 +76,18 @@ def js(self): context = self.context form_url = context.absolute_url() js_callback = self.js_callback_template.format( - **dict(id=self.id, name=self.name) - ) + id=self.id, name=self.name) return self.js_template.format( - **dict( - id=self.id, - name=self.name, - url=form_url, - minChars=self.minChars, - maxResults=self.maxResults, - mustMatch=str(self.mustMatch).lower(), - matchContains=str(self.matchContains).lower(), - formatItem=self.formatItem, - formatResult=self.formatResult, - js_callback=js_callback, - ) + id=self.id, + name=self.name, + url=form_url, + minChars=self.minChars, + maxResults=self.maxResults, + mustMatch=str(self.mustMatch).lower(), + matchContains=str(self.matchContains).lower(), + formatItem=self.formatItem, + formatResult=self.formatResult, + js_callback=js_callback, ) def vocab(self): diff --git a/src/brasil/gov/vcge/tests/test_behavior.py b/src/brasil/gov/vcge/tests/test_behavior.py index 33cac5f..17c61d6 100644 --- a/src/brasil/gov/vcge/tests/test_behavior.py +++ b/src/brasil/gov/vcge/tests/test_behavior.py @@ -69,10 +69,10 @@ def setUpContent(self): o = api.content.create( type=DEXTERITY_FTI_FOLDER, container=portal, - id='content' + id='content', ) i = IVCGE(o) - i.skos = [token, ] + i.skos = [token] self.content = o def setUp(self): @@ -88,7 +88,7 @@ def setUp(self): api.content.create( type=DEXTERITY_FTI_FOLDER, container=self.portal, - id='folder' + id='folder', ) self.setUpContent() @@ -99,7 +99,7 @@ def test_behavior_applied(self): def test_content_information(self): content = self.content - self.assertEqual(content.skos, [self.token, ]) + self.assertEqual(content.skos, [self.token]) class TestViewlet(unittest.TestCase): @@ -119,7 +119,7 @@ def setUpContent(self): container=portal, id='content', ) - o.skos = [token, ] + o.skos = [token] self.content = o def setUp(self): diff --git a/src/brasil/gov/vcge/tests/test_contentrules_action.py b/src/brasil/gov/vcge/tests/test_contentrules_action.py index 246cc49..53cd787 100644 --- a/src/brasil/gov/vcge/tests/test_contentrules_action.py +++ b/src/brasil/gov/vcge/tests/test_contentrules_action.py @@ -39,23 +39,23 @@ def setUp(self): self.folder = api.content.create( type='Folder', container=self.portal, - id='folder' + id='folder', ) - self.folder.skos = [self.term, ] + self.folder.skos = [self.term] self.folder.reindexObject() self.sub_folder = api.content.create( type='Folder', container=self.folder, - id='sub_folder' + id='sub_folder', ) self.document = api.content.create( type='Document', container=self.folder, - id='a_document' + id='a_document', ) - self.document.setSubject(['Bar', ]) + self.document.setSubject(['Bar']) self.document.reindexObject() o = PortalContent('cmf', 'CMF Content', '', '', '') @@ -86,12 +86,12 @@ def test_invoke_add_view(self): name=element.addview) addview.createAndAdd(data={'same_as_parent': False, - 'skos': [self.term, ]}) + 'skos': [self.term]}) e = rule.actions[0] self.assertTrue(isinstance(e, VCGEAction)) self.assertEqual(False, e.same_as_parent) - self.assertEqual([self.term, ], e.skos) + self.assertEqual([self.term], e.skos) def test_invoke_edit_view(self): element = getUtility(IRuleAction, @@ -104,26 +104,20 @@ def test_invoke_edit_view(self): def test_summary_parent_vcge(self): e = VCGEAction() e.same_as_parent = True - self.assertEqual( - e.summary, - u'Aplica termos da pasta no conteúdo.' - ) + self.assertEqual(e.summary, u'Aplica termos da pasta no conteúdo.') def test_summary_with_vcge(self): from plone.app.contentrules import PloneMessageFactory as _ e = VCGEAction() - e.skos = [self.term, ] + e.skos = [self.term] msg = _(u'Aplica os termos ${skos}', mapping=dict(skos=' or '.join(e.skos))) - self.assertEqual( - e.summary, - msg - ) + self.assertEqual(e.summary, msg) def test_execute_with_vcge(self): e = VCGEAction() e.same_as_parent = False - e.skos = ['http://vocab.e.gov.br/2011/03/vcge#governo', ] + e.skos = ['http://vocab.e.gov.br/2011/03/vcge#governo'] ex = getMultiAdapter((self.folder, e, DummyEvent(self.sub_folder)), @@ -147,7 +141,7 @@ def test_execute_same_as_parent(self): def test_execute_object_without_vcge(self): e = VCGEAction() e.same_as_parent = False - e.skos = ['http://vocab.e.gov.br/2011/03/vcge#governo', ] + e.skos = ['http://vocab.e.gov.br/2011/03/vcge#governo'] o = self.folder['cmf'] ex = getMultiAdapter((self.folder, e, DummyEvent(o)), diff --git a/src/brasil/gov/vcge/tests/test_contentrules_condition.py b/src/brasil/gov/vcge/tests/test_contentrules_condition.py index cb30ab3..83a6baf 100644 --- a/src/brasil/gov/vcge/tests/test_contentrules_condition.py +++ b/src/brasil/gov/vcge/tests/test_contentrules_condition.py @@ -38,16 +38,16 @@ def setUp(self): self.folder = api.content.create( type='Folder', container=self.portal, - id='folder' + id='folder', ) - self.folder.skos = [self.term, ] + self.folder.skos = [self.term] self.sub_folder = api.content.create( type='Folder', container=self.folder, - id='sub_folder' + id='sub_folder', ) - self.sub_folder.skos = ['http://vocab.e.gov.br/2011/03/vcge#governo', ] + self.sub_folder.skos = ['http://vocab.e.gov.br/2011/03/vcge#governo'] o = PortalContent('cmf', 'CMF Content', '', '', '') self.folder._setObject('cmf', o, suppress_events=True) @@ -71,11 +71,11 @@ def test_invoke_add_view(self): addview = getMultiAdapter((adding, self.portal.REQUEST), name=element.addview) - addview.createAndAdd(data={'skos': [self.term, ]}) + addview.createAndAdd(data={'skos': [self.term]}) e = rule.conditions[0] self.assertTrue(isinstance(e, VCGECondition)) - self.assertEqual([self.term, ], e.skos) + self.assertEqual([self.term], e.skos) def test_invoke_edit_view(self): element = getUtility(IRuleCondition, @@ -92,17 +92,14 @@ def test_summary_empty_vcge(self): def test_summary_with_vcge(self): from plone.app.contentrules import PloneMessageFactory as _ e = VCGECondition() - e.skos = [self.term, ] + e.skos = [self.term] msg = _(u'VCGE contém ${skos}', mapping=dict(skos=' or '.join(e.skos))) - self.assertEqual( - e.summary, - msg - ) + self.assertEqual(e.summary, msg) def test_execute(self): e = VCGECondition() - e.skos = [self.term, ] + e.skos = [self.term] ex = getMultiAdapter((self.portal, e, DummyEvent(self.folder)), IExecutable) @@ -132,7 +129,7 @@ def test_execute_empty(self): def test_execute_object_without_vcge(self): e = VCGECondition() - e.skos = [self.term, ] + e.skos = [self.term] ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder['cmf'])), diff --git a/src/brasil/gov/vcge/tests/test_setup.py b/src/brasil/gov/vcge/tests/test_setup.py index 6366476..a0ad00d 100644 --- a/src/brasil/gov/vcge/tests/test_setup.py +++ b/src/brasil/gov/vcge/tests/test_setup.py @@ -44,13 +44,13 @@ def test_installed(self): '{0} not installed'.format(PROJECTNAME)) def test_dependencies_installed(self): - for product in ['raptus.autocompletewidget', ]: + for product in ['raptus.autocompletewidget']: self.assertTrue(self.qi.isProductInstalled(product), '{0} not installed'.format(product)) @unittest.skipIf(not HAS_DEXTERITY, '"dexterity" extra not included') def test_dx_dependencies_installed(self): - for product in ['plone.app.dexterity', ]: + for product in ['plone.app.dexterity']: self.assertTrue(self.qi.isProductInstalled(product), '{0} not installed'.format(product)) diff --git a/src/brasil/gov/vcge/tests/test_viewlet.py b/src/brasil/gov/vcge/tests/test_viewlet.py index 287857c..002934b 100644 --- a/src/brasil/gov/vcge/tests/test_viewlet.py +++ b/src/brasil/gov/vcge/tests/test_viewlet.py @@ -26,9 +26,9 @@ def setUpContent(self): o = api.content.create( type='Document', container=portal, - id='doc' + id='doc', ) - o.Schema().getField('skos').set(o, [token, ]) + o.Schema().getField('skos').set(o, [token]) self.content = o def setUp(self):