From edf27b291b1fd78d389f6a02af9533446fdf67d2 Mon Sep 17 00:00:00 2001 From: Daniele Andreotti Date: Fri, 8 Nov 2024 14:18:51 +0100 Subject: [PATCH] updated tests --- rer/bandi/tests/test_bando_view.py | 148 ++++++++++---------- rer/bandi/tests/test_collection_criteria.py | 50 +++---- 2 files changed, 99 insertions(+), 99 deletions(-) diff --git a/rer/bandi/tests/test_bando_view.py b/rer/bandi/tests/test_bando_view.py index 143b9c7..5fe23b3 100644 --- a/rer/bandi/tests/test_bando_view.py +++ b/rer/bandi/tests/test_bando_view.py @@ -12,170 +12,170 @@ class BandoViewTest(unittest.TestCase): layer = RER_BANDI_INTEGRATION_TESTING def setUp(self): - self.portal = self.layer['portal'] - self.request = self.layer['request'] - setRoles(self.portal, TEST_USER_ID, ['Manager']) + self.portal = self.layer["portal"] + self.request = self.layer["request"] + setRoles(self.portal, TEST_USER_ID, ["Manager"]) self.bando = api.content.create( - container=self.portal, type='Bando', title='Bando foo' + container=self.portal, type="Bando", title="Bando foo" ) def test_bando_views_registered(self): view = api.content.get_view( - name='bando_view', context=self.bando, request=self.request + name="bando_view", context=self.bando, request=self.request ) - self.assertTrue(view.__name__ == 'bando_view') + self.assertTrue(view.__name__ == "bando_view") view_right = api.content.get_view( - name='bando_right_view', context=self.bando, request=self.request + name="bando_right_view", context=self.bando, request=self.request ) - self.assertTrue(view_right.__name__ == 'bando_right_view') + self.assertTrue(view_right.__name__ == "bando_right_view") def test_destinatari_in_view(self): view = api.content.get_view( - name='bando_view', context=self.bando, request=self.request + name="bando_view", context=self.bando, request=self.request ) - self.assertNotIn('Who can apply', view()) + self.assertNotIn("Who can apply", view()) bando_new = api.content.create( container=self.portal, - type='Bando', - title='Bando new', - destinatari=['foo', 'bar'], + type="Bando", + title="Bando new", + destinatari=["foo", "bar"], ) view_new = api.content.get_view( - name='bando_view', context=bando_new, request=self.request + name="bando_view", context=bando_new, request=self.request ) - self.assertIn('Who can apply', view_new()) - self.assertIn('
  • foo
  • ', view_new()) - self.assertIn('
  • bar
  • ', view_new()) + self.assertIn("Who can apply", view_new()) + self.assertIn("
  • foo
  • ", view_new()) + self.assertIn("
  • bar
  • ", view_new()) def test_destinatari_in_right_view(self): view = api.content.get_view( - name='bando_right_view', context=self.bando, request=self.request + name="bando_right_view", context=self.bando, request=self.request ) - self.assertNotIn('Who can apply', view()) + self.assertNotIn("Who can apply", view()) bando_new = api.content.create( container=self.portal, - type='Bando', - title='Bando new', - destinatari=['foo', 'bar'], + type="Bando", + title="Bando new", + destinatari=["foo", "bar"], ) view_new = api.content.get_view( - name='bando_right_view', context=bando_new, request=self.request + name="bando_right_view", context=bando_new, request=self.request ) - self.assertIn('Who can apply', view_new()) - self.assertIn('
  • foo
  • ', view_new()) - self.assertIn('
  • bar
  • ', view_new()) + self.assertIn("Who can apply", view_new()) + self.assertIn("
  • foo
  • ", view_new()) + self.assertIn("
  • bar
  • ", view_new()) def test_tipologia_bando_in_view(self): view = api.content.get_view( - name='bando_view', context=self.bando, request=self.request + name="bando_view", context=self.bando, request=self.request ) # Because it's a required field - self.assertIn('Announcement type', view()) + self.assertIn("Announcement type", view()) bando_new = api.content.create( container=self.portal, - type='Bando', - title='Bando new', - tipologia_bando='Type a', + type="Bando", + title="Bando new", + tipologia_bando="Type a", ) view_new = api.content.get_view( - name='bando_view', context=bando_new, request=self.request + name="bando_view", context=bando_new, request=self.request ) - self.assertIn('Announcement type', view_new()) - self.assertIn('Type a', view_new()) + self.assertIn("Announcement type", view_new()) + self.assertIn("Type a", view_new()) def test_tipologia_bando_in_right_view(self): view = api.content.get_view( - name='bando_right_view', context=self.bando, request=self.request + name="bando_right_view", context=self.bando, request=self.request ) # Because it's a required field - self.assertIn('Announcement type', view()) + self.assertIn("Announcement type", view()) bando_new = api.content.create( container=self.portal, - type='Bando', - title='Bando new', - tipologia_bando='Type a', + type="Bando", + title="Bando new", + tipologia_bando="Type a", ) view_new = api.content.get_view( - name='bando_right_view', context=bando_new, request=self.request + name="bando_right_view", context=bando_new, request=self.request ) - self.assertIn('Announcement type', view_new()) - self.assertIn('Type a', view_new()) + self.assertIn("Announcement type", view_new()) + self.assertIn("Type a", view_new()) def test_finanziatori_in_view(self): view = api.content.get_view( - name='bando_view', context=self.bando, request=self.request + name="bando_view", context=self.bando, request=self.request ) - self.assertNotIn('Financed by EU programmes', view()) + self.assertNotIn("Financed by EU programmes", view()) bando_new = api.content.create( container=self.portal, - type='Bando', - title='Bando new', - finanziatori=['Found1', 'Found2'], + type="Bando", + title="Bando new", + finanziato=True, ) view_new = api.content.get_view( - name='bando_view', context=bando_new, request=self.request + name="bando_view", context=bando_new, request=self.request ) - self.assertIn('Financed by EU programmes', view_new()) - self.assertIn('Found1 | Found2', view_new()) + self.assertIn("Financed by EU programmes", view_new()) + self.assertIn("Found1 | Found2", view_new()) def test_finanziatori_in_right_view(self): view = api.content.get_view( - name='bando_right_view', context=self.bando, request=self.request + name="bando_right_view", context=self.bando, request=self.request ) - self.assertNotIn('Financed by EU programmes', view()) + self.assertNotIn("Financed by EU programmes", view()) bando_new = api.content.create( container=self.portal, - type='Bando', - title='Bando new', - finanziatori=['Found1', 'Found2'], + type="Bando", + title="Bando new", + finanziato=True, ) view_new = api.content.get_view( - name='bando_right_view', context=bando_new, request=self.request + name="bando_right_view", context=bando_new, request=self.request ) - self.assertIn('Financed by EU programmes', view_new()) - self.assertIn('Found1 | Found2', view_new()) + self.assertIn("Financed by EU programmes", view_new()) + self.assertIn("Found1 | Found2", view_new()) def test_materie_in_view(self): view = api.content.get_view( - name='bando_view', context=self.bando, request=self.request + name="bando_view", context=self.bando, request=self.request ) - self.assertNotIn('Topic', view()) + self.assertNotIn("Topic", view()) bando_new = api.content.create( container=self.portal, - type='Bando', - title='Bando new', - materie=['Topic1', 'Topic2'], + type="Bando", + title="Bando new", + materie=["Topic1", "Topic2"], ) view_new = api.content.get_view( - name='bando_view', context=bando_new, request=self.request + name="bando_view", context=bando_new, request=self.request ) - self.assertIn('Topic', view_new()) - self.assertIn('Topic1 | Topic2', view_new()) + self.assertIn("Topic", view_new()) + self.assertIn("Topic1 | Topic2", view_new()) def test_materie_in_right_view(self): view = api.content.get_view( - name='bando_right_view', context=self.bando, request=self.request + name="bando_right_view", context=self.bando, request=self.request ) - self.assertNotIn('Topic', view()) + self.assertNotIn("Topic", view()) bando_new = api.content.create( container=self.portal, - type='Bando', - title='Bando new', - materie=['Topic1', 'Topic2'], + type="Bando", + title="Bando new", + materie=["Topic1", "Topic2"], ) view_new = api.content.get_view( - name='bando_right_view', context=bando_new, request=self.request + name="bando_right_view", context=bando_new, request=self.request ) - self.assertIn('Topic', view_new()) - self.assertIn('Topic1 | Topic2', view_new()) + self.assertIn("Topic", view_new()) + self.assertIn("Topic1 | Topic2", view_new()) diff --git a/rer/bandi/tests/test_collection_criteria.py b/rer/bandi/tests/test_collection_criteria.py index 3650167..6ae300b 100644 --- a/rer/bandi/tests/test_collection_criteria.py +++ b/rer/bandi/tests/test_collection_criteria.py @@ -14,40 +14,40 @@ class TestCollectionCriteria(unittest.TestCase): layer = RER_BANDI_FUNCTIONAL_TESTING def setUp(self): - self.portal = self.layer['portal'] - self.request = self.layer['request'] - setRoles(self.portal, TEST_USER_ID, ['Manager']) + self.portal = self.layer["portal"] + self.request = self.layer["request"] + setRoles(self.portal, TEST_USER_ID, ["Manager"]) login(self.portal, TEST_USER_NAME) self.collection = api.content.create( - container=self.portal, type='Collection', title='Collection' + container=self.portal, type="Collection", title="Collection" ) self.bando1 = api.content.create( container=self.portal, - type='Bando', - title='Bando with destinatari', - destinatari=[u'd1', u'd2', u'dà'], + type="Bando", + title="Bando with destinatari", + destinatari=["d1", "d2", "dà"], ) self.bando2 = api.content.create( container=self.portal, - type='Bando', - title='Bando with finanziatori', - finanziatori=['f1'], + type="Bando", + title="Bando with finanziatori", + finanziato=True, ) self.bando3 = api.content.create( container=self.portal, - type='Bando', - title='Bando with materie', - materie=['m1', 'm2'], + type="Bando", + title="Bando with materie", + materie=["m1", "m2"], ) def test_query_destinatari(self): query = [ { - 'i': 'destinatari', - 'o': 'plone.app.querystring.operation.string.is', - 'v': ['d1'], + "i": "destinatari", + "o": "plone.app.querystring.operation.string.is", + "v": ["d1"], } ] self.collection.setQuery(query) @@ -58,9 +58,9 @@ def test_query_destinatari(self): def test_query_destinatari_with_accent(self): query = [ { - 'i': 'destinatari', - 'o': 'plone.app.querystring.operation.string.is', - 'v': ['dà'], + "i": "destinatari", + "o": "plone.app.querystring.operation.string.is", + "v": ["dà"], } ] self.collection.setQuery(query) @@ -71,9 +71,9 @@ def test_query_destinatari_with_accent(self): def test_query_finanziatori(self): query = [ { - 'i': 'finanziatori', - 'o': 'plone.app.querystring.operation.string.is', - 'v': ['f1'], + "i": "finanziato", + "o": "plone.app.querystring.operation.boolean.isTrue", + "v": "", } ] self.collection.setQuery(query) @@ -84,9 +84,9 @@ def test_query_finanziatori(self): def test_query_materie(self): query = [ { - 'i': 'materie', - 'o': 'plone.app.querystring.operation.string.is', - 'v': ['m1'], + "i": "materie", + "o": "plone.app.querystring.operation.string.is", + "v": ["m1"], } ] self.collection.setQuery(query)