From e7f7800e9e2157f7fef4b28d488c609d8b54c374 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 17 Jan 2025 02:27:12 +0930 Subject: [PATCH] chore(access): Add trace output for tests that pass locally and fail on GH actions ref: #469 #471 --- app/access/models.py | 9 +++++++++ app/api/tests/abstract/api_permissions_viewset.py | 13 +++++++++++++ .../config_groups/test_config_groups_viewset.py | 4 ++++ 3 files changed, 26 insertions(+) diff --git a/app/access/models.py b/app/access/models.py index 180352c80..b93c7c798 100644 --- a/app/access/models.py +++ b/app/access/models.py @@ -179,18 +179,26 @@ def get_queryset(self): user_organizations: list(str()) = [] + print(f'current app settings {self._app_settings}') + if request: if not self._app_settings: + print(f'no cached app settings') + from settings.models.app_settings import AppSettings self._app_settings = AppSettings.objects.prefetch_related('global_organization').get( owner_organization = None ) + print(f'app settings cached') + if self._app_settings.global_organization: + print(f'adding global organization') + user_organizations += [ self._app_settings.global_organization.id ] # user = request.user._wrapped if hasattr(request.user,'_wrapped') else request.user @@ -212,6 +220,7 @@ def get_queryset(self): user_organizations += [ team_user.team.organization.id ] + print(f'user orgs: {user_organizations}') # if len(user_organizations) > 0 and not user.is_superuser and self.model.is_global is not None: if len(user_organizations) > 0 and not user.is_superuser: diff --git a/app/api/tests/abstract/api_permissions_viewset.py b/app/api/tests/abstract/api_permissions_viewset.py index 4d5794ec7..419cb5d44 100644 --- a/app/api/tests/abstract/api_permissions_viewset.py +++ b/app/api/tests/abstract/api_permissions_viewset.py @@ -157,17 +157,30 @@ def test_returned_data_from_user_and_global_organizations_only(self): self.global_organization.id ] + print(f'[TRACE] TEST self.global_organization.id: {self.global_organization.id}') + + print(f'[TRACE] TEST self.global_org_item: {self.global_org_item.id}') assert getattr(self.global_organization, 'id', False) # fail if no global org set + + print(f'[TRACE] TEST one passed') + assert getattr(self.global_org_item, 'id', False) # fail if no global item set + print(f'[TRACE] TEST two passed') client.force_login(self.view_user) response = client.get(url) + + print(f'[TRACE] TEST response.data["results"] {response.data["results"]}') + + assert len(response.data['results']) >= 2 # fail if only one item extist. + print(f'[TRACE] TEST three passed') + for row in response.data['results']: if row['organization']['id'] not in viewable_organizations: diff --git a/app/config_management/tests/functional/config_groups/test_config_groups_viewset.py b/app/config_management/tests/functional/config_groups/test_config_groups_viewset.py index e1894b52b..f07111d2a 100644 --- a/app/config_management/tests/functional/config_groups/test_config_groups_viewset.py +++ b/app/config_management/tests/functional/config_groups/test_config_groups_viewset.py @@ -73,6 +73,10 @@ def setUpTestData(self): app_settings.save() + print(f'[TRACE] global org: {self.global_organization.id}') + + print(f'[TRACE] app_settings global org: {app_settings.global_organization}') +