From db6f565dcafbd0c8c25c9a24edc49f7c28c9ffdd Mon Sep 17 00:00:00 2001 From: Jim Ladd Date: Wed, 24 Mar 2021 12:00:46 -0700 Subject: [PATCH] black formatting --- awx/api/views/__init__.py | 4 +-- awx/main/models/events.py | 35 +++++++++----------- awx/main/models/unified_jobs.py | 2 +- awx/main/tasks.py | 2 +- awx/main/tests/functional/api/test_events.py | 6 ++-- 5 files changed, 20 insertions(+), 29 deletions(-) diff --git a/awx/api/views/__init__.py b/awx/api/views/__init__.py index 9ee3e8dc31..8a61c10ef6 100644 --- a/awx/api/views/__init__.py +++ b/awx/api/views/__init__.py @@ -3792,9 +3792,7 @@ class JobEventChildrenList(NoTruncateMixin, SubListAPIView): def get_queryset(self): parent_event = self.get_parent_object() self.check_parent_access(parent_event) - return parent_event.job.get_event_queryset().filter( - parent_uuid=parent_event.uuid - ) + return parent_event.job.get_event_queryset().filter(parent_uuid=parent_event.uuid) class BaseJobEventsList(NoTruncateMixin, SubListAPIView): diff --git a/awx/main/models/events.py b/awx/main/models/events.py index ef83a1b6c7..b4afb080e3 100644 --- a/awx/main/models/events.py +++ b/awx/main/models/events.py @@ -501,10 +501,7 @@ class JobEvent(BasePlaybookEvent): default='', editable=False, ) - job_created = models.DateTimeField( - null=True, - editable=False - ) + job_created = models.DateTimeField(null=True, editable=False) def get_absolute_url(self, request=None): return reverse('api:job_event_detail', kwargs={'pk': self.pk}, request=request) @@ -587,6 +584,8 @@ class JobEvent(BasePlaybookEvent): class UnpartitionedJobEvent(JobEvent): class Meta: proxy = True + + UnpartitionedJobEvent._meta.db_table = '_unpartitioned_' + JobEvent._meta.db_table # noqa @@ -613,10 +612,7 @@ class ProjectUpdateEvent(BasePlaybookEvent): on_delete=models.CASCADE, editable=False, ) - job_created = models.DateTimeField( - null=True, - editable=False - ) + job_created = models.DateTimeField(null=True, editable=False) @property def host_name(self): @@ -626,6 +622,8 @@ class ProjectUpdateEvent(BasePlaybookEvent): class UnpartitionedProjectUpdateEvent(ProjectUpdateEvent): class Meta: proxy = True + + UnpartitionedProjectUpdateEvent._meta.db_table = '_unpartitioned_' + ProjectUpdateEvent._meta.db_table # noqa @@ -796,10 +794,7 @@ class AdHocCommandEvent(BaseCommandEvent): default='', editable=False, ) - job_created = models.DateTimeField( - null=True, - editable=False - ) + job_created = models.DateTimeField(null=True, editable=False) def get_absolute_url(self, request=None): return reverse('api:ad_hoc_command_event_detail', kwargs={'pk': self.pk}, request=request) @@ -818,6 +813,8 @@ class AdHocCommandEvent(BaseCommandEvent): class UnpartitionedAdHocCommandEvent(AdHocCommandEvent): class Meta: proxy = True + + UnpartitionedAdHocCommandEvent._meta.db_table = '_unpartitioned_' + AdHocCommandEvent._meta.db_table # noqa @@ -843,10 +840,7 @@ class InventoryUpdateEvent(BaseCommandEvent): on_delete=models.CASCADE, editable=False, ) - job_created = models.DateTimeField( - null=True, - editable=False - ) + job_created = models.DateTimeField(null=True, editable=False) @property def event(self): @@ -864,6 +858,8 @@ class InventoryUpdateEvent(BaseCommandEvent): class UnpartitionedInventoryUpdateEvent(InventoryUpdateEvent): class Meta: proxy = True + + UnpartitionedInventoryUpdateEvent._meta.db_table = '_unpartitioned_' + InventoryUpdateEvent._meta.db_table # noqa @@ -889,10 +885,7 @@ class SystemJobEvent(BaseCommandEvent): on_delete=models.CASCADE, editable=False, ) - job_created = models.DateTimeField( - null=True, - editable=False - ) + job_created = models.DateTimeField(null=True, editable=False) @property def event(self): @@ -910,4 +903,6 @@ class SystemJobEvent(BaseCommandEvent): class UnpartitionedSystemJobEvent(SystemJobEvent): class Meta: proxy = True + + UnpartitionedSystemJobEvent._meta.db_table = '_unpartitioned_' + SystemJobEvent._meta.db_table # noqa diff --git a/awx/main/models/unified_jobs.py b/awx/main/models/unified_jobs.py index ec303710ea..507f662886 100644 --- a/awx/main/models/unified_jobs.py +++ b/awx/main/models/unified_jobs.py @@ -49,7 +49,7 @@ from awx.main.utils import ( getattr_dne, polymorphic, schedule_task_manager, - get_event_partition_epoch + get_event_partition_epoch, ) from awx.main.constants import ACTIVE_STATES, CAN_CANCEL from awx.main.redact import UriCleaner, REPLACE_STR diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 98635f19bb..f2bbbe78de 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -80,7 +80,7 @@ from awx.main.models import ( InventoryUpdateEvent, AdHocCommandEvent, SystemJobEvent, - build_safe_env + build_safe_env, ) from awx.main.constants import ACTIVE_STATES from awx.main.exceptions import AwxTaskError, PostRunError diff --git a/awx/main/tests/functional/api/test_events.py b/awx/main/tests/functional/api/test_events.py index 37fdbae878..4579d6eab3 100644 --- a/awx/main/tests/functional/api/test_events.py +++ b/awx/main/tests/functional/api/test_events.py @@ -10,8 +10,7 @@ from awx.main.models import Job # created before job event tables were partitioned. # This test can safely behave as if all job events were created # after the migration, in which case Job.created_or_epoch == Job.created -@mock.patch('awx.main.models.Job.created_or_epoch', - Job.created) +@mock.patch('awx.main.models.Job.created_or_epoch', Job.created) @pytest.mark.django_db @pytest.mark.parametrize( 'truncate, expected', @@ -38,8 +37,7 @@ def test_job_events_sublist_truncation(get, organization_factory, job_template_f # created before job event tables were partitioned. # This test can safely behave as if all job events were created # after the migration, in which case Job.created_or_epoch == Job.created -@mock.patch('awx.main.models.ad_hoc_commands.AdHocCommand.created_or_epoch', - Job.created) +@mock.patch('awx.main.models.ad_hoc_commands.AdHocCommand.created_or_epoch', Job.created) @pytest.mark.django_db @pytest.mark.parametrize( 'truncate, expected',