Skip to content

Commit

Permalink
Update unit test and typing
Browse files Browse the repository at this point in the history
  • Loading branch information
novakzaballa committed Jul 15, 2024
1 parent 2a9bcc4 commit 3fa14a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api/organisations/permissions/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from rest_framework.exceptions import PermissionDenied, ValidationError
from rest_framework.permissions import BasePermission, IsAuthenticated
from rest_framework.request import Request
from rest_framework.viewsets import GenericViewSet

from organisations.models import Organisation
from users.models import FFAdminUser
Expand Down Expand Up @@ -189,7 +190,7 @@ def has_object_permission(self, request, view, obj):


class GithubIsAdminOrganisation(NestedIsOrganisationAdminPermission):
def has_permission(self, request, view) -> bool:
def has_permission(self, request: Request, view: GenericViewSet) -> bool:
organisation_pk = view.kwargs.get("organisation_pk")

with suppress(ObjectDoesNotExist):
Expand All @@ -202,7 +203,7 @@ def has_permission(self, request, view) -> bool:
else:
return request.user.is_master_api_key_user

def has_object_permission(self, request, view, obj) -> bool:
def has_object_permission(self, request: Request, view: GenericViewSet) -> bool:
organisation_pk = view.kwargs.get("organisation_pk")
if isinstance(request.user, FFAdminUser):
return request.user.is_organisation_admin(
Expand Down
4 changes: 4 additions & 0 deletions api/tests/unit/integrations/github/test_unit_github_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def test_get_github_configuration(
def test_non_admin_user_get_github_configuration(
staff_client: APIClient,
organisation: Organisation,
github_configuration: GithubConfiguration,
) -> None:
# Given
url = reverse(
Expand All @@ -66,7 +67,10 @@ def test_non_admin_user_get_github_configuration(
# When
response = staff_client.get(url)
# Then
github_configuration_res = response.json()["results"][0]
assert response.status_code == status.HTTP_200_OK
assert github_configuration_res["installation_id"] == "1234567"
assert github_configuration_res["id"] == 1


def test_create_github_configuration(
Expand Down

0 comments on commit 3fa14a9

Please sign in to comment.