Browse Source

Fix some test that was failing

Signed-off-by: Luciano Almeida <lucianoalmeida@interlegis.leg.br>
pull/6/head
Luciano Almeida 8 years ago
committed by Luciano Almeida
parent
commit
3486863fa2
  1. 3
      sigi/apps/casas/test_casas.py
  2. 20
      sigi/apps/parlamentares/migrations/0003_auto_20160811_1553.py
  3. 3
      sigi/apps/parlamentares/models.py
  4. 12
      sigi/apps/servidores/management/commands/test_sync_ldap.py
  5. 20
      sigi/apps/servidores/migrations/0003_auto_20160811_1553.py
  6. 3
      sigi/apps/servidores/models.py
  7. 8
      sigi/settings/test.py

3
sigi/apps/casas/test_casas.py

@ -14,4 +14,5 @@ def some_parliaments():
def parliaments_from_names(names): def parliaments_from_names(names):
return [G(CasaLegislativa, nome=name, foto=None, gerente_contas=None,) for name in names] return [G(CasaLegislativa, nome=name, foto=None, gerente_contas=None,
pesquisador=None,) for name in names]

20
sigi/apps/parlamentares/migrations/0003_auto_20160811_1553.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-08-11 15:53
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('parlamentares', '0002_auto_20160623_0829'),
]
operations = [
migrations.AlterField(
model_name='parlamentar',
name='foto',
field=models.ImageField(blank=True, height_field=b'foto_altura', null=True, upload_to=b'fotos/parlamentares', width_field=b'foto_largura'),
),
]

3
sigi/apps/parlamentares/models.py

@ -27,7 +27,8 @@ class Parlamentar(models.Model):
upload_to='fotos/parlamentares', upload_to='fotos/parlamentares',
width_field='foto_largura', width_field='foto_largura',
height_field='foto_altura', height_field='foto_altura',
blank=True blank=True,
null=True
) )
foto_largura = models.SmallIntegerField(editable=False, null=True) foto_largura = models.SmallIntegerField(editable=False, null=True)
foto_altura = models.SmallIntegerField(editable=False, null=True) foto_altura = models.SmallIntegerField(editable=False, null=True)

12
sigi/apps/servidores/management/commands/test_sync_ldap.py

@ -19,11 +19,11 @@ class StubCommand(Command):
def create_stub_user(username, nome_completo, first_name, last_name, email): def create_stub_user(username, nome_completo, first_name, last_name, email):
user = G(User, username=username, first_name=first_name, last_name=last_name, email=email) user = G(User, username=username, first_name=first_name, last_name=last_name, email=email, is_staff=True)
user.servidor.nome_completo = nome_completo user.servidor.nome_completo = nome_completo
return user return user
ALEX_LDAP, BRUNO_LDAP, RITA_LDAP = [ ALEX_LDAP, BRUNO_LDAP, CLAUDIA_LDAP = [
('...', ('...',
{'cn': ['Alex Lima'], {'cn': ['Alex Lima'],
'givenName': ['Alex'], 'givenName': ['Alex'],
@ -54,6 +54,7 @@ ALEX_LDAP, BRUNO_LDAP, RITA_LDAP = [
[(u'alexlima', u'Alex Lima', u'Alex', u'Lima', u'alexlima@interlegis.leg.br')], [(u'alexlima', u'Alex Lima', u'Alex', u'Lima', u'alexlima@interlegis.leg.br')],
u''' u'''
User 'alexlima' created. User 'alexlima' created.
Servidor 'Alex Lima' created.
Users are synchronized. Users are synchronized.
'''), '''),
@ -67,7 +68,7 @@ Users are synchronized.
# unicode encoding from LDAP data works well # unicode encoding from LDAP data works well
([('claudia', u'Cláudia de Cássia', u'Cláudia', u'de Cássia', 'claudia@interlegis.leg.br', )], ([('claudia', u'Cláudia de Cássia', u'Cláudia', u'de Cássia', 'claudia@interlegis.leg.br', )],
[RITA_LDAP], [CLAUDIA_LDAP],
[(u'claudia', u'Cláudia de Cássia', u'Cláudia', u'de Cássia', u'claudia@interlegis.leg.br', )], [(u'claudia', u'Cláudia de Cássia', u'Cláudia', u'de Cássia', u'claudia@interlegis.leg.br', )],
u''' u'''
Users are synchronized. Users are synchronized.
@ -77,7 +78,7 @@ Users are synchronized.
([('alexlima', '___', '___', '___', '___', ), ([('alexlima', '___', '___', '___', '___', ),
('bruno', 'Bruno Almeida Prado', '___', 'Almeida Prado', '___', ), ('bruno', 'Bruno Almeida Prado', '___', 'Almeida Prado', '___', ),
('claudia', '___', u'Cláudia', '___', 'claudia@interlegis.leg.br', )], ('claudia', '___', u'Cláudia', '___', 'claudia@interlegis.leg.br', )],
[ALEX_LDAP, BRUNO_LDAP, RITA_LDAP], [ALEX_LDAP, BRUNO_LDAP, CLAUDIA_LDAP],
[(u'alexlima', u'Alex Lima', u'Alex', u'Lima', u'alexlima@interlegis.leg.br', ), [(u'alexlima', u'Alex Lima', u'Alex', u'Lima', u'alexlima@interlegis.leg.br', ),
(u'bruno', u'Bruno Almeida Prado', u'Bruno', u'Almeida Prado', u'bruno@interlegis.leg.br', ), (u'bruno', u'Bruno Almeida Prado', u'Bruno', u'Almeida Prado', u'bruno@interlegis.leg.br', ),
(u'claudia', u'Cláudia de Cássia', u'Cláudia', u'de Cássia', u'claudia@interlegis.leg.br', )], (u'claudia', u'Cláudia de Cássia', u'Cláudia', u'de Cássia', u'claudia@interlegis.leg.br', )],
@ -108,7 +109,7 @@ Users are synchronized.
([(u'alexlima', u'Alex Lima', u'Alex', u'Lima', u'alexlima@interlegis.leg.br', ), ([(u'alexlima', u'Alex Lima', u'Alex', u'Lima', u'alexlima@interlegis.leg.br', ),
(u'bruno', u'Bruno Almeida Prado', u'Bruno', u'Almeida Prado', u'bruno@interlegis.leg.br', ), (u'bruno', u'Bruno Almeida Prado', u'Bruno', u'Almeida Prado', u'bruno@interlegis.leg.br', ),
(u'claudia', u'Cláudia de Cássia', u'Cláudia', u'de Cássia', u'claudia@interlegis.leg.br', )], (u'claudia', u'Cláudia de Cássia', u'Cláudia', u'de Cássia', u'claudia@interlegis.leg.br', )],
[ALEX_LDAP, RITA_LDAP], [ALEX_LDAP, CLAUDIA_LDAP],
[(u'alexlima', u'Alex Lima', u'Alex', u'Lima', u'alexlima@interlegis.leg.br', ), [(u'alexlima', u'Alex Lima', u'Alex', u'Lima', u'alexlima@interlegis.leg.br', ),
(u'bruno', u'Bruno Almeida Prado', u'Bruno', u'Almeida Prado', u'bruno@interlegis.leg.br', ), (u'bruno', u'Bruno Almeida Prado', u'Bruno', u'Almeida Prado', u'bruno@interlegis.leg.br', ),
(u'claudia', u'Cláudia de Cássia', u'Cláudia', u'de Cássia', u'claudia@interlegis.leg.br', )], (u'claudia', u'Cláudia de Cássia', u'Cláudia', u'de Cássia', u'claudia@interlegis.leg.br', )],
@ -119,6 +120,7 @@ Users are synchronized.
def test_sync_users(before, ldap_users, after, messages, capsys): def test_sync_users(before, ldap_users, after, messages, capsys):
# setup # setup
User.objects.all().delete()
for user_setup in before: for user_setup in before:
if type(user_setup) == tuple: if type(user_setup) == tuple:
create_stub_user(*user_setup) create_stub_user(*user_setup)

20
sigi/apps/servidores/migrations/0003_auto_20160811_1553.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-08-11 15:53
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('servidores', '0002_auto_20160623_0829'),
]
operations = [
migrations.AlterField(
model_name='servidor',
name='foto',
field=models.ImageField(blank=True, height_field=b'foto_altura', null=True, upload_to=b'fotos/servidores', width_field=b'foto_largura'),
),
]

3
sigi/apps/servidores/models.py

@ -71,7 +71,8 @@ class Servidor(models.Model):
upload_to='fotos/servidores', upload_to='fotos/servidores',
width_field='foto_largura', width_field='foto_largura',
height_field='foto_altura', height_field='foto_altura',
blank=True blank=True,
null=True
) )
foto_largura = models.SmallIntegerField(editable=False, null=True) foto_largura = models.SmallIntegerField(editable=False, null=True)
foto_altura = models.SmallIntegerField(editable=False, null=True) foto_altura = models.SmallIntegerField(editable=False, null=True)

8
sigi/settings/test.py

@ -10,7 +10,13 @@ DATABASES = {
'USER': 'sigi', 'USER': 'sigi',
'PASSWORD': 'sigi', 'PASSWORD': 'sigi',
'HOST': 'localhost', 'HOST': 'localhost',
'PORT': '5432', },
'moodle': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'moodle', # will be actually used as "test_sigi" by pytest-django
'USER': 'saberes',
'PASSWORD': 'A8oFvFWnvj',
'HOST': 'bdsaberes02h.interlegis.leg.br',
} }
} }

Loading…
Cancel
Save