From 3486863fa2fdaaf14c3370593c02bbab1403b96a Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Mon, 15 Aug 2016 11:53:16 -0300 Subject: [PATCH] Fix some test that was failing Signed-off-by: Luciano Almeida --- sigi/apps/casas/test_casas.py | 3 ++- .../migrations/0003_auto_20160811_1553.py | 20 +++++++++++++++++++ sigi/apps/parlamentares/models.py | 3 ++- .../management/commands/test_sync_ldap.py | 12 ++++++----- .../migrations/0003_auto_20160811_1553.py | 20 +++++++++++++++++++ sigi/apps/servidores/models.py | 3 ++- sigi/settings/test.py | 8 +++++++- 7 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 sigi/apps/parlamentares/migrations/0003_auto_20160811_1553.py create mode 100644 sigi/apps/servidores/migrations/0003_auto_20160811_1553.py diff --git a/sigi/apps/casas/test_casas.py b/sigi/apps/casas/test_casas.py index 9e113c1..ad95dee 100644 --- a/sigi/apps/casas/test_casas.py +++ b/sigi/apps/casas/test_casas.py @@ -14,4 +14,5 @@ def some_parliaments(): 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] diff --git a/sigi/apps/parlamentares/migrations/0003_auto_20160811_1553.py b/sigi/apps/parlamentares/migrations/0003_auto_20160811_1553.py new file mode 100644 index 0000000..dbb1aad --- /dev/null +++ b/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'), + ), + ] diff --git a/sigi/apps/parlamentares/models.py b/sigi/apps/parlamentares/models.py index 2d80d38..176e2b6 100644 --- a/sigi/apps/parlamentares/models.py +++ b/sigi/apps/parlamentares/models.py @@ -27,7 +27,8 @@ class Parlamentar(models.Model): upload_to='fotos/parlamentares', width_field='foto_largura', height_field='foto_altura', - blank=True + blank=True, + null=True ) foto_largura = models.SmallIntegerField(editable=False, null=True) foto_altura = models.SmallIntegerField(editable=False, null=True) diff --git a/sigi/apps/servidores/management/commands/test_sync_ldap.py b/sigi/apps/servidores/management/commands/test_sync_ldap.py index 4cac024..d7512d0 100644 --- a/sigi/apps/servidores/management/commands/test_sync_ldap.py +++ b/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): - 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 return user -ALEX_LDAP, BRUNO_LDAP, RITA_LDAP = [ +ALEX_LDAP, BRUNO_LDAP, CLAUDIA_LDAP = [ ('...', {'cn': ['Alex Lima'], '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''' User 'alexlima' created. +Servidor 'Alex Lima' created. Users are synchronized. '''), @@ -67,7 +68,7 @@ Users are synchronized. # 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', )], - [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''' Users are synchronized. @@ -77,7 +78,7 @@ Users are synchronized. ([('alexlima', '___', '___', '___', '___', ), ('bruno', 'Bruno Almeida Prado', '___', 'Almeida Prado', '___', ), ('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'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', )], @@ -108,7 +109,7 @@ Users are synchronized. ([(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'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'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', )], @@ -119,6 +120,7 @@ Users are synchronized. def test_sync_users(before, ldap_users, after, messages, capsys): # setup + User.objects.all().delete() for user_setup in before: if type(user_setup) == tuple: create_stub_user(*user_setup) diff --git a/sigi/apps/servidores/migrations/0003_auto_20160811_1553.py b/sigi/apps/servidores/migrations/0003_auto_20160811_1553.py new file mode 100644 index 0000000..9e0e273 --- /dev/null +++ b/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'), + ), + ] diff --git a/sigi/apps/servidores/models.py b/sigi/apps/servidores/models.py index 204fb5f..e835815 100644 --- a/sigi/apps/servidores/models.py +++ b/sigi/apps/servidores/models.py @@ -71,7 +71,8 @@ class Servidor(models.Model): upload_to='fotos/servidores', width_field='foto_largura', height_field='foto_altura', - blank=True + blank=True, + null=True ) foto_largura = models.SmallIntegerField(editable=False, null=True) foto_altura = models.SmallIntegerField(editable=False, null=True) diff --git a/sigi/settings/test.py b/sigi/settings/test.py index 094b710..93dfe90 100644 --- a/sigi/settings/test.py +++ b/sigi/settings/test.py @@ -10,7 +10,13 @@ DATABASES = { 'USER': 'sigi', 'PASSWORD': 'sigi', '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', } }