Skip to content

Commit

Permalink
Merge pull request #13 from bencrealc/mrespuesta
Browse files Browse the repository at this point in the history
Test votacion binaria
  • Loading branch information
bencrealc authored Jan 5, 2022
2 parents 2987d53 + 6504704 commit 21da4de
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
6 changes: 5 additions & 1 deletion decide/decide/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@
'voting',
]

BASEURL = 'http://localhost:8000/'
BASEURL = 'https://decide-penyagolosa.herokuapp.com/'

APIS = {}

import django_heroku
django_heroku.settings(locals())

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
Expand Down
41 changes: 19 additions & 22 deletions decide/voting/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from mixnet.mixcrypt import ElGamal
from mixnet.mixcrypt import MixCrypt
from mixnet.models import Auth
from voting.models import Voting, Question, QuestionOption, Detector, Percentage
from voting.models import Voting, Question, QuestionOption


class VotingTestCase(BaseTestCase):
Expand Down Expand Up @@ -47,6 +47,23 @@ def create_voting(self):

return v

def test_create_binary_voting(self):
q = Question(desc='binary voting', binary_question=True)
q.save()

opt = QuestionOption(question=q)
opt.save()

v = Voting(name='test voting', question=q)
v.save()

a, _ = Auth.objects.get_or_create(url=settings.BASEURL,
defaults={'me': True, 'name': 'test auth'})
a.save()
v.auths.add(a)

return v

def create_voters(self, v):
for i in range(100):
u, _ = User.objects.get_or_create(username='testvoter{}'.format(i))
Expand Down Expand Up @@ -106,27 +123,7 @@ def test_complete_voting(self):
for q in v.postproc:
self.assertEqual(tally.get(q["number"], 0), q["votes"])

def test_create_detector_word(self):
detector = Detector(word="palabra")
detector.save()
self.assertEqual(detector.word, "palabra")

def test_create_percentage(self):
percentage = Percentage(number=25)
percentage.save()
self.assertEqual(percentage.number, 25)

def test_update_detector(self):
detector = Detector(word="palabra")
detector.word = "palabra2"
detector.save()
self.assertEqual(detector.word, "palabra2")

def test_update_percentage(self):
percentage = Percentage(number=25)
percentage.number = 30
percentage.save()
self.assertEqual(percentage.number, 30)


def test_create_voting_from_api(self):
data = {'name': 'Example'}
Expand Down

0 comments on commit 21da4de

Please sign in to comment.