-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66558d6
commit f1af1e4
Showing
5 changed files
with
65 additions
and
16 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
src/tupan/usuarios/migrations/0006_usuario_groups_usuario_user_permissions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 5.1.1 on 2024-09-20 12:44 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('auth', '0012_alter_user_first_name_max_length'), | ||
('usuarios', '0005_usuario_is_staff_usuario_is_superuser'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='usuario', | ||
name='groups', | ||
field=models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups'), | ||
), | ||
migrations.AddField( | ||
model_name='usuario', | ||
name='user_permissions', | ||
field=models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,29 @@ | ||
from django.test import TestCase | ||
import pytest | ||
from .models import Usuario | ||
|
||
# Create your tests here. | ||
class TestUsuario: | ||
|
||
@pytest.mark.django_db | ||
def test_criacao_usuarios(self): | ||
user1 = Usuario.objects.create_user(email='user@gmail.com', password='senha1') | ||
user2 = Usuario.objects.create_user(email='well@gmail.com', password='senha2') | ||
|
||
assert Usuario.objects.count() == 2 | ||
assert user1.email == 'user@gmail.com' | ||
assert user2.email == 'well@gmail.com' | ||
|
||
assert user1.check_password("senha1") | ||
assert user2.check_password("senha2") | ||
|
||
assert user1.ativo == True | ||
assert user2.ativo == True | ||
|
||
@pytest.mark.django_db | ||
def test_listagem_usuarios(self): | ||
user1 = Usuario.objects.create_user(email='user@gmail.com', password='senha1') | ||
user2 = Usuario.objects.create_user(email='well@gmail.com', password='senha2') | ||
|
||
usuarios = Usuario.objects.all() | ||
assert len(usuarios) == 2 | ||
assert user1 in usuarios | ||
assert user2 in usuarios |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters