-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tags/view): Add api to get tag by uuid (#3229)
- Loading branch information
1 parent
91cef60
commit 6500451
Showing
4 changed files
with
90 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from typing import Callable | ||
|
||
import pytest | ||
from django.urls import reverse | ||
from pytest_lazyfixture import lazy_fixture | ||
from rest_framework import status | ||
from rest_framework.test import APIClient | ||
|
||
from projects.models import Project | ||
from projects.permissions import VIEW_PROJECT | ||
from projects.tags.models import Tag | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"client", | ||
[(lazy_fixture("admin_master_api_key_client")), (lazy_fixture("admin_client"))], | ||
) | ||
def test_get_tag_by_uuid(client: APIClient, project: Project, tag: Tag): | ||
url = reverse("api-v1:projects:tags-get-by-uuid", args=[project.id, str(tag.uuid)]) | ||
|
||
# When | ||
response = client.get(url) | ||
|
||
# Then | ||
assert response.status_code == status.HTTP_200_OK | ||
assert response.json()["uuid"] == str(tag.uuid) | ||
|
||
|
||
def test_get_tag_by_uuid__returns_403_for_user_without_permission( | ||
staff_client: APIClient, | ||
organisation_one_project_two: Project, | ||
project: Project, | ||
tag: Tag, | ||
with_project_permissions: Callable[[list[str], int], None], | ||
): | ||
# Given | ||
# user with view permission for a different project | ||
with_project_permissions([VIEW_PROJECT], organisation_one_project_two.id) | ||
|
||
url = reverse( | ||
"api-v1:projects:tags-get-by-uuid", | ||
args=[project.id, str(tag.uuid)], | ||
) | ||
|
||
# When | ||
response = staff_client.get(url) | ||
|
||
# Then | ||
assert response.status_code == status.HTTP_403_FORBIDDEN | ||
|
||
|
||
def test_get_tag_by__uuid_returns_200_for_user_with_view_project_permission( | ||
staff_client: APIClient, | ||
project: Project, | ||
tag: Tag, | ||
with_project_permissions: Callable[[list[str], int], None], | ||
): | ||
# Given | ||
with_project_permissions([VIEW_PROJECT]) | ||
|
||
url = reverse( | ||
"api-v1:projects:tags-get-by-uuid", | ||
args=[project.id, str(tag.uuid)], | ||
) | ||
|
||
# When | ||
response = staff_client.get(url) | ||
|
||
# Then | ||
assert response.status_code == status.HTTP_200_OK | ||
assert response.json()["uuid"] == str(tag.uuid) |
6500451
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-preview – ./frontend
flagsmith-frontend-production-native.vercel.app
flagsmith-frontend-preview-git-main-flagsmith.vercel.app
flagsmith-frontend-preview-flagsmith.vercel.app
6500451
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs-flagsmith.vercel.app
docs.bullet-train.io
docs.flagsmith.com
docs-git-main-flagsmith.vercel.app
6500451
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-staging – ./frontend
flagsmith-frontend-staging-flagsmith.vercel.app
flagsmith-frontend-staging-git-main-flagsmith.vercel.app
staging.flagsmith.com
flagsmith-staging-frontend.vercel.app