<s> """<STR_LIT>""" <EOL> import factory <EOL> from modoboa . core . factories import PermissionFactory , UserFactory <EOL> from . import models <EOL> class DomainFactory ( PermissionFactory ) : <EOL> """<STR_LIT>""" <EOL> class Meta : <EOL> model = models . Domain <EOL> django_get_or_create = ( "<STR_LIT:name>" , ) <EOL> type = "<STR_LIT>" <EOL> quota = <NUM_LIT:10> <EOL> enabled = True <EOL> class DomainAliasFactory ( PermissionFactory ) : <EOL> """<STR_LIT>""" <EOL> class Meta : <EOL> model = models . DomainAlias <EOL> django_get_or_create = ( "<STR_LIT:name>" , ) <EOL> target = factory . SubFactory ( DomainFactory ) <EOL> enabled = True <EOL> class MailboxFactory ( PermissionFactory ) : <EOL> """<STR_LIT>""" <EOL> class Meta : <EOL> model = models . Mailbox <EOL> django_get_or_create = ( "<STR_LIT:address>" , "<STR_LIT>" ) <EOL> domain = factory . SubFactory ( DomainFactory ) <EOL> user = factory . SubFactory ( UserFactory ) <EOL> quota = <NUM_LIT:10> <EOL> enabled = True <EOL> class AliasRecipientFactory ( factory . django . DjangoModelFactory ) : <EOL> class Meta : <EOL> model = models . AliasRecipient <EOL> class AliasFactory ( PermissionFactory ) : <EOL> class Meta : <EOL> model = models . Alias <EOL> enabled = True <EOL> def populate_database ( ) : <EOL> """<STR_LIT>""" <EOL> dom = DomainFactory ( name = "<STR_LIT>" ) <EOL> admin = UserFactory ( <EOL> username = "<STR_LIT>" , groups = ( '<STR_LIT>' , ) , <EOL> password = '<STR_LIT>' <EOL> ) <EOL> MailboxFactory ( address = '<STR_LIT>' , domain = dom , user = admin ) <EOL> account = UserFactory . create ( <EOL> username = "<STR_LIT>" , groups = ( '<STR_LIT>' , ) , <EOL> ) <EOL> MailboxFactory . create ( address = '<STR_LIT:user>' , domain = dom , user = account ) <EOL> al = AliasFactory . create ( <EOL> address = '<STR_LIT>' , domain = dom <EOL> ) <EOL> AliasRecipientFactory . create ( <EOL> address = '<STR_LIT>' , alias = al ) <EOL> al = AliasFactory . create ( <EOL> address = '<STR_LIT>' , domain = dom <EOL> ) <EOL> mb = account . mailbox <EOL> AliasRecipientFactory . create ( <EOL> address = mb . full_address , alias = al , r_mailbox = mb ) <EOL> al = AliasFactory . create ( <EOL> address = '<STR_LIT>' , domain = dom <EOL> ) <EOL> for address in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> AliasRecipientFactory . create ( address = address , alias = al ) <EOL> dom . add_admin ( admin ) <EOL> dom2 = DomainFactory . create ( name = '<STR_LIT>' , quota = <NUM_LIT:0> ) <EOL> admin = UserFactory . create ( <EOL> username = '<STR_LIT>' , groups = ( '<STR_LIT>' , ) , <EOL> password = '<STR_LIT>' <EOL> ) <EOL> MailboxFactory . create ( address = '<STR_LIT>' , domain = dom2 , user = admin ) <EOL> u = UserFactory . create ( <EOL> username = '<STR_LIT>' , groups = ( '<STR_LIT>' , ) <EOL> ) <EOL> MailboxFactory . create ( address = '<STR_LIT:user>' , domain = dom2 , user = u ) <EOL> dom2 . add_admin ( admin ) </s>
