Add migration for creation of Fairphone staff group

Issue: HIC-247
Change-Id: I44b3db32e3646fae8d7d9ff37dc203c6c2c65756
diff --git a/README.md b/README.md
index 1e75f05..bd79db2 100644
--- a/README.md
+++ b/README.md
@@ -97,15 +97,13 @@
     python manage.py shell -c "
         from django.contrib.auth.models import Group, User
         admin = User.objects.get(username='admin')
-        stats_group = Group.objects.create(name='FairphoneSoftwareTeam')
+        stats_group = Group.objects.get(name='FairphoneSoftwareTeam')
         stats_group.user_set.add(admin)
         "
 
 * You need a running server and a super-user account;
-* Head to `http://localhost:8000/hiccup/admin/auth/group/`;
-* Create a new group named `FairphoneSoftwareTeam`;
-* Go back to the user list at `http://localhost:8000/hiccup/admin/auth/user/` and add your
-  super-user to the new group.
+* Go to the user list at `http://localhost:8000/hiccup/admin/auth/user/` and add your
+  super-user to the 'FairphoneSoftwareTeam' group.
 
 ## API Documentation
 
diff --git a/crashreport_stats/tests/utils.py b/crashreport_stats/tests/utils.py
index 9157a63..279320b 100644
--- a/crashreport_stats/tests/utils.py
+++ b/crashreport_stats/tests/utils.py
@@ -336,8 +336,7 @@
         cls.admin = APIClient()
         cls.admin.force_login(admin_user)
 
-        fp_staff_group = Group(name=FP_STAFF_GROUP_NAME)
-        fp_staff_group.save()
+        fp_staff_group = Group.objects.get(name=FP_STAFF_GROUP_NAME)
         fp_staff_user = User.objects.create_user(
             "fp_staff", "somebody@fairphone.com", "thepassword"
         )
diff --git a/crashreports/migrations/0005_add_fp_staff_group.py b/crashreports/migrations/0005_add_fp_staff_group.py
new file mode 100644
index 0000000..86d4eba
--- /dev/null
+++ b/crashreports/migrations/0005_add_fp_staff_group.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+
+"""Migrations for creating the Fairphone staff authentication group."""
+# pylint: disable=invalid-name
+
+from django.contrib.auth.models import Group
+from django.db import migrations
+
+from hiccup.allauth_adapters import FP_STAFF_GROUP_NAME
+
+
+def add_fp_staff_group(apps, schema_editor):
+    """Create the Fairphone staff group if it does not exist."""
+    # pylint: disable=unused-argument
+
+    if not Group.objects.filter(name=FP_STAFF_GROUP_NAME).exists():
+        Group.objects.create(name=FP_STAFF_GROUP_NAME)
+
+
+class Migration(migrations.Migration):
+    """Run the migration script."""
+
+    dependencies = [("crashreports", "0004_update_logfile_paths")]
+
+    operations = [migrations.RunPython(add_fp_staff_group)]
diff --git a/hiccup/tests/test_allauth_adapters.py b/hiccup/tests/test_allauth_adapters.py
index c349688..1ab17bc 100644
--- a/hiccup/tests/test_allauth_adapters.py
+++ b/hiccup/tests/test_allauth_adapters.py
@@ -18,6 +18,8 @@
 class Dummy:
     """Create dummies class instances for testing."""
 
+    # pylint: disable=too-few-public-methods
+
     EMAIL_FAIRPHONE = "test@fairphone.com"
     EMAIL_OTHER = "test@test.com"
 
@@ -40,13 +42,6 @@
         )
         return sociallogin
 
-    @staticmethod
-    def create_fp_staff_group():
-        """Create a FP staff group instance and save it to the database."""
-        group = Group(name=FP_STAFF_GROUP_NAME)
-        group.save()
-        return group
-
 
 class FairphoneAccountAdapterTests(TestCase):
     """Tests for the Fairphone account adapter."""
@@ -74,8 +69,8 @@
 
     def test_save_user_with_fp_email(self):
         """Test saving a user with a Fairphone E-Mail address."""
-        # Create the Fairphone staff group
-        fp_staff_group = Dummy.create_fp_staff_group()
+        # Get the Fairphone staff group
+        fp_staff_group = Group.objects.get(name=FP_STAFF_GROUP_NAME)
 
         # Save a user with a Fairphone E-Mail address
         user = self._save_user(Dummy.EMAIL_FAIRPHONE)
@@ -85,8 +80,8 @@
 
     def test_save_user_without_fp_email(self):
         """Test saving a user without a Fairphone E-Mail address."""
-        # Create the Fairphone staff group
-        fp_staff_group = Dummy.create_fp_staff_group()
+        # Get the Fairphone staff group
+        fp_staff_group = Group.objects.get(name=FP_STAFF_GROUP_NAME)
 
         # Save a user without a Fairphone E-Mail address
         user = self._save_user(Dummy.EMAIL_OTHER)