<s> import factory <EOL> from django . contrib . auth . models import Group <EOL> from factory . django import DjangoModelFactory <EOL> from ralph . accounts . models import RalphUser , Region , Team <EOL> class RegionFactory ( DjangoModelFactory ) : <EOL> name = factory . Iterator ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> class Meta : <EOL> model = Region <EOL> django_get_or_create = [ '<STR_LIT:name>' ] <EOL> class GroupFactory ( DjangoModelFactory ) : <EOL> name = factory . Iterator ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> class Meta : <EOL> model = Group <EOL> django_get_or_create = [ '<STR_LIT:name>' ] <EOL> class UserFactory ( DjangoModelFactory ) : <EOL> username = factory . Faker ( '<STR_LIT>' ) <EOL> first_name = factory . Faker ( '<STR_LIT>' ) <EOL> last_name = factory . Faker ( '<STR_LIT>' ) <EOL> is_active = True <EOL> class Meta : <EOL> model = RalphUser <EOL> django_get_or_create = [ '<STR_LIT:username>' ] <EOL> @ factory . post_generation <EOL> def groups ( self , create , extracted , ** kwargs ) : <EOL> if not create : <EOL> return <EOL> if not extracted : <EOL> extracted = [ GroupFactory ( ) for i in range ( <NUM_LIT:2> ) ] <EOL> if extracted : <EOL> for group in extracted : <EOL> self . groups . add ( group ) <EOL> class TeamFactory ( DjangoModelFactory ) : <EOL> name = factory . Iterator ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> class Meta : <EOL> model = Team <EOL> django_get_or_create = [ '<STR_LIT:name>' ] </s>
