Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-andreotti committed Nov 8, 2024
1 parent 4eb6b57 commit edf27b2
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 99 deletions.
148 changes: 74 additions & 74 deletions rer/bandi/tests/test_bando_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<li>foo</li>', view_new())
self.assertIn('<li>bar</li>', view_new())
self.assertIn("Who can apply", view_new())
self.assertIn("<li>foo</li>", view_new())
self.assertIn("<li>bar</li>", 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('<li>foo</li>', view_new())
self.assertIn('<li>bar</li>', view_new())
self.assertIn("Who can apply", view_new())
self.assertIn("<li>foo</li>", view_new())
self.assertIn("<li>bar</li>", 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('<span>Found1 | Found2</span>', view_new())
self.assertIn("Financed by EU programmes", view_new())
self.assertIn("<span>Found1 | Found2</span>", 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('<span>Found1 | Found2</span>', view_new())
self.assertIn("Financed by EU programmes", view_new())
self.assertIn("<span>Found1 | Found2</span>", 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('<span>Topic1 | Topic2</span>', view_new())
self.assertIn("Topic", view_new())
self.assertIn("<span>Topic1 | Topic2</span>", 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('<span>Topic1 | Topic2</span>', view_new())
self.assertIn("Topic", view_new())
self.assertIn("<span>Topic1 | Topic2</span>", view_new())
50 changes: 25 additions & 25 deletions rer/bandi/tests/test_collection_criteria.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit edf27b2

Please sign in to comment.