mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 15:19:15 +02:00
Fixed #54: Now use pytest everywhere \o/
This commit is contained in:
parent
a7758395ee
commit
099cdfa99c
65 changed files with 1466 additions and 1467 deletions
|
@ -1,30 +0,0 @@
|
|||
import factory
|
||||
|
||||
from django.contrib.auth.models import Permission
|
||||
|
||||
|
||||
class UserFactory(factory.django.DjangoModelFactory):
|
||||
username = factory.Sequence(lambda n: 'user-{0}'.format(n))
|
||||
email = factory.Sequence(lambda n: 'user-{0}@example.com'.format(n))
|
||||
password = factory.PostGenerationMethodCall('set_password', 'password')
|
||||
|
||||
class Meta:
|
||||
model = 'users.User'
|
||||
django_get_or_create = ('username', )
|
||||
|
||||
@factory.post_generation
|
||||
def perms(self, create, extracted, **kwargs):
|
||||
if not create:
|
||||
# Simple build, do nothing.
|
||||
return
|
||||
|
||||
if extracted:
|
||||
perms = [
|
||||
Permission.objects.get(
|
||||
content_type__app_label=p.split('.')[0],
|
||||
codename=p.split('.')[1],
|
||||
)
|
||||
for p in extracted
|
||||
]
|
||||
# A list of permissions were passed in, use them
|
||||
self.user_permissions.add(*perms)
|
Loading…
Add table
Add a link
Reference in a new issue