Rename dummy instance creation methods
The dummy instance creation methods do not need "Dummy" in their
name, as they are all in the Dummy class.
Issue: HIC-286
Change-Id: I688eaf0d67f5357dd386a701f958dc57a889a6c6
diff --git a/crashreport_stats/tests/test_rest_endpoints.py b/crashreport_stats/tests/test_rest_endpoints.py
index 8708f3d..4502fbb 100644
--- a/crashreport_stats/tests/test_rest_endpoints.py
+++ b/crashreport_stats/tests/test_rest_endpoints.py
@@ -57,14 +57,12 @@
def test_get_status(self):
"""Get the status after some reports have been created."""
# Create a device with a heartbeat and a crash report
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
- Dummy.create_dummy_report(HeartBeat, device)
- Dummy.create_dummy_report(Crashreport, device)
+ device = Dummy.create_device(Dummy.create_user())
+ Dummy.create_report(HeartBeat, device)
+ Dummy.create_report(Crashreport, device)
# Create a second device without any reports
- Dummy.create_dummy_device(
- Dummy.create_dummy_user(username=Dummy.USERNAMES[1])
- )
+ Dummy.create_device(Dummy.create_user(username=Dummy.USERNAMES[1]))
# Assert that the status includes the appropriate numbers (a third
# device was created by the setUpTestData() method)
@@ -79,7 +77,7 @@
@staticmethod
def _create_dummy_version(**kwargs):
- return Dummy.create_dummy_version(**kwargs)
+ return Dummy.create_version(**kwargs)
def _get_with_params(self, url, params):
return self.fp_staff_client.get("{}?{}".format(url, urlencode(params)))
@@ -234,7 +232,7 @@
@staticmethod
def _create_dummy_version(**kwargs):
- return Dummy.create_dummy_version(RadioVersion, **kwargs)
+ return Dummy.create_version(RadioVersion, **kwargs)
class VersionDailyTestCase(_VersionTestCase):
@@ -246,7 +244,7 @@
@staticmethod
def _create_dummy_daily_version(version, **kwargs):
- return Dummy.create_dummy_daily_version(version, **kwargs)
+ return Dummy.create_daily_version(version, **kwargs)
def _create_version_entities(self):
versions = [
@@ -335,14 +333,14 @@
@staticmethod
def _create_dummy_version(**kwargs):
- return Dummy.create_dummy_version(RadioVersion, **kwargs)
+ return Dummy.create_version(RadioVersion, **kwargs)
@staticmethod
def _create_dummy_daily_version(version, **kwargs):
- return Dummy.create_dummy_daily_radio_version(version, **kwargs)
+ return Dummy.create_daily_radio_version(version, **kwargs)
-@override_settings(MEDIA_ROOT=Dummy.DEFAULT_DUMMY_LOG_FILE_DIRECTORY)
+@override_settings(MEDIA_ROOT=Dummy.DEFAULT_LOG_FILE_DIRECTORY)
class DeviceStatsTestCase(HiccupStatsAPITestCase):
"""Test the single device stats REST endpoints."""
@@ -512,7 +510,7 @@
def test_get_device_stats_no_reports(self):
"""Test getting device stats for a device without reports."""
# Create a device
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
+ device = Dummy.create_device(Dummy.create_user())
# Get the device statistics
response = self._get_with_params(
@@ -535,8 +533,8 @@
def test_get_device_stats_no_crash_reports(self):
"""Test getting device stats for a device without crashreports."""
# Create a device and a heartbeat
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
- heartbeat = Dummy.create_dummy_report(HeartBeat, device)
+ device = Dummy.create_device(Dummy.create_user())
+ heartbeat = Dummy.create_report(HeartBeat, device)
# Get the device statistics
response = self._get_with_params(
@@ -559,8 +557,8 @@
def test_get_device_stats_no_heartbeats(self):
"""Test getting device stats for a device without heartbeats."""
# Create a device and crashreport
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
- Dummy.create_dummy_report(Crashreport, device)
+ device = Dummy.create_device(Dummy.create_user())
+ Dummy.create_report(Crashreport, device)
# Get the device statistics
response = self._get_with_params(
@@ -583,9 +581,9 @@
def test_get_device_stats(self):
"""Test getting device stats for a device."""
# Create a device with a heartbeat and one report of each type
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
- crashreport_date = Dummy.DEFAULT_DUMMY_CRASHREPORT_VALUES["date"]
- heartbeat = Dummy.create_dummy_report(
+ device = Dummy.create_device(Dummy.create_user())
+ crashreport_date = Dummy.DEFAULT_CRASHREPORT_VALUES["date"]
+ heartbeat = Dummy.create_report(
HeartBeat, device, date=crashreport_date.date()
)
for boot_reason in (
@@ -593,7 +591,7 @@
+ Crashreport.CRASH_BOOT_REASONS
+ ["other boot reason"]
):
- Dummy.create_dummy_report(
+ Dummy.create_report(
Crashreport,
device,
boot_reason=boot_reason,
@@ -622,15 +620,15 @@
def test_get_device_stats_multiple_days(self):
"""Test getting device stats for a device that sent more reports."""
# Create a device with some heartbeats and reports over time
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
+ device = Dummy.create_device(Dummy.create_user())
num_days = 100
for i in range(num_days):
report_date = datetime.now(tz=pytz.utc) + timedelta(days=i)
- heartbeat = Dummy.create_dummy_report(
+ heartbeat = Dummy.create_report(
HeartBeat, device, date=report_date.date()
)
- Dummy.create_dummy_report(Crashreport, device, date=report_date)
- Dummy.create_dummy_report(
+ Dummy.create_report(Crashreport, device, date=report_date)
+ Dummy.create_report(
Crashreport,
device,
date=report_date + timedelta(minutes=1),
@@ -658,17 +656,17 @@
def test_get_device_stats_multiple_days_missing_heartbeat(self):
"""Test getting device stats for a device with missing heartbeat."""
# Create a device with some heartbeats and reports over time
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
+ device = Dummy.create_device(Dummy.create_user())
num_days = 100
skip_day = round(num_days / 2)
for i in range(num_days):
report_date = datetime.now(tz=pytz.utc) + timedelta(days=i)
# Skip creation of heartbeat at one day
if i != skip_day:
- heartbeat = Dummy.create_dummy_report(
+ heartbeat = Dummy.create_report(
HeartBeat, device, date=report_date.date()
)
- Dummy.create_dummy_report(Crashreport, device, date=report_date)
+ Dummy.create_report(Crashreport, device, date=report_date)
# Get the device statistics
response = self._get_with_params(
@@ -691,7 +689,7 @@
def test_get_device_report_history_no_reports(self):
"""Test getting report history stats for a device without reports."""
# Create a device
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
+ device = Dummy.create_device(Dummy.create_user())
# Get the device report history statistics
response = self._get_with_params(
@@ -704,9 +702,9 @@
def test_get_device_report_history(self):
"""Test getting report history stats for a device."""
# Create a device with a heartbeat and one report of each type
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
- crashreport_date = Dummy.DEFAULT_DUMMY_CRASHREPORT_VALUES["date"]
- heartbeat = Dummy.create_dummy_report(
+ device = Dummy.create_device(Dummy.create_user())
+ crashreport_date = Dummy.DEFAULT_CRASHREPORT_VALUES["date"]
+ heartbeat = Dummy.create_report(
HeartBeat, device, date=crashreport_date.date()
)
for boot_reason in (
@@ -714,7 +712,7 @@
+ Crashreport.CRASH_BOOT_REASONS
+ ["other boot reason"]
):
- Dummy.create_dummy_report(
+ Dummy.create_report(
Crashreport,
device,
boot_reason=boot_reason,
@@ -741,24 +739,22 @@
def test_get_device_report_history_multiple_days(self):
"""Test getting report history stats for a device for multiple days."""
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
+ device = Dummy.create_device(Dummy.create_user())
expected_report_history = []
# Create a device with a heartbeat and one report of each type for 10
# days
- report_date = Dummy.DEFAULT_DUMMY_CRASHREPORT_VALUES["date"]
+ report_date = Dummy.DEFAULT_CRASHREPORT_VALUES["date"]
for _ in range(10):
report_date = report_date + timedelta(days=1)
- Dummy.create_dummy_report(
- HeartBeat, device, date=report_date.date()
- )
+ Dummy.create_report(HeartBeat, device, date=report_date.date())
for i, boot_reason in enumerate(
Crashreport.SMPL_BOOT_REASONS
+ Crashreport.CRASH_BOOT_REASONS
+ ["other boot reason"]
):
- Dummy.create_dummy_report(
+ Dummy.create_report(
Crashreport,
device,
boot_reason=boot_reason,
@@ -790,7 +786,7 @@
def test_get_device_update_history_no_reports(self):
"""Test getting update history stats for a device without reports."""
# Create a device
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
+ device = Dummy.create_device(Dummy.create_user())
# Get the device report history statistics
response = self._get_with_params(
@@ -803,9 +799,9 @@
def test_get_device_update_history(self):
"""Test getting update history stats for a device."""
# Create a device with a heartbeat and one report of each type
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
- crashreport_date = Dummy.DEFAULT_DUMMY_CRASHREPORT_VALUES["date"]
- heartbeat = Dummy.create_dummy_report(
+ device = Dummy.create_device(Dummy.create_user())
+ crashreport_date = Dummy.DEFAULT_CRASHREPORT_VALUES["date"]
+ heartbeat = Dummy.create_report(
HeartBeat, device, date=crashreport_date.date()
)
for boot_reason in (
@@ -814,7 +810,7 @@
+ ["other boot reason"]
):
params = {"boot_reason": boot_reason, "date": crashreport_date}
- Dummy.create_dummy_report(Crashreport, device, **params)
+ Dummy.create_report(Crashreport, device, **params)
crashreport_date += timedelta(milliseconds=1)
# Get the device update history statistics
@@ -840,17 +836,17 @@
"""Test getting update history stats with multiple updates."""
# Create a device with a heartbeats and crashreport for each build
# fingerprint in the dummy values
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
+ device = Dummy.create_device(Dummy.create_user())
expected_update_history = []
for i, build_fingerprint in enumerate(Dummy.BUILD_FINGERPRINTS):
report_date = datetime.now(tz=pytz.utc) + timedelta(days=i)
- Dummy.create_dummy_report(
+ Dummy.create_report(
HeartBeat,
device,
date=report_date,
build_fingerprint=build_fingerprint,
)
- Dummy.create_dummy_report(
+ Dummy.create_report(
Crashreport,
device,
date=report_date,
@@ -893,9 +889,9 @@
def test_download_logfile(self):
"""Test download of log files."""
# Create a device with a crash report along with log file
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
- crashreport = Dummy.create_dummy_report(Crashreport, device)
- logfile = Dummy.create_dummy_log_file(crashreport)
+ device = Dummy.create_device(Dummy.create_user())
+ crashreport = Dummy.create_report(Crashreport, device)
+ logfile = Dummy.create_log_file(crashreport)
# Get the log file
response = self._get_with_params(
@@ -904,11 +900,10 @@
# Assert that the log file contents are in the response data
self.assertEqual(response.status_code, status.HTTP_200_OK)
- self.assertIn(Dummy.DEFAULT_DUMMY_LOG_FILE_NAME, response.data)
+ self.assertIn(Dummy.DEFAULT_LOG_FILE_NAME, response.data)
expected_logfile_content = Dummy.read_logfile_contents(
- logfile.logfile.path, Dummy.DEFAULT_DUMMY_LOG_FILE_NAME
+ logfile.logfile.path, Dummy.DEFAULT_LOG_FILE_NAME
)
self.assertEqual(
- response.data[Dummy.DEFAULT_DUMMY_LOG_FILE_NAME],
- expected_logfile_content,
+ response.data[Dummy.DEFAULT_LOG_FILE_NAME], expected_logfile_content
)
diff --git a/crashreport_stats/tests/test_stats_management_command.py b/crashreport_stats/tests/test_stats_management_command.py
index ddea798..6409b55 100644
--- a/crashreport_stats/tests/test_stats_management_command.py
+++ b/crashreport_stats/tests/test_stats_management_command.py
@@ -46,13 +46,13 @@
"date": report_date - timedelta(days=i),
}
report_attributes.update(**kwargs)
- Dummy.create_dummy_report(report_type, **report_attributes)
+ Dummy.create_report(report_type, **report_attributes)
def test_stats_calculation(self):
"""Test generation of a Version instance."""
- user = Dummy.create_dummy_user()
- device = Dummy.create_dummy_device(user=user)
- heartbeat = Dummy.create_dummy_report(HeartBeat, device=device)
+ user = Dummy.create_user()
+ device = Dummy.create_device(user=user)
+ heartbeat = Dummy.create_report(HeartBeat, device=device)
# Expect that we do not have the Version before updating the stats
get_params = {
@@ -73,9 +73,9 @@
def _assert_older_report_updates_version_date(self, report_type):
"""Validate that older reports sent later affect the version date."""
- user = Dummy.create_dummy_user()
- device = Dummy.create_dummy_device(user=user)
- report = Dummy.create_dummy_report(report_type, device=device)
+ user = Dummy.create_user()
+ device = Dummy.create_device(user=user)
+ report = Dummy.create_report(report_type, device=device)
# Run the command to update the database
call_command("stats", "update")
@@ -92,9 +92,7 @@
# Create a new report from an earlier point in time
report_date_2 = report.date - timedelta(weeks=1)
- Dummy.create_dummy_report(
- report_type, device=device, date=report_date_2
- )
+ Dummy.create_report(report_type, device=device, date=report_date_2)
# Run the command to update the database
call_command("stats", "update")
@@ -119,8 +117,8 @@
"""Validate the entries' unicity and value."""
# Create some reports
for unique_entry, username in zip(self.unique_entries, Dummy.USERNAMES):
- user = Dummy.create_dummy_user(username=username)
- device = Dummy.create_dummy_device(user=user)
+ user = Dummy.create_user(username=username)
+ device = Dummy.create_device(user=user)
self._create_reports(HeartBeat, unique_entry, device, 10)
# Run the command to update the database
@@ -149,8 +147,8 @@
for unique_entry, num, username in zip(
self.unique_entries, numbers, Dummy.USERNAMES
):
- user = Dummy.create_dummy_user(username=username)
- device = Dummy.create_dummy_device(user=user)
+ user = Dummy.create_user(username=username)
+ device = Dummy.create_device(user=user)
self._create_reports(
report_type, unique_entry, device, num, **kwargs
)
@@ -205,7 +203,7 @@
"""Validate a counter distribution with reports of different devices."""
# Create some devices and corresponding reports
devices = [
- Dummy.create_dummy_device(Dummy.create_dummy_user(username=name))
+ Dummy.create_device(Dummy.create_user(username=name))
for name in Dummy.USERNAMES
]
num_reports = 5
@@ -268,7 +266,7 @@
def test_reset_deletion_of_unrelated_version(self):
"""Test delete functionality of the reset command."""
# Create a version instance that is not related to any reports
- Dummy.create_dummy_version(
+ Dummy.create_version(
self.version_class,
**{self.unique_entry_name: self.unique_entries[0]}
)
@@ -287,7 +285,7 @@
self, report_type, counter_attribute_name, **kwargs
):
# Create a device and corresponding reports
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
+ device = Dummy.create_device(Dummy.create_user())
num_reports = 5
self._create_reports(
report_type, self.unique_entries[0], device, num_reports, **kwargs
@@ -295,7 +293,7 @@
# Create a version instance with wrong numbers
wrong_num_of_reports = 4
- Dummy.create_dummy_version(
+ Dummy.create_version(
self.version_class,
**{
self.unique_entry_name: self.unique_entries[0],
@@ -342,7 +340,7 @@
):
# Create a two devices and a corresponding reports for 2 different
# versions
- device_1 = Dummy.create_dummy_device(Dummy.create_dummy_user())
+ device_1 = Dummy.create_device(Dummy.create_user())
num_reports = 5
self._create_reports(
report_type,
@@ -351,8 +349,8 @@
num_reports,
**boot_reason_param
)
- device_2 = Dummy.create_dummy_device(
- Dummy.create_dummy_user(username=Dummy.USERNAMES[1])
+ device_2 = Dummy.create_device(
+ Dummy.create_user(username=Dummy.USERNAMES[1])
)
self._create_reports(
report_type,
@@ -385,7 +383,7 @@
"device": device_1,
**boot_reason_param,
}
- Dummy.create_dummy_report(report_type, **report_new_attributes)
+ Dummy.create_report(report_type, **report_new_attributes)
# Run the command to update the database again
call_command("stats", "update")
@@ -447,18 +445,16 @@
counted as independent reports.
"""
# Create a report
- device1 = Dummy.create_dummy_device(
- user=Dummy.create_dummy_user(username=username_1)
+ device1 = Dummy.create_device(
+ user=Dummy.create_user(username=username_1)
)
- report1 = Dummy.create_dummy_report(
- report_type, device=device1, **kwargs
- )
+ report1 = Dummy.create_report(report_type, device=device1, **kwargs)
# Create a second report with the same timestamp but from another device
- device2 = Dummy.create_dummy_device(
- user=Dummy.create_dummy_user(username=username_2)
+ device2 = Dummy.create_device(
+ user=Dummy.create_user(username=username_2)
)
- Dummy.create_dummy_report(
+ Dummy.create_report(
report_type, device=device2, date=report1.date, **kwargs
)
@@ -534,8 +530,8 @@
sent.
"""
# Create a report
- device = Dummy.create_dummy_device(user=Dummy.create_dummy_user())
- report = Dummy.create_dummy_report(report_type, device=device, **kwargs)
+ device = Dummy.create_device(user=Dummy.create_user())
+ report = Dummy.create_report(report_type, device=device, **kwargs)
# Run the command to update the database
call_command("stats", "update")
@@ -553,7 +549,7 @@
# Create a second report with the a timestamp earlier in time
report_2_date = report.date - timedelta(days=1)
- Dummy.create_dummy_report(
+ Dummy.create_report(
report_type, device=device, date=report_2_date, **kwargs
)
@@ -579,8 +575,8 @@
sent.
"""
# Create a report
- device = Dummy.create_dummy_device(user=Dummy.create_dummy_user())
- report = Dummy.create_dummy_report(report_type, device=device, **kwargs)
+ device = Dummy.create_device(user=Dummy.create_user())
+ report = Dummy.create_report(report_type, device=device, **kwargs)
report_1_date = (
report.date.date() if report_type == Crashreport else report.date
)
@@ -598,7 +594,7 @@
# Create a second report with the a timestamp later in time
report_2_date = report.date + timedelta(days=1)
- Dummy.create_dummy_report(
+ Dummy.create_report(
report_type, device=device, date=report_2_date, **kwargs
)
@@ -638,8 +634,8 @@
new reports are sent.
"""
# Create a report
- device = Dummy.create_dummy_device(user=Dummy.create_dummy_user())
- report = Dummy.create_dummy_report(report_type, device=device, **kwargs)
+ device = Dummy.create_device(user=Dummy.create_user())
+ report = Dummy.create_report(report_type, device=device, **kwargs)
# Run the command to update the database
call_command("stats", "update")
@@ -657,7 +653,7 @@
# Create a second report with a timestamp earlier in time
report_2_date = report.date - timedelta(days=1)
- Dummy.create_dummy_report(
+ Dummy.create_report(
report_type, device=device, date=report_2_date, **kwargs
)
@@ -767,11 +763,11 @@
model instance for each class.
"""
# Create dummy version instances
- version = Dummy.create_dummy_version()
- radio_version = Dummy.create_dummy_version(RadioVersion)
- Dummy.create_dummy_daily_version(version)
- Dummy.create_dummy_daily_radio_version(radio_version)
- Dummy.create_dummy_stats_metadata()
+ version = Dummy.create_version()
+ radio_version = Dummy.create_version(RadioVersion)
+ Dummy.create_daily_version(version)
+ Dummy.create_daily_radio_version(radio_version)
+ Dummy.create_stats_metadata()
# We expect that the model instances get deleted
self._assert_command_output_matches(
diff --git a/crashreport_stats/tests/test_views.py b/crashreport_stats/tests/test_views.py
index ab46fce..ed41cbd 100644
--- a/crashreport_stats/tests/test_views.py
+++ b/crashreport_stats/tests/test_views.py
@@ -155,7 +155,7 @@
def test_home_view_filter_devices_by_uuid(self):
"""Test filtering devices by UUID."""
# Create a device
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
+ device = Dummy.create_device(Dummy.create_user())
# Filter devices by UUID of the created device
response = self.fp_staff_client.post(
@@ -171,7 +171,7 @@
def test_home_view_filter_devices_by_uuid_part(self):
"""Test filtering devices by start of UUID."""
# Create a device
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
+ device = Dummy.create_device(Dummy.create_user())
# Filter devices with start of the created device's UUID
response = self.fp_staff_client.post(
@@ -187,9 +187,9 @@
def test_home_view_filter_devices_by_uuid_part_ambiguous_result(self):
"""Test filtering devices with common start of UUIDs."""
# Create two devices
- device1 = Dummy.create_dummy_device(Dummy.create_dummy_user())
- device2 = Dummy.create_dummy_device(
- Dummy.create_dummy_user(username=Dummy.USERNAMES[1])
+ device1 = Dummy.create_device(Dummy.create_user())
+ device2 = Dummy.create_device(
+ Dummy.create_user(username=Dummy.USERNAMES[1])
)
# Adapt the devices' UUID so that they start with the same characters
@@ -235,7 +235,7 @@
def test_get_device_view(self):
"""Test getting device view."""
# Create a device
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
+ device = Dummy.create_device(Dummy.create_user())
# Get the corresponding device view
response = self._get_with_params(self.device_url, {"uuid": device.uuid})
@@ -297,7 +297,7 @@
def test_get_versions_view(self):
"""Test getting versions view."""
# Create a version
- Dummy.create_dummy_version()
+ Dummy.create_version()
# Get the versions view
response = self.fp_staff_client.get(self.versions_url)
@@ -321,7 +321,7 @@
def test_get_versions_all_view(self):
"""Test getting versions view."""
# Create a version
- Dummy.create_dummy_version()
+ Dummy.create_version()
# Get the versions view
response = self.fp_staff_client.get(self.versions_all_url)
diff --git a/crashreport_stats/tests/utils.py b/crashreport_stats/tests/utils.py
index 491839b..8e22acd 100644
--- a/crashreport_stats/tests/utils.py
+++ b/crashreport_stats/tests/utils.py
@@ -24,7 +24,7 @@
class Dummy(CrashreportsDummy):
"""Class for creating dummy instances for testing."""
- DEFAULT_DUMMY_VERSION_VALUES = {
+ DEFAULT_VERSION_VALUES = {
"build_fingerprint": CrashreportsDummy.BUILD_FINGERPRINTS[0],
"first_seen_on": CrashreportsDummy.DATES[1],
"released_on": CrashreportsDummy.DATES[0],
@@ -32,24 +32,22 @@
"is_official_release": True,
}
- DEFAULT_DUMMY_VERSION_DAILY_VALUES = {"date": CrashreportsDummy.DATES[1]}
+ DEFAULT_VERSION_DAILY_VALUES = {"date": CrashreportsDummy.DATES[1]}
- DEFAULT_DUMMY_RADIO_VERSION_VALUES = {
+ DEFAULT_RADIO_VERSION_VALUES = {
"radio_version": CrashreportsDummy.RADIO_VERSIONS[0],
"first_seen_on": CrashreportsDummy.DATES[1],
"released_on": CrashreportsDummy.DATES[0],
}
- DEFAULT_DUMMY_RADIO_VERSION_DAILY_VALUES = {
- "date": CrashreportsDummy.DATES[1]
- }
+ DEFAULT_RADIO_VERSION_DAILY_VALUES = {"date": CrashreportsDummy.DATES[1]}
- DEFAULT_DUMMY_STATSMETADATA_VALUES = {
+ DEFAULT_STATSMETADATA_VALUES = {
"updated_at": datetime(2018, 6, 15, 2, 12, 24, tzinfo=pytz.utc)
}
@staticmethod
- def create_dummy_version(version_type=Version, **kwargs):
+ def create_version(version_type=Version, **kwargs):
"""Create a dummy version instance.
The dummy instance is created and saved to the database.
@@ -66,13 +64,11 @@
"""
if version_type == Version:
entity = Version(
- **Dummy._update_copy(Dummy.DEFAULT_DUMMY_VERSION_VALUES, kwargs)
+ **Dummy._update_copy(Dummy.DEFAULT_VERSION_VALUES, kwargs)
)
elif version_type == RadioVersion:
entity = RadioVersion(
- **Dummy._update_copy(
- Dummy.DEFAULT_DUMMY_RADIO_VERSION_VALUES, kwargs
- )
+ **Dummy._update_copy(Dummy.DEFAULT_RADIO_VERSION_VALUES, kwargs)
)
else:
raise ValueError(
@@ -84,7 +80,7 @@
return entity
@staticmethod
- def create_dummy_daily_version(version, **kwargs):
+ def create_daily_version(version, **kwargs):
"""Create a dummy daily version instance.
The dummy instance is created and saved to the database.
@@ -97,15 +93,13 @@
"""
entity = VersionDaily(
version=version,
- **Dummy._update_copy(
- Dummy.DEFAULT_DUMMY_VERSION_DAILY_VALUES, kwargs
- )
+ **Dummy._update_copy(Dummy.DEFAULT_VERSION_DAILY_VALUES, kwargs)
)
entity.save()
return entity
@staticmethod
- def create_dummy_daily_radio_version(version, **kwargs):
+ def create_daily_radio_version(version, **kwargs):
"""Create a dummy daily radio version instance.
The dummy instance is created and saved to the database.
@@ -119,14 +113,14 @@
entity = RadioVersionDaily(
version=version,
**Dummy._update_copy(
- Dummy.DEFAULT_DUMMY_RADIO_VERSION_DAILY_VALUES, kwargs
+ Dummy.DEFAULT_RADIO_VERSION_DAILY_VALUES, kwargs
)
)
entity.save()
return entity
@staticmethod
- def create_dummy_stats_metadata(**kwargs):
+ def create_stats_metadata(**kwargs):
"""Create a dummy stats metadata instance.
The dummy instance is created and saved to the database.
@@ -138,9 +132,7 @@
"""
entity = StatsMetadata(
- **Dummy._update_copy(
- Dummy.DEFAULT_DUMMY_STATSMETADATA_VALUES, kwargs
- )
+ **Dummy._update_copy(Dummy.DEFAULT_STATSMETADATA_VALUES, kwargs)
)
entity.save()
return entity
@@ -170,7 +162,7 @@
"device_owner", "somebody@somemail.com", "thepassword"
)
Token.objects.create(user=cls.device_owner_user)
- cls.device_owner_device = Dummy.create_dummy_device(
+ cls.device_owner_device = Dummy.create_device(
user=cls.device_owner_user
)
cls.device_owner_client = APIClient()
diff --git a/crashreports/tests/test_migrations.py b/crashreports/tests/test_migrations.py
index e5faffb..34696ae 100644
--- a/crashreports/tests/test_migrations.py
+++ b/crashreports/tests/test_migrations.py
@@ -55,10 +55,10 @@
def _assert_duplicates_are_deleted(self, object_type):
# Create a user, device and two duplicate reports
- user = Dummy.create_dummy_user()
- device = Dummy.create_dummy_device(user)
- report_1 = Dummy.create_dummy_report(object_type, device)
- Dummy.create_dummy_report(object_type, device)
+ user = Dummy.create_user()
+ device = Dummy.create_device(user)
+ report_1 = Dummy.create_report(object_type, device)
+ Dummy.create_report(object_type, device)
# Assert that 2 instances have been created
self.assertEqual(object_type.objects.count(), 2)
@@ -96,15 +96,15 @@
def test_delete_duplicate_crashreport_with_logfile(self):
"""Test deletion of a duplicate crashreport with logfile."""
# Create a user, device and two duplicate reports with logfiles
- user = Dummy.create_dummy_user()
- device = Dummy.create_dummy_device(user)
- crashreport_1 = Dummy.create_dummy_report(Crashreport, device)
- crashreport_2 = Dummy.create_dummy_report(Crashreport, device)
- _, logfile_1_path = Dummy.create_dummy_log_file_with_actual_file(
+ user = Dummy.create_user()
+ device = Dummy.create_device(user)
+ crashreport_1 = Dummy.create_report(Crashreport, device)
+ crashreport_2 = Dummy.create_report(Crashreport, device)
+ _, logfile_1_path = Dummy.create_log_file_with_actual_file(
crashreport_1
)
- _, logfile_2_path = Dummy.create_dummy_log_file_with_actual_file(
- crashreport_2, logfile=Dummy.DEFAULT_DUMMY_LOG_FILE_PATHS[1]
+ _, logfile_2_path = Dummy.create_log_file_with_actual_file(
+ crashreport_2, logfile=Dummy.DEFAULT_LOG_FILE_PATHS[1]
)
# Assert that 2 crashreports and logfiles have been created
@@ -129,11 +129,11 @@
def test_change_of_date_field_type(self):
"""Test that the 'date' field of heartbeats is changed to a date."""
# Create a user, device and a heartbeat
- user = Dummy.create_dummy_user()
- device = Dummy.create_dummy_device(user)
+ user = Dummy.create_user()
+ device = Dummy.create_device(user)
heartbeat_timestamp = datetime(2015, 12, 15, 1, 23, 45, tzinfo=pytz.utc)
- heartbeat = Dummy.create_dummy_report(
+ heartbeat = Dummy.create_report(
HeartBeat, device, date=heartbeat_timestamp
)
diff --git a/crashreports/tests/test_models.py b/crashreports/tests/test_models.py
index d12189d..d14155f 100644
--- a/crashreports/tests/test_models.py
+++ b/crashreports/tests/test_models.py
@@ -21,14 +21,14 @@
def _assert_duplicate_entries_can_not_be_created(self, object_type):
# Create a user, device and a report
- user = Dummy.create_dummy_user()
- device = Dummy.create_dummy_device(user)
- Dummy.create_dummy_report(object_type, device)
+ user = Dummy.create_user()
+ device = Dummy.create_device(user)
+ Dummy.create_report(object_type, device)
# Assert creating a duplicate report fails
logger = logging.getLogger("crashreports")
with self.assertLogs(logger, "DEBUG") as logging_watcher:
- report = Dummy.create_dummy_report(object_type, device)
+ report = Dummy.create_report(object_type, device)
self.assertEqual(
logging_watcher.output,
[
diff --git a/crashreports/tests/test_rest_api_logfiles.py b/crashreports/tests/test_rest_api_logfiles.py
index 1cf2e55..f66a357 100644
--- a/crashreports/tests/test_rest_api_logfiles.py
+++ b/crashreports/tests/test_rest_api_logfiles.py
@@ -77,7 +77,7 @@
def upload_logfile(self, client, uuid, device_local_id):
"""Upload a log file and assert that it was created."""
- logfile = open(Dummy.DEFAULT_DUMMY_LOG_FILE_PATHS[0], "rb")
+ logfile = open(Dummy.DEFAULT_LOG_FILE_PATHS[0], "rb")
logfile_name = os.path.basename(logfile.name)
response = client.post(
reverse(
@@ -103,8 +103,7 @@
.logfiles.last()
)
uploaded_logfile_path = crashreport_file_name(
- logfile_instance,
- os.path.basename(Dummy.DEFAULT_DUMMY_LOG_FILE_PATHS[0]),
+ logfile_instance, os.path.basename(Dummy.DEFAULT_LOG_FILE_PATHS[0])
)
self.assertTrue(default_storage.exists(uploaded_logfile_path))
@@ -112,7 +111,7 @@
# bytes. However, we mainly care that the contents are equal:
self._assert_zip_file_contents_equal(
default_storage.path(uploaded_logfile_path),
- Dummy.DEFAULT_DUMMY_LOG_FILE_PATHS[0],
+ Dummy.DEFAULT_LOG_FILE_PATHS[0],
)
def test_logfile_upload_as_user(self):
@@ -126,9 +125,9 @@
def test_logfile_deletion(self):
"""Test deletion of logfile instances."""
# Create a user, device and crashreport with logfile
- device = Dummy.create_dummy_device(Dummy.create_dummy_user())
- crashreport = Dummy.create_dummy_report(Crashreport, device)
- logfile, logfile_path = Dummy.create_dummy_log_file_with_actual_file(
+ device = Dummy.create_device(Dummy.create_user())
+ crashreport = Dummy.create_report(Crashreport, device)
+ logfile, logfile_path = Dummy.create_log_file_with_actual_file(
crashreport
)
diff --git a/crashreports/tests/utils.py b/crashreports/tests/utils.py
index e9139df..8f71cad 100644
--- a/crashreports/tests/utils.py
+++ b/crashreports/tests/utils.py
@@ -79,19 +79,19 @@
DATES = [date(2018, 3, 19), date(2018, 3, 26), date(2018, 5, 1)]
- DEFAULT_DUMMY_USER_VALUES = {"username": USERNAMES[0]}
+ DEFAULT_USER_VALUES = {"username": USERNAMES[0]}
- DEFAULT_DUMMY_DEVICE_REGISTER_VALUES = {
+ DEFAULT_DEVICE_REGISTER_VALUES = {
"board_date": datetime(2015, 12, 15, 1, 23, 45, tzinfo=pytz.utc),
"chipset": "Qualcomm MSM8974PRO-AA",
}
- DEFAULT_DUMMY_DEVICE_VALUES = DEFAULT_DUMMY_DEVICE_REGISTER_VALUES.copy()
- DEFAULT_DUMMY_DEVICE_VALUES.update(
+ DEFAULT_DEVICE_VALUES = DEFAULT_DEVICE_REGISTER_VALUES.copy()
+ DEFAULT_DEVICE_VALUES.update(
{"token": "64111c62d521fb4724454ca6dea27e18f93ef56e"}
)
- DEFAULT_DUMMY_HEARTBEAT_VALUES = {
+ DEFAULT_HEARTBEAT_VALUES = {
"app_version": 10100,
"uptime": (
"up time: 16 days, 21:49:56, idle time: 5 days, 20:55:04, "
@@ -113,8 +113,8 @@
"date": date(2018, 3, 19),
}
- DEFAULT_DUMMY_CRASHREPORT_VALUES = DEFAULT_DUMMY_HEARTBEAT_VALUES.copy()
- DEFAULT_DUMMY_CRASHREPORT_VALUES.update(
+ DEFAULT_CRASHREPORT_VALUES = DEFAULT_HEARTBEAT_VALUES.copy()
+ DEFAULT_CRASHREPORT_VALUES.update(
{
"is_fake_report": False,
"boot_reason": Crashreport.BOOT_REASON_UNKOWN,
@@ -135,7 +135,7 @@
}
)
- DEFAULT_DUMMY_LOG_FILE_NAME = "dmesg.log"
+ DEFAULT_LOG_FILE_NAME = "dmesg.log"
CRASH_TYPE_TO_BOOT_REASON_MAP = {
"crash": Crashreport.BOOT_REASON_KEYBOARD_POWER_ON,
@@ -143,26 +143,17 @@
"other": "whatever",
}
- DEFAULT_DUMMY_LOG_FILE_FILENAMES = [
- "test_logfile_1.zip",
- "test_logfile_2.zip",
- ]
- DEFAULT_DUMMY_LOG_FILE_DIRECTORY = os.path.join("resources", "test")
+ DEFAULT_LOG_FILE_FILENAMES = ["test_logfile_1.zip", "test_logfile_2.zip"]
+ DEFAULT_LOG_FILE_DIRECTORY = os.path.join("resources", "test")
- DEFAULT_DUMMY_LOG_FILE_VALUES = {
+ DEFAULT_LOG_FILE_VALUES = {
"logfile_type": "last_kmsg",
- "logfile": DEFAULT_DUMMY_LOG_FILE_FILENAMES[0],
+ "logfile": DEFAULT_LOG_FILE_FILENAMES[0],
}
- DEFAULT_DUMMY_LOG_FILE_PATHS = [
- os.path.join(
- DEFAULT_DUMMY_LOG_FILE_DIRECTORY,
- DEFAULT_DUMMY_LOG_FILE_FILENAMES[0],
- ),
- os.path.join(
- DEFAULT_DUMMY_LOG_FILE_DIRECTORY,
- DEFAULT_DUMMY_LOG_FILE_FILENAMES[1],
- ),
+ DEFAULT_LOG_FILE_PATHS = [
+ os.path.join(DEFAULT_LOG_FILE_DIRECTORY, DEFAULT_LOG_FILE_FILENAMES[0]),
+ os.path.join(DEFAULT_LOG_FILE_DIRECTORY, DEFAULT_LOG_FILE_FILENAMES[1]),
]
@staticmethod
@@ -177,20 +168,18 @@
"""Return the data required to register a device.
Use the values passed as keyword arguments or default to the ones
- from `Dummy.DEFAULT_DUMMY_DEVICE_REGISTER_VALUES`.
+ from `Dummy.DEFAULT_DEVICE_REGISTER_VALUES`.
"""
- return Dummy._update_copy(
- Dummy.DEFAULT_DUMMY_DEVICE_REGISTER_VALUES, kwargs
- )
+ return Dummy._update_copy(Dummy.DEFAULT_DEVICE_REGISTER_VALUES, kwargs)
@staticmethod
def heartbeat_data(**kwargs):
"""Return the data required to create a heartbeat.
Use the values passed as keyword arguments or default to the ones
- from `Dummy.DEFAULT_DUMMY_HEARTBEAT_VALUES`.
+ from `Dummy.DEFAULT_HEARTBEAT_VALUES`.
"""
- return Dummy._update_copy(Dummy.DEFAULT_DUMMY_HEARTBEAT_VALUES, kwargs)
+ return Dummy._update_copy(Dummy.DEFAULT_HEARTBEAT_VALUES, kwargs)
@staticmethod
def alternative_heartbeat_data(**kwargs):
@@ -206,7 +195,7 @@
"""Return the data required to create a crashreport.
Use the values passed as keyword arguments or default to the ones
- from `Dummy.DEFAULT_DUMMY_CRASHREPORTS_VALUES`.
+ from `Dummy.DEFAULT_CRASHREPORTS_VALUES`.
Args:
report_type: A valid value from
@@ -214,9 +203,7 @@
define the boot reason if not explicitly defined in the
keyword arguments already.
"""
- data = Dummy._update_copy(
- Dummy.DEFAULT_DUMMY_CRASHREPORT_VALUES, kwargs
- )
+ data = Dummy._update_copy(Dummy.DEFAULT_CRASHREPORT_VALUES, kwargs)
if report_type and "boot_reason" not in kwargs:
if report_type not in Dummy.CRASH_TYPE_TO_BOOT_REASON_MAP:
raise InvalidCrashTypeError(report_type)
@@ -235,7 +222,7 @@
return Dummy._update_copy(Dummy.ALTERNATIVE_CRASHREPORT_VALUES, kwargs)
@staticmethod
- def create_dummy_user(**kwargs):
+ def create_user(**kwargs):
"""Create a dummy user instance.
The dummy instance is created and saved to the database.
@@ -246,14 +233,12 @@
Returns: The created user instance.
"""
- entity = User(
- **Dummy._update_copy(Dummy.DEFAULT_DUMMY_USER_VALUES, kwargs)
- )
+ entity = User(**Dummy._update_copy(Dummy.DEFAULT_USER_VALUES, kwargs))
entity.save()
return entity
@staticmethod
- def create_dummy_device(user, **kwargs):
+ def create_device(user, **kwargs):
"""Create a dummy device instance.
The dummy instance is created and saved to the database.
@@ -266,14 +251,13 @@
"""
entity = Device(
- user=user,
- **Dummy._update_copy(Dummy.DEFAULT_DUMMY_DEVICE_VALUES, kwargs)
+ user=user, **Dummy._update_copy(Dummy.DEFAULT_DEVICE_VALUES, kwargs)
)
entity.save()
return entity
@staticmethod
- def create_dummy_report(report_type, device, **kwargs):
+ def create_report(report_type, device, **kwargs):
"""Create a dummy report instance of the given report class type.
The dummy instance is created and saved to the database.
@@ -292,16 +276,12 @@
if report_type == HeartBeat:
entity = HeartBeat(
device=device,
- **Dummy._update_copy(
- Dummy.DEFAULT_DUMMY_HEARTBEAT_VALUES, kwargs
- )
+ **Dummy._update_copy(Dummy.DEFAULT_HEARTBEAT_VALUES, kwargs)
)
elif report_type == Crashreport:
entity = Crashreport(
device=device,
- **Dummy._update_copy(
- Dummy.DEFAULT_DUMMY_CRASHREPORT_VALUES, kwargs
- )
+ **Dummy._update_copy(Dummy.DEFAULT_CRASHREPORT_VALUES, kwargs)
)
else:
raise RuntimeError(
@@ -313,7 +293,7 @@
return entity
@staticmethod
- def create_dummy_log_file(crashreport, **kwargs):
+ def create_log_file(crashreport, **kwargs):
"""Create a dummy log file instance.
The dummy instance is created and saved to the database.
@@ -327,14 +307,14 @@
"""
entity = LogFile(
crashreport=crashreport,
- **Dummy._update_copy(Dummy.DEFAULT_DUMMY_LOG_FILE_VALUES, kwargs)
+ **Dummy._update_copy(Dummy.DEFAULT_LOG_FILE_VALUES, kwargs)
)
entity.save()
return entity
@staticmethod
- def create_dummy_log_file_with_actual_file(crashreport, **kwargs):
+ def create_log_file_with_actual_file(crashreport, **kwargs):
"""Create a dummy log file instance along with a file.
The dummy instance is created and saved to the database. The log file
@@ -347,7 +327,7 @@
Returns: The created log file instance and the path to the copied file.
"""
- logfile = Dummy.create_dummy_log_file(crashreport, **kwargs)
+ logfile = Dummy.create_log_file(crashreport, **kwargs)
logfile_filename = os.path.basename(logfile.logfile.path)
test_logfile_path = os.path.join(
settings.MEDIA_ROOT,
@@ -358,9 +338,7 @@
os.makedirs(os.path.dirname(test_logfile_path))
shutil.copy(
- os.path.join(
- Dummy.DEFAULT_DUMMY_LOG_FILE_DIRECTORY, logfile_filename
- ),
+ os.path.join(Dummy.DEFAULT_LOG_FILE_DIRECTORY, logfile_filename),
test_logfile_path,
)
return logfile, test_logfile_path