<s> """<STR_LIT>""" <EOL> import factory <EOL> from django . contrib . auth . models import Group <EOL> from . import models <EOL> class PermissionFactory ( factory . DjangoModelFactory ) : <EOL> """<STR_LIT>""" <EOL> class Meta : <EOL> abstract = True <EOL> @ factory . post_generation <EOL> def set_permission ( self , create , extracted , ** kwargs ) : <EOL> if not create : <EOL> return <EOL> self . post_create ( models . User . objects . filter ( is_superuser = True ) . first ( ) ) <EOL> class GroupFactory ( factory . DjangoModelFactory ) : <EOL> """<STR_LIT>""" <EOL> class Meta : <EOL> model = Group <EOL> name = '<STR_LIT>' <EOL> class UserFactory ( PermissionFactory ) : <EOL> """<STR_LIT>""" <EOL> class Meta : <EOL> model = models . User <EOL> django_get_or_create = ( "<STR_LIT:username>" , ) <EOL> email = factory . LazyAttribute ( lambda a : a . username ) <EOL> password = '<STR_LIT>' <EOL> @ factory . post_generation <EOL> def groups ( self , create , extracted , ** kwargs ) : <EOL> if not create : <EOL> return <EOL> if extracted : <EOL> for group in extracted : <EOL> self . groups . add ( Group . objects . get ( name = group ) ) </s>
