From d6e4b7ceeb6641c2be9c7a60ef277b3852079eca Mon Sep 17 00:00:00 2001 From: Weslin-0101 Date: Wed, 6 Apr 2022 11:52:18 -0300 Subject: [PATCH 1/5] Adicionando o restante dos testes Co-authored-by: Co-authored-by: --- tests/urls_tests.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/urls_tests.py b/tests/urls_tests.py index 70de99f..ff2f1d7 100644 --- a/tests/urls_tests.py +++ b/tests/urls_tests.py @@ -4,6 +4,8 @@ from profile_app.models import User import os +# + @pytest.mark.django_db(transaction=False) class TestUserEndpoints: From c7878c8286d2f47b6b4f299bf3627a135f781b3c Mon Sep 17 00:00:00 2001 From: Guilherme Puida Moreira Date: Mon, 11 Apr 2022 23:06:08 -0300 Subject: [PATCH 2/5] Adicionado campos ao serializer do usuario --- profile_app/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profile_app/serializers.py b/profile_app/serializers.py index 04d96f8..2d1cb1d 100644 --- a/profile_app/serializers.py +++ b/profile_app/serializers.py @@ -22,7 +22,7 @@ class GetUserSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = User - fields = ['first_name', 'last_name'] + fields = ['first_name', 'last_name', 'username', 'user_type', 'cpf', 'id'] class UserSerializer(serializers.ModelSerializer): From 4fa2e016269b2c2ef559925ce3ad15868116409e Mon Sep 17 00:00:00 2001 From: Weslin-0101 Date: Sun, 17 Apr 2022 22:55:39 -0300 Subject: [PATCH 3/5] =?UTF-8?q?Adicionando=20unicidade=20no=20campo=20de?= =?UTF-8?q?=20cpf=20da=20cria=C3=A7=C3=A3o=20de=20usu=C3=A1rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile_app/migrations/0006_alter_user_cpf.py | 18 ++++++++++++++++++ profile_app/models.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 profile_app/migrations/0006_alter_user_cpf.py diff --git a/profile_app/migrations/0006_alter_user_cpf.py b/profile_app/migrations/0006_alter_user_cpf.py new file mode 100644 index 0000000..608cbab --- /dev/null +++ b/profile_app/migrations/0006_alter_user_cpf.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.6 on 2022-04-18 01:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('profile_app', '0005_create_first_user'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='cpf', + field=models.CharField(blank=True, max_length=15, unique=True), + ), + ] diff --git a/profile_app/models.py b/profile_app/models.py index 1ff8d46..3521f87 100644 --- a/profile_app/models.py +++ b/profile_app/models.py @@ -39,7 +39,7 @@ class User_Type(models.TextChoices): default=User_Type.VI) first_name = models.CharField(max_length=150, blank=True) last_name = models.CharField(max_length=150, blank=True) - cpf = models.CharField(max_length=15, blank=True) + cpf = models.CharField(max_length=15, blank=True, unique=True) is_superuser = models.BooleanField(default=False) USERNAME_FIELD = 'username' From 12f8420c76ec1602153a7bd3de3d5025fe484588 Mon Sep 17 00:00:00 2001 From: Weslin-0101 Date: Tue, 19 Apr 2022 02:11:28 -0300 Subject: [PATCH 4/5] Refatorando casos de testes --- tests/urls_tests.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/urls_tests.py b/tests/urls_tests.py index ff2f1d7..f7aed12 100644 --- a/tests/urls_tests.py +++ b/tests/urls_tests.py @@ -4,8 +4,6 @@ from profile_app.models import User import os -# - @pytest.mark.django_db(transaction=False) class TestUserEndpoints: @@ -34,8 +32,8 @@ def test_create(self, api_client): "user_type": "VI", "first_name": "test", "last_name": "test", + "password": os.getenv('POSTGRES_HOST'), "cpf": "11111111111", - "password": os.getenv('POSTGRES_HOST') } response = api_client.post( @@ -49,8 +47,10 @@ def test_create_superuser(self, api_client): data={ 'username': 'superuser', 'user_type': "AD", + 'first_name': 'superuser', + 'last_name': 'superuser', 'password': 'superuser', - 'cpf': '00000000000', + 'cpf': "00000000000", 'is_superuser': 'true' }, format='json' @@ -66,7 +66,8 @@ def test_get_user(self, api_client): "user_type": "AD", "first_name": "test", "last_name": "test", - "password": PASSWORD + "password": PASSWORD, + "cpf": "11111111111", } user_response = api_client.post( From a1d45e19aa7943550cd6fc5a1ae11ee11077bb44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Luis=20Baraky?= Date: Wed, 20 Apr 2022 12:16:55 -0300 Subject: [PATCH 5/5] =?UTF-8?q?Corrige=20fun=C3=A7=C3=A3o=20create=5Fsuper?= =?UTF-8?q?=5Fsuer.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile_app/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/profile_app/models.py b/profile_app/models.py index 3521f87..aeefa89 100644 --- a/profile_app/models.py +++ b/profile_app/models.py @@ -4,8 +4,10 @@ class UserManager(BaseUserManager): - def create_superuser(self, username, user_type, first_name, last_name, - cpf, password, **other_fields): + def create_superuser(self, username, cpf, password, **other_fields): + user_type = "AD" + first_name = "super" + last_name = "user" other_fields.setdefault('is_superuser', True)