Populate account table
[vagrant-mail.git] / database / platal / management / commands / fake_email_accounts.py
similarity index 75%
rename from database/platal/static_data.py
rename to database/platal/management/commands/fake_email_accounts.py
index 14a0ad5..677a33f 100644 (file)
 #*  Foundation, Inc.,                                                      *
 #*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
 #***************************************************************************/
-"""Define the data which must be initially in the database"""
+"""Create fake email accounts in the database for testing purpose"""
 from __future__ import unicode_literals
 
+from django.core.management.base import BaseCommand
+from ... import factories, models
 
-# XXX TODO Find a Django-way to do this
-AccountType...
+
+class Command(BaseCommand):
+    help = "Create fake email accounts in the database"
+
+    def handle(self, *args, **options):
+        # Remove every account from the database
+        models.Account.objects.all().delete()
+
+        # Create several accounts
+        for i in range(20):
+            account = factories.AccountFactory.create()