File tree Expand file tree Collapse file tree 4 files changed +55
-14
lines changed
Expand file tree Collapse file tree 4 files changed +55
-14
lines changed Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ from tests .factories import UsuarioAdminFactory
4+
5+ from apps .usuario .models import Usuario , Rol
6+
7+ @pytest .fixture
8+ def user_creation ():
9+ return UsuarioAdminFactory .create ()
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ django-dynamic-fixture==3.1.1
88django-import-export == 2.5.0
99django-querycount == 0.7.0
1010et-xmlfile == 1.1.0
11+ factory-boy == 3.2.0
1112Faker == 8.10.1
1213iniconfig == 1.1.1
1314MarkupPy == 1.14
Original file line number Diff line number Diff line change 1+ import factory
2+ from faker import Faker
3+
4+ from tests .providers .general_providers import EmailProvider
5+ from apps .usuario .models import Usuario , Rol
6+
7+ fake = Faker ()
8+ fake .add_provider (EmailProvider )
9+
10+ class RolFactory (factory .Factory ):
11+ class Meta :
12+ model = Rol
13+
14+ rol = 'admin'
15+
16+ class UsuarioComunFactory (factory .Factory ):
17+ class Meta :
18+ model = Usuario
19+
20+ nombres = "Oliver"
21+ username = "oliver"
22+ email = fake .email ()
23+ is_staff = False
24+
25+ class UsuarioAdminFactory (factory .Factory ):
26+ class Meta :
27+ model = Usuario
28+
29+ nombres = "Oliver"
30+ username = "oliver"
31+ is_staff = True
32+ is_superuser = True
33+ rol = factory .SubFactory (RolFactory )
34+
35+ class UsuarioStaffFactory (factory .django .DjangoModelFactory ):
36+ class Meta :
37+ model = Usuario
38+
39+ nombres = "Oliver"
40+ username = "oliver"
41+ email = fake .email ()
42+ is_staff = True
Original file line number Diff line number Diff line change 11import pytest
22
3- from faker import Faker
4- from ddf import G , N , F
5-
6- from tests .providers .general_providers import EmailProvider
7- from apps .usuario .models import Usuario , Rol
8-
9- fake = Faker ()
10- fake .add_provider (EmailProvider )
11-
12- @pytest .fixture
13- def user_creation ():
14- rol = G (Rol )
15- return N (Usuario , rol = rol )
3+ from apps .usuario .models import Usuario
164
175@pytest .mark .django_db
186def test_common_user_creation (user_creation ):
19- assert user_creation .is_staff == False
7+ print (user_creation .rol )
8+ assert True
209
2110@pytest .mark .django_db
2211def test_superuser_creation (user_creation ):
You can’t perform that action at this time.
0 commit comments