Skip to content

Commit

Permalink
chore(access): Add trace output for tests that pass locally and fail …
Browse files Browse the repository at this point in the history
…on GH actions

ref: #469 #471
  • Loading branch information
jon-nfc committed Jan 16, 2025
1 parent 9d776e1 commit e3b275c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/access/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions app/api/tests/abstract/api_permissions_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}')




Expand Down

0 comments on commit e3b275c

Please sign in to comment.