Format all python files using the formatter

Run `git ls-files '*.py' | xargs black`

Issue: HIC-161
Change-Id: I1619e6296bc4036504c5bb73128f769a1b7b688d
diff --git a/crashreport_stats/tests.py b/crashreport_stats/tests.py
index e852700..68f8e82 100644
--- a/crashreport_stats/tests.py
+++ b/crashreport_stats/tests.py
@@ -12,84 +12,91 @@
 from rest_framework.test import APITestCase, APIClient
 
 from crashreport_stats.models import (
-    Version, VersionDaily, RadioVersion, RadioVersionDaily, StatsMetadata
+    Version,
+    VersionDaily,
+    RadioVersion,
+    RadioVersionDaily,
+    StatsMetadata,
 )
 
 from crashreports.models import User, Device, Crashreport, HeartBeat
 
 
-class Dummy():
+class Dummy:
     """Class for creating dummy instances for testing."""
 
     # Valid unique entries
-    BUILD_FINGERPRINTS = [(
-        'Fairphone/FP2/FP2:5.1/FP2/r4275.1_FP2_gms76_1.13.0:user/release-keys'
-    ), (
-        'Fairphone/FP2/FP2:5.1.1/FP2-gms75.1.13.0/FP2-gms75.1.13.0'
-        ':user/release-keys'
-    ), (
-        'Fairphone/FP2/FP2:6.0.1/FP2-gms-18.04.1/FP2-gms-18.04.1'
-        ':user/release-keys'
-    ), (
-        'Fairphone/FP2/FP2:7.1.2/18.07.2/gms-7480c31d'
-        ':user/release-keys'
-    )]
-    RADIO_VERSIONS = ['4437.1-FP2-0-07', '4437.1-FP2-0-08',
-                      '4437.1-FP2-0-09', '4437.1-FP2-0-10']
+    BUILD_FINGERPRINTS = [
+        (
+            "Fairphone/FP2/FP2:5.1/FP2/r4275.1_FP2_gms76_1.13.0:user/release-keys"
+        ),
+        (
+            "Fairphone/FP2/FP2:5.1.1/FP2-gms75.1.13.0/FP2-gms75.1.13.0"
+            ":user/release-keys"
+        ),
+        (
+            "Fairphone/FP2/FP2:6.0.1/FP2-gms-18.04.1/FP2-gms-18.04.1"
+            ":user/release-keys"
+        ),
+        ("Fairphone/FP2/FP2:7.1.2/18.07.2/gms-7480c31d" ":user/release-keys"),
+    ]
+    RADIO_VERSIONS = [
+        "4437.1-FP2-0-07",
+        "4437.1-FP2-0-08",
+        "4437.1-FP2-0-09",
+        "4437.1-FP2-0-10",
+    ]
 
     DATES = [date(2018, 3, 19), date(2018, 3, 26), date(2018, 5, 1)]
 
     DEFAULT_DUMMY_VERSION_VALUES = {
-        'build_fingerprint': BUILD_FINGERPRINTS[0],
-        'first_seen_on': DATES[1],
-        'released_on': DATES[0]
+        "build_fingerprint": BUILD_FINGERPRINTS[0],
+        "first_seen_on": DATES[1],
+        "released_on": DATES[0],
     }
 
-    DEFAULT_DUMMY_VERSION_DAILY_VALUES = {
-        'date': DATES[1]
-    }
+    DEFAULT_DUMMY_VERSION_DAILY_VALUES = {"date": DATES[1]}
 
     DEFAULT_DUMMY_RADIO_VERSION_VALUES = {
-        'radio_version': RADIO_VERSIONS[0],
-        'first_seen_on': DATES[1],
-        'released_on': DATES[0]
+        "radio_version": RADIO_VERSIONS[0],
+        "first_seen_on": DATES[1],
+        "released_on": DATES[0],
     }
 
-    DEFAULT_DUMMY_RADIO_VERSION_DAILY_VALUES = {
-        'date': DATES[1]
-    }
+    DEFAULT_DUMMY_RADIO_VERSION_DAILY_VALUES = {"date": DATES[1]}
 
     DEFAULT_DUMMY_STATSMETADATA_VALUES = {
-        'updated_at': datetime(2018, 6, 15, 2, 12, 24, tzinfo=pytz.utc),
+        "updated_at": datetime(2018, 6, 15, 2, 12, 24, tzinfo=pytz.utc)
     }
 
     DEFAULT_DUMMY_DEVICE_VALUES = {
-        'board_date': datetime(2015, 12, 15, 1, 23, 45, tzinfo=pytz.utc),
-        'chipset': 'Qualcomm MSM8974PRO-AA',
-        'token': '64111c62d521fb4724454ca6dea27e18f93ef56e'
+        "board_date": datetime(2015, 12, 15, 1, 23, 45, tzinfo=pytz.utc),
+        "chipset": "Qualcomm MSM8974PRO-AA",
+        "token": "64111c62d521fb4724454ca6dea27e18f93ef56e",
     }
 
-    DEFAULT_DUMMY_USER_VALUES = {
-        'username': 'testuser'
-    }
+    DEFAULT_DUMMY_USER_VALUES = {"username": "testuser"}
 
     DEFAULT_DUMMY_HEARTBEAT_VALUES = {
-        'app_version': 10100,
-        'uptime': (
-            'up time: 16 days, 21:49:56, idle time: 5 days, 20:55:04, '
-            'sleep time: 10 days, 20:46:27'),
-        'build_fingerprint': BUILD_FINGERPRINTS[0],
-        'radio_version': RADIO_VERSIONS[0],
-        'date': datetime(2018, 3, 19, tzinfo=pytz.utc),
+        "app_version": 10100,
+        "uptime": (
+            "up time: 16 days, 21:49:56, idle time: 5 days, 20:55:04, "
+            "sleep time: 10 days, 20:46:27"
+        ),
+        "build_fingerprint": BUILD_FINGERPRINTS[0],
+        "radio_version": RADIO_VERSIONS[0],
+        "date": datetime(2018, 3, 19, tzinfo=pytz.utc),
     }
 
     DEFAULT_DUMMY_CRASHREPORT_VALUES = DEFAULT_DUMMY_HEARTBEAT_VALUES.copy()
-    DEFAULT_DUMMY_CRASHREPORT_VALUES.update({
-        'is_fake_report': 0,
-        'boot_reason': Crashreport.BOOT_REASON_UNKOWN,
-        'power_on_reason': 'it was powered on',
-        'power_off_reason': 'something happened and it went off',
-    })
+    DEFAULT_DUMMY_CRASHREPORT_VALUES.update(
+        {
+            "is_fake_report": 0,
+            "boot_reason": Crashreport.BOOT_REASON_UNKOWN,
+            "power_on_reason": "it was powered on",
+            "power_off_reason": "something happened and it went off",
+        }
+    )
 
     @staticmethod
     def update_copy(original, update):
@@ -110,8 +117,9 @@
         Returns: The created user instance.
 
         """
-        entity = User(**Dummy.update_copy(
-            Dummy.DEFAULT_DUMMY_USER_VALUES, kwargs))
+        entity = User(
+            **Dummy.update_copy(Dummy.DEFAULT_DUMMY_USER_VALUES, kwargs)
+        )
         entity.save()
         return entity
 
@@ -128,8 +136,10 @@
         Returns: The created device instance.
 
         """
-        entity = Device(user=user, **Dummy.update_copy(
-            Dummy.DEFAULT_DUMMY_DEVICE_VALUES, kwargs))
+        entity = Device(
+            user=user,
+            **Dummy.update_copy(Dummy.DEFAULT_DUMMY_DEVICE_VALUES, kwargs)
+        )
         entity.save()
         return entity
 
@@ -148,15 +158,25 @@
 
         """
         if report_type == HeartBeat:
-            entity = HeartBeat(device=device, **Dummy.update_copy(
-                Dummy.DEFAULT_DUMMY_HEARTBEAT_VALUES, kwargs))
+            entity = HeartBeat(
+                device=device,
+                **Dummy.update_copy(
+                    Dummy.DEFAULT_DUMMY_HEARTBEAT_VALUES, kwargs
+                )
+            )
         elif report_type == Crashreport:
-            entity = Crashreport(device=device, **Dummy.update_copy(
-                Dummy.DEFAULT_DUMMY_CRASHREPORT_VALUES, kwargs))
+            entity = Crashreport(
+                device=device,
+                **Dummy.update_copy(
+                    Dummy.DEFAULT_DUMMY_CRASHREPORT_VALUES, kwargs
+                )
+            )
         else:
             raise RuntimeError(
-                'No dummy report instance can be created for {}'.format(
-                    report_type.__name__))
+                "No dummy report instance can be created for {}".format(
+                    report_type.__name__
+                )
+            )
         entity.save()
         return entity
 
@@ -172,8 +192,9 @@
         Returns: The created version instance.
 
         """
-        entity = Version(**Dummy.update_copy(
-            Dummy.DEFAULT_DUMMY_VERSION_VALUES, kwargs))
+        entity = Version(
+            **Dummy.update_copy(Dummy.DEFAULT_DUMMY_VERSION_VALUES, kwargs)
+        )
         entity.save()
         return entity
 
@@ -189,8 +210,11 @@
         Returns: The created radio version instance.
 
         """
-        entity = RadioVersion(**Dummy.update_copy(
-            Dummy.DEFAULT_DUMMY_RADIO_VERSION_VALUES, kwargs))
+        entity = RadioVersion(
+            **Dummy.update_copy(
+                Dummy.DEFAULT_DUMMY_RADIO_VERSION_VALUES, kwargs
+            )
+        )
         entity.save()
         return entity
 
@@ -206,8 +230,12 @@
         Returns: The created daily version instance.
 
         """
-        entity = VersionDaily(version=version, **Dummy.update_copy(
-            Dummy.DEFAULT_DUMMY_VERSION_DAILY_VALUES, kwargs))
+        entity = VersionDaily(
+            version=version,
+            **Dummy.update_copy(
+                Dummy.DEFAULT_DUMMY_VERSION_DAILY_VALUES, kwargs
+            )
+        )
         entity.save()
         return entity
 
@@ -223,8 +251,12 @@
         Returns: The created daily radio version instance.
 
         """
-        entity = RadioVersionDaily(version=version, **Dummy.update_copy(
-            Dummy.DEFAULT_DUMMY_RADIO_VERSION_DAILY_VALUES, kwargs))
+        entity = RadioVersionDaily(
+            version=version,
+            **Dummy.update_copy(
+                Dummy.DEFAULT_DUMMY_RADIO_VERSION_DAILY_VALUES, kwargs
+            )
+        )
         entity.save()
         return entity
 
@@ -240,8 +272,11 @@
         Returns: The created stats metadata instance.
 
         """
-        entity = StatsMetadata(**Dummy.update_copy(
-            Dummy.DEFAULT_DUMMY_STATSMETADATA_VALUES, kwargs))
+        entity = StatsMetadata(
+            **Dummy.update_copy(
+                Dummy.DEFAULT_DUMMY_STATSMETADATA_VALUES, kwargs
+            )
+        )
         entity.save()
         return entity
 
@@ -251,11 +286,11 @@
 
     # The attribute name characterising the unicity of a stats entry (the
     # named identifier)
-    unique_entry_name = 'build_fingerprint'
+    unique_entry_name = "build_fingerprint"
     # The collection of unique entries to post
     unique_entries = Dummy.BUILD_FINGERPRINTS
     # The URL to retrieve the stats entries from
-    endpoint_url = reverse('hiccup_stats_api_v1_versions')
+    endpoint_url = reverse("hiccup_stats_api_v1_versions")
 
     @classmethod
     def setUpTestData(cls):  # noqa: N802
@@ -265,7 +300,8 @@
         server is stored in self.admin.
         """
         admin_user = User.objects.create_superuser(
-            'somebody', 'somebody@example.com', 'thepassword')
+            "somebody", "somebody@example.com", "thepassword"
+        )
         cls.admin = APIClient()
         cls.admin.force_authenticate(admin_user)
 
@@ -274,14 +310,14 @@
         return Dummy.create_dummy_version(**kwargs)
 
     def _get_with_params(self, url, params):
-        return self.admin.get('{}?{}'.format(url, urlencode(params)))
+        return self.admin.get("{}?{}".format(url, urlencode(params)))
 
     def _assert_result_length_is(self, response, count):
         self.assertEqual(response.status_code, status.HTTP_200_OK)
-        self.assertIn('results', response.data)
-        self.assertIn('count', response.data)
-        self.assertEqual(response.data['count'], count)
-        self.assertEqual(len(response.data['results']), count)
+        self.assertIn("results", response.data)
+        self.assertIn("count", response.data)
+        self.assertEqual(response.data["count"], count)
+        self.assertEqual(len(response.data["results"]), count)
 
     def _assert_device_owner_has_no_get_access(self, entries_url):
         # Create a user and device
@@ -290,7 +326,7 @@
 
         # Create authenticated client
         user = APIClient()
-        user.credentials(HTTP_AUTHORIZATION='Token ' + device.token)
+        user.credentials(HTTP_AUTHORIZATION="Token " + device.token)
 
         # Try getting entries using the client
         response = user.get(entries_url)
@@ -302,8 +338,10 @@
 
         # Expect only the single matching result to be returned
         self._assert_result_length_is(response, 1)
-        self.assertEqual(response.data['results'][0][self.unique_entry_name],
-                         getattr(expected_result, self.unique_entry_name))
+        self.assertEqual(
+            response.data["results"][0][self.unique_entry_name],
+            getattr(expected_result, self.unique_entry_name),
+        )
 
 
 class VersionTestCase(_VersionTestCase):
@@ -311,9 +349,7 @@
 
     def _create_version_entities(self):
         versions = [
-            self._create_dummy_version(
-                **{self.unique_entry_name: unique_entry}
-            )
+            self._create_dummy_version(**{self.unique_entry_name: unique_entry})
             for unique_entry in self.unique_entries
         ]
         return versions
@@ -348,11 +384,11 @@
 
         # List entities with filter
         filter_params = {
-            self.unique_entry_name: getattr(versions[0],
-                                            self.unique_entry_name)
+            self.unique_entry_name: getattr(versions[0], self.unique_entry_name)
         }
-        self._assert_filter_result_matches(filter_params,
-                                           expected_result=versions[0])
+        self._assert_filter_result_matches(
+            filter_params, expected_result=versions[0]
+        )
 
     def test_filter_versions_by_release_type(self):
         """Test filtering versions by release type."""
@@ -361,11 +397,15 @@
         i = 0
         for is_official_release in True, False:
             for is_beta_release in True, False:
-                versions.append(self._create_dummy_version(**{
-                    'is_official_release': is_official_release,
-                    'is_beta_release': is_beta_release,
-                    self.unique_entry_name: self.unique_entries[i]
-                }))
+                versions.append(
+                    self._create_dummy_version(
+                        **{
+                            "is_official_release": is_official_release,
+                            "is_beta_release": is_beta_release,
+                            self.unique_entry_name: self.unique_entries[i],
+                        }
+                    )
+                )
                 i += 1
 
         # # Listing all entities should return the correct result length
@@ -375,11 +415,12 @@
         # List each of the entities with the matching filter params
         for version in versions:
             filter_params = {
-                'is_official_release': version.is_official_release,
-                'is_beta_release': version.is_beta_release
+                "is_official_release": version.is_official_release,
+                "is_beta_release": version.is_beta_release,
             }
-            self._assert_filter_result_matches(filter_params,
-                                               expected_result=version)
+            self._assert_filter_result_matches(
+                filter_params, expected_result=version
+            )
 
     def test_filter_versions_by_first_seen_date(self):
         """Test filtering versions by first seen date."""
@@ -394,18 +435,19 @@
         self._assert_result_length_is(response, len(versions))
 
         # Expect the single matching result to be returned
-        filter_params = {'first_seen_after': Dummy.DATES[2]}
-        self._assert_filter_result_matches(filter_params,
-                                           expected_result=versions[0])
+        filter_params = {"first_seen_after": Dummy.DATES[2]}
+        self._assert_filter_result_matches(
+            filter_params, expected_result=versions[0]
+        )
 
 
 # pylint: disable=too-many-ancestors
 class RadioVersionTestCase(VersionTestCase):
     """Test the RadioVersion REST endpoint."""
 
-    unique_entry_name = 'radio_version'
+    unique_entry_name = "radio_version"
     unique_entries = Dummy.RADIO_VERSIONS
-    endpoint_url = reverse('hiccup_stats_api_v1_radio_versions')
+    endpoint_url = reverse("hiccup_stats_api_v1_radio_versions")
 
     @staticmethod
     def _create_dummy_version(**kwargs):
@@ -415,7 +457,7 @@
 class VersionDailyTestCase(_VersionTestCase):
     """Test the VersionDaily REST endpoint."""
 
-    endpoint_url = reverse('hiccup_stats_api_v1_version_daily')
+    endpoint_url = reverse("hiccup_stats_api_v1_version_daily")
 
     @staticmethod
     def _create_dummy_daily_version(version, **kwargs):
@@ -423,9 +465,7 @@
 
     def _create_version_entities(self):
         versions = [
-            self._create_dummy_version(
-                **{self.unique_entry_name: unique_entry}
-            )
+            self._create_dummy_version(**{self.unique_entry_name: unique_entry})
             for unique_entry in self.unique_entries
         ]
         versions_daily = [
@@ -464,12 +504,13 @@
         self._assert_result_length_is(response, len(versions))
 
         # List entities with filter
-        param_name = 'version__' + self.unique_entry_name
+        param_name = "version__" + self.unique_entry_name
         filter_params = {
             param_name: getattr(versions[0].version, self.unique_entry_name)
         }
-        self._assert_filter_result_matches(filter_params,
-                                           expected_result=versions[0].version)
+        self._assert_filter_result_matches(
+            filter_params, expected_result=versions[0].version
+        )
 
     def test_filter_daily_versions_by_date(self):
         """Test filtering daily versions by date."""
@@ -485,22 +526,26 @@
         self._assert_result_length_is(response, len(versions))
 
         # Expect the single matching result to be returned
-        filter_params = {'date': versions[0].date}
-        self._assert_filter_result_matches(filter_params,
-                                           expected_result=versions[0].version)
+        filter_params = {"date": versions[0].date}
+        self._assert_filter_result_matches(
+            filter_params, expected_result=versions[0].version
+        )
 
 
 class RadioVersionDailyTestCase(VersionDailyTestCase):
     """Test the RadioVersionDaily REST endpoint."""
 
-    unique_entry_name = 'radio_version'
+    unique_entry_name = "radio_version"
     unique_entries = Dummy.RADIO_VERSIONS
-    endpoint_url = reverse('hiccup_stats_api_v1_radio_version_daily')
+    endpoint_url = reverse("hiccup_stats_api_v1_radio_version_daily")
 
     @staticmethod
     def _create_dummy_version(**kwargs):
-        entity = RadioVersion(**Dummy.update_copy(
-            Dummy.DEFAULT_DUMMY_RADIO_VERSION_VALUES, kwargs))
+        entity = RadioVersion(
+            **Dummy.update_copy(
+                Dummy.DEFAULT_DUMMY_RADIO_VERSION_VALUES, kwargs
+            )
+        )
         entity.save()
         return entity
 
@@ -523,20 +568,21 @@
     version_class = Version
     # The attribute name characterising the unicity of a stats entry (the
     # named identifier)
-    unique_entry_name = 'build_fingerprint'
+    unique_entry_name = "build_fingerprint"
     # The collection of unique entries to post
     unique_entries = Dummy.BUILD_FINGERPRINTS
 
-    def _create_reports(self, report_type, unique_entry_name, device,
-                        number, **kwargs):
+    def _create_reports(
+        self, report_type, unique_entry_name, device, number, **kwargs
+    ):
         # Create reports with distinct timestamps
         now = datetime.now(pytz.utc)
         for i in range(number):
             report_date = now - timedelta(milliseconds=i)
             report_attributes = {
                 self.unique_entry_name: unique_entry_name,
-                'device': device,
-                'date': report_date
+                "device": device,
+                "date": report_date,
             }
             report_attributes.update(**kwargs)
             Dummy.create_dummy_report(report_type, **report_attributes)
@@ -551,11 +597,14 @@
         get_params = {
             self.unique_entry_name: getattr(heartbeat, self.unique_entry_name)
         }
-        self.assertRaises(self.version_class.DoesNotExist,
-                          self.version_class.objects.get, **get_params)
+        self.assertRaises(
+            self.version_class.DoesNotExist,
+            self.version_class.objects.get,
+            **get_params
+        )
 
         # Run the command to update the database
-        call_command('stats', 'update')
+        call_command("stats", "update")
 
         # Assume that a corresponding Version instance has been created
         version = self.version_class.objects.get(**get_params)
@@ -568,7 +617,7 @@
         report = Dummy.create_dummy_report(report_type, device=device)
 
         # Run the command to update the database
-        call_command('stats', 'update')
+        call_command("stats", "update")
 
         get_params = {
             self.unique_entry_name: getattr(report, self.unique_entry_name)
@@ -579,11 +628,12 @@
 
         # Create a new report from an earlier point in time
         report_time_2 = report.date - timedelta(weeks=1)
-        Dummy.create_dummy_report(report_type, device=device,
-                                  date=report_time_2)
+        Dummy.create_dummy_report(
+            report_type, device=device, date=report_time_2
+        )
 
         # Run the command to update the database
-        call_command('stats', 'update')
+        call_command("stats", "update")
 
         # Get the same version object from before
         version = self.version_class.objects.get(**get_params)
@@ -608,34 +658,37 @@
             self._create_reports(HeartBeat, unique_entry, device, 10)
 
         # Run the command to update the database
-        call_command('stats', 'update')
+        call_command("stats", "update")
 
         # Check whether the correct amount of distinct versions have been
         # created
         versions = self.version_class.objects.all()
         for version in versions:
-            self.assertIn(getattr(version, self.unique_entry_name),
-                          self.unique_entries)
+            self.assertIn(
+                getattr(version, self.unique_entry_name), self.unique_entries
+            )
         self.assertEqual(len(versions), len(self.unique_entries))
 
-    def _assert_counter_distribution_is_correct(self, report_type, numbers,
-                                                counter_attribute_name,
-                                                **kwargs):
+    def _assert_counter_distribution_is_correct(
+        self, report_type, numbers, counter_attribute_name, **kwargs
+    ):
         """Validate a counter distribution in the database."""
         if len(numbers) != len(self.unique_entries):
-            raise ValueError('The length of the numbers list must match the '
-                             'length of self.unique_entries in the test class'
-                             '({} != {})'.format(len(numbers),
-                                                 len(self.unique_entries)))
+            raise ValueError(
+                "The length of the numbers list must match the "
+                "length of self.unique_entries in the test class"
+                "({} != {})".format(len(numbers), len(self.unique_entries))
+            )
         # Create some reports
         user = Dummy.create_dummy_user()
         device = Dummy.create_dummy_device(user=user)
         for unique_entry, num in zip(self.unique_entries, numbers):
-            self._create_reports(report_type, unique_entry, device, num,
-                                 **kwargs)
+            self._create_reports(
+                report_type, unique_entry, device, num, **kwargs
+            )
 
         # Run the command to update the database
-        call_command('stats', 'update')
+        call_command("stats", "update")
 
         # Check whether the numbers of reports match
         for version in self.version_class.objects.all():
@@ -646,50 +699,52 @@
     def test_heartbeats_counter(self):
         """Test the calculation of the heartbeats counter."""
         numbers = [10, 7, 8, 5]
-        counter_attribute_name = 'heartbeats'
-        self._assert_counter_distribution_is_correct(HeartBeat, numbers,
-                                                     counter_attribute_name)
+        counter_attribute_name = "heartbeats"
+        self._assert_counter_distribution_is_correct(
+            HeartBeat, numbers, counter_attribute_name
+        )
 
     def test_crash_reports_counter(self):
         """Test the calculation of the crashreports counter."""
         numbers = [2, 5, 0, 3]
-        counter_attribute_name = 'prob_crashes'
-        boot_reason_param = {'boot_reason': Crashreport.BOOT_REASON_UNKOWN}
-        self._assert_counter_distribution_is_correct(Crashreport, numbers,
-                                                     counter_attribute_name,
-                                                     **boot_reason_param)
+        counter_attribute_name = "prob_crashes"
+        boot_reason_param = {"boot_reason": Crashreport.BOOT_REASON_UNKOWN}
+        self._assert_counter_distribution_is_correct(
+            Crashreport, numbers, counter_attribute_name, **boot_reason_param
+        )
 
     def test_smpl_reports_counter(self):
         """Test the calculation of the smpl reports counter."""
         numbers = [1, 3, 4, 0]
-        counter_attribute_name = 'smpl'
-        boot_reason_param = {'boot_reason': Crashreport.BOOT_REASON_RTC_ALARM}
-        self._assert_counter_distribution_is_correct(Crashreport, numbers,
-                                                     counter_attribute_name,
-                                                     **boot_reason_param)
+        counter_attribute_name = "smpl"
+        boot_reason_param = {"boot_reason": Crashreport.BOOT_REASON_RTC_ALARM}
+        self._assert_counter_distribution_is_correct(
+            Crashreport, numbers, counter_attribute_name, **boot_reason_param
+        )
 
     def test_other_reports_counter(self):
         """Test the calculation of the other reports counter."""
         numbers = [0, 2, 1, 2]
-        counter_attribute_name = 'other'
-        boot_reason_param = {'boot_reason': "random boot reason"}
-        self._assert_counter_distribution_is_correct(Crashreport, numbers,
-                                                     counter_attribute_name,
-                                                     **boot_reason_param)
+        counter_attribute_name = "other"
+        boot_reason_param = {"boot_reason": "random boot reason"}
+        self._assert_counter_distribution_is_correct(
+            Crashreport, numbers, counter_attribute_name, **boot_reason_param
+        )
 
-    def _assert_duplicates_are_ignored(self, report_type, device,
-                                       counter_attribute_name, **kwargs):
+    def _assert_duplicates_are_ignored(
+        self, report_type, device, counter_attribute_name, **kwargs
+    ):
         """Validate that reports with duplicate timestamps are ignored."""
         # Create a report
-        report = Dummy.create_dummy_report(report_type, device=device,
-                                           **kwargs)
+        report = Dummy.create_dummy_report(report_type, device=device, **kwargs)
 
         # Create a second report with the same timestamp
-        Dummy.create_dummy_report(report_type, device=device,
-                                  date=report.date, **kwargs)
+        Dummy.create_dummy_report(
+            report_type, device=device, date=report.date, **kwargs
+        )
 
         # Run the command to update the database
-        call_command('stats', 'update')
+        call_command("stats", "update")
 
         # Get the corresponding version instance from the database
         get_params = {
@@ -703,41 +758,46 @@
 
     def test_heartbeat_duplicates_are_ignored(self):
         """Validate that heartbeat duplicates are ignored."""
-        counter_attribute_name = 'heartbeats'
+        counter_attribute_name = "heartbeats"
         device = Dummy.create_dummy_device(user=Dummy.create_dummy_user())
-        self._assert_duplicates_are_ignored(HeartBeat, device,
-                                            counter_attribute_name)
+        self._assert_duplicates_are_ignored(
+            HeartBeat, device, counter_attribute_name
+        )
 
     def test_crash_report_duplicates_are_ignored(self):
         """Validate that crash report duplicates are ignored."""
-        counter_attribute_name = 'prob_crashes'
+        counter_attribute_name = "prob_crashes"
         device = Dummy.create_dummy_device(user=Dummy.create_dummy_user())
         for i, boot_reason in enumerate(Crashreport.CRASH_BOOT_REASONS):
-            params = {'boot_reason': boot_reason,
-                      self.unique_entry_name: self.unique_entries[i]}
-            self._assert_duplicates_are_ignored(Crashreport, device,
-                                                counter_attribute_name,
-                                                **params)
+            params = {
+                "boot_reason": boot_reason,
+                self.unique_entry_name: self.unique_entries[i],
+            }
+            self._assert_duplicates_are_ignored(
+                Crashreport, device, counter_attribute_name, **params
+            )
 
     def test_smpl_report_duplicates_are_ignored(self):
         """Validate that smpl report duplicates are ignored."""
-        counter_attribute_name = 'smpl'
+        counter_attribute_name = "smpl"
         device = Dummy.create_dummy_device(user=Dummy.create_dummy_user())
         for i, boot_reason in enumerate(Crashreport.SMPL_BOOT_REASONS):
-            params = {'boot_reason': boot_reason,
-                      self.unique_entry_name: self.unique_entries[i]}
-            self._assert_duplicates_are_ignored(Crashreport, device,
-                                                counter_attribute_name,
-                                                **params)
+            params = {
+                "boot_reason": boot_reason,
+                self.unique_entry_name: self.unique_entries[i],
+            }
+            self._assert_duplicates_are_ignored(
+                Crashreport, device, counter_attribute_name, **params
+            )
 
     def test_other_report_duplicates_are_ignored(self):
         """Validate that other report duplicates are ignored."""
-        counter_attribute_name = 'other'
-        params = {'boot_reason': 'random boot reason'}
+        counter_attribute_name = "other"
+        params = {"boot_reason": "random boot reason"}
         device = Dummy.create_dummy_device(user=Dummy.create_dummy_user())
-        self._assert_duplicates_are_ignored(Crashreport, device,
-                                            counter_attribute_name,
-                                            **params)
+        self._assert_duplicates_are_ignored(
+            Crashreport, device, counter_attribute_name, **params
+        )
 
 
 # pylint: disable=too-many-ancestors
@@ -745,7 +805,7 @@
     """Test the generation of RadioVersion stats with the stats command."""
 
     version_class = RadioVersion
-    unique_entry_name = 'radio_version'
+    unique_entry_name = "radio_version"
     unique_entries = Dummy.RADIO_VERSIONS
 
 
@@ -753,17 +813,14 @@
     """Test the reset and update commands debug output."""
 
     # Additional positional arguments to pass to the commands
-    _CMD_ARGS = [
-        '--no-color',
-        '-v 2',
-    ]
+    _CMD_ARGS = ["--no-color", "-v 2"]
 
     # The stats models
     _STATS_MODELS = [Version, VersionDaily, RadioVersion, RadioVersionDaily]
     # The models that will generate an output
     _ALL_MODELS = _STATS_MODELS + [StatsMetadata]
-    _COUNTER_NAMES = ['heartbeats', 'crashes', 'smpl', 'other']
-    _COUNTER_ACTIONS = ['created', 'updated']
+    _COUNTER_NAMES = ["heartbeats", "crashes", "smpl", "other"]
+    _COUNTER_ACTIONS = ["created", "updated"]
 
     def _assert_command_output_matches(self, command, number, facts, models):
         """Validate the debug output of a command.
@@ -772,38 +829,42 @@
         the parameters.
         """
         buffer = StringIO()
-        call_command('stats', command, *self._CMD_ARGS, stdout=buffer)
+        call_command("stats", command, *self._CMD_ARGS, stdout=buffer)
         output = buffer.getvalue().splitlines()
 
-        expected_output = '{number} {model} {fact}'
+        expected_output = "{number} {model} {fact}"
         for model in models:
             for fact in facts:
                 self.assertIn(
-                    expected_output.format(number=number,
-                                           model=model.__name__,
-                                           fact=fact),
-                    output)
+                    expected_output.format(
+                        number=number, model=model.__name__, fact=fact
+                    ),
+                    output,
+                )
 
     def test_reset_command_on_empty_db(self):
         """Test the reset command on an empty database.
 
         The reset command should yield nothing on an empty database.
         """
-        self._assert_command_output_matches('reset', 0, ['deleted'],
-                                            self._ALL_MODELS)
+        self._assert_command_output_matches(
+            "reset", 0, ["deleted"], self._ALL_MODELS
+        )
 
     def test_update_command_on_empty_db(self):
         """Test the update command on an empty database.
 
         The update command should yield nothing on an empty database.
         """
-        pattern = '{action} for counter {counter}'
+        pattern = "{action} for counter {counter}"
         facts = [
             pattern.format(action=counter_action, counter=counter_name)
             for counter_action in self._COUNTER_ACTIONS
-            for counter_name in self._COUNTER_NAMES]
-        self._assert_command_output_matches('update', 0, facts,
-                                            self._STATS_MODELS)
+            for counter_name in self._COUNTER_NAMES
+        ]
+        self._assert_command_output_matches(
+            "update", 0, facts, self._STATS_MODELS
+        )
 
     def test_reset_command_deletion_of_instances(self):
         """Test the deletion of stats model instances with the reset command.
@@ -820,5 +881,6 @@
         Dummy.create_dummy_stats_metadata()
 
         # We expect that the model instances get deleted
-        self._assert_command_output_matches('reset', 1, ['deleted'],
-                                            self._ALL_MODELS)
+        self._assert_command_output_matches(
+            "reset", 1, ["deleted"], self._ALL_MODELS
+        )