Skip to content

Commit

Permalink
Fixed tests, we do not use FormWrapper for votes anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
gbastien committed May 30, 2022
1 parent 560a344 commit 1c36b4e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Products/PloneMeeting/tests/testVotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def test_pm_EncodePublicVotesForm(self):
hp4 = person4.get_held_positions()[0]
hp4_uid = hp4.UID()
self.request['PUBLISHED'] = public_item
votes_form = public_item.restrictedTraverse('@@item_encode_votes_form').form_instance
votes_form = public_item.restrictedTraverse('@@item_encode_votes_form')
votes_form.meeting = meeting
# change vote to all 'no'
votes_form.votes = [{'voter_uid': hp1_uid, 'vote_value': 'no'},
Expand All @@ -379,6 +379,7 @@ def test_pm_EncodePublicVotesForm(self):
self.request.form['vote_number'] = 0
votes_form.label = u"My label"
votes_form.linked_to_previous = False
votes_form.apply_until_item_number = u'0'
votes_form.update()
# only for MeetingManagers
self.changeUser('pmCreator1')
Expand Down Expand Up @@ -410,7 +411,7 @@ def test_pm_EncodePublicVotesFormLinkedToPrevious(self):
person4 = self.portal.contacts.get('person4')
hp4 = person4.get_held_positions()[0]
hp4_uid = hp4.UID()
votes_form = public_item.restrictedTraverse('@@item_encode_votes_form').form_instance
votes_form = public_item.restrictedTraverse('@@item_encode_votes_form')
votes_form.meeting = meeting
# there are 'yes' votes so not able to link to previous
self.assertEqual(public_item.getVoteCount('yes'), 2)
Expand All @@ -426,6 +427,7 @@ def test_pm_EncodePublicVotesFormLinkedToPrevious(self):
votes_form.vote_number = 0
votes_form.label = u"My label"
votes_form.linked_to_previous = False
votes_form.apply_until_item_number = u'0'
votes_form._doApply()
load_view._update()
self.assertTrue(load_view.show_add_vote_linked_to_previous_icon(vote_number=0))
Expand All @@ -446,6 +448,7 @@ def test_pm_EncodePublicVotesFormLinkedToPrevious(self):
votes_form.vote_number = 1
votes_form.label = u"My label 1"
votes_form.linked_to_previous = True
votes_form.apply_until_item_number = u'0'
votes_form.votes = [{'voter_uid': hp3_uid, 'vote_value': 'yes'},
{'voter_uid': hp4_uid, 'vote_value': NOT_ENCODED_VOTE_VALUE}]
votes_form._doApply()
Expand Down Expand Up @@ -475,7 +478,7 @@ def test_pm_EncodeSecretVotesForm(self):

# encode votes form
votes_form = secret_item.restrictedTraverse(
'@@item_encode_secret_votes_form').form_instance
'@@item_encode_secret_votes_form')
self.request['PUBLISHED'] = secret_item
votes_form.meeting = meeting
votes_form.votes = [
Expand All @@ -486,6 +489,7 @@ def test_pm_EncodeSecretVotesForm(self):
votes_form.vote_number = 0
votes_form.label = u"My label"
votes_form.linked_to_previous = False
votes_form.apply_until_item_number = u'0'
# only for MeetingManagers
self.changeUser('pmCreator1')
self.assertRaises(Unauthorized, votes_form._doApply)
Expand All @@ -510,7 +514,7 @@ def test_pm_EncodeSecretVotesFormLinkedToPrevious(self):
self.assertFalse(load_view.show_add_vote_linked_to_previous_icon(vote_number=0))

# make linked vote addable
votes_form = secret_item.restrictedTraverse('@@item_encode_secret_votes_form').form_instance
votes_form = secret_item.restrictedTraverse('@@item_encode_secret_votes_form')
votes_form.meeting = meeting
votes_form.votes = [
{'vote_value': 'yes', 'vote_count': 0, 'vote_value_id': 'yes'},
Expand All @@ -519,6 +523,7 @@ def test_pm_EncodeSecretVotesFormLinkedToPrevious(self):
votes_form.vote_number = 0
votes_form.label = u"My label"
votes_form.linked_to_previous = False
votes_form.apply_until_item_number = u'0'
votes_form._doApply()
load_view._update()
self.assertTrue(load_view.show_add_vote_linked_to_previous_icon(vote_number=0))
Expand All @@ -534,6 +539,7 @@ def test_pm_EncodeSecretVotesFormLinkedToPrevious(self):
votes_form.vote_number = 1
votes_form.label = u"My label 1"
votes_form.linked_to_previous = True
votes_form.apply_until_item_number = u'0'
votes_form.votes = [{'vote_value': 'yes', 'vote_count': 1, 'vote_value_id': 'yes'}]
votes_form._doApply()
# 2 encoded votes
Expand Down

0 comments on commit 1c36b4e

Please sign in to comment.