Skip to content

Commit

Permalink
Merge pull request #18 from bencrealc/lofensivo
Browse files Browse the repository at this point in the history
Resuelto test de lofensivo y configurado docker
  • Loading branch information
bencrealc authored Jan 6, 2022
2 parents 7f599ce + 62b11e3 commit d760a83
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
37 changes: 20 additions & 17 deletions decide/voting/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,6 @@ 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 @@ -123,6 +106,26 @@ def test_complete_voting(self):
for q in v.postproc:
self.assertEqual(tally.get(q["number"], 0), q["votes"])

def test_lofensivo_dont_pass(self):
self.login()
question = Question(desc='Tonto, esta descripcion contiene alguna palabra ofensiva? Pis, ceporro')
with self.assertRaises(ValidationError):
question.clean()

def test_lofensivo_pass_by_words(self):
self.login()
question = Question(desc='Esta descripcion no contiene lenguaje ofensivo')
question.clean()
self.assertEqual(question.desc, 'Esta descripcion no contiene lenguaje ofensivo')

def test_lofensivo_pass_by_percentage(self):
self.login()
question = Question(desc='Esta descripcion contiene solo una palabra ofensiva, tonto, pero se necesita que el 20 por ciento sean palabras ofensivas')
question.clean()
self.assertEqual(question.desc, 'Esta descripcion contiene solo una palabra ofensiva, tonto, pero se necesita que el 20 por ciento sean palabras ofensivas')



def test_create_voting_from_api(self):
data = {'name': 'Example'}
response = self.client.post('/voting/', data, format='json')
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from python:alpine
from python:3.7-alpine

RUN apk add --no-cache git postgresql-dev gcc libc-dev
RUN apk add --no-cache gcc g++ make libffi-dev python3-dev build-base
Expand Down
4 changes: 3 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ services:
db:
restart: always
container_name: decide_db
image: postgres:alpine
image: postgres:10.15-alpine
volumes:
- db:/var/lib/postgresql/data
networks:
- decide
environment:
- POSTGRES_PASSWORD=postgres
web:
restart: always
container_name: decide_web
Expand Down
1 change: 1 addition & 0 deletions docker/docker-settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD':'postgres',
'HOST': 'db',
'PORT': 5432,
}
Expand Down

0 comments on commit d760a83

Please sign in to comment.