mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-16 20:49:00 -04:00
update test to reflect enum in servicepermission
This commit is contained in:
@@ -2,6 +2,7 @@ import pytest
|
||||
from flask import request
|
||||
from werkzeug.exceptions import Forbidden
|
||||
|
||||
from app.enums import ServicePermission
|
||||
from app.utils.user import user_has_permissions
|
||||
|
||||
|
||||
@@ -10,17 +11,17 @@ from app.utils.user import user_has_permissions
|
||||
[
|
||||
[
|
||||
# Route has one of the permissions which the user has
|
||||
"manage_service"
|
||||
ServicePermission.MANAGE_SERVICE
|
||||
],
|
||||
[
|
||||
# Route has more than one of the permissions which the user has
|
||||
"manage_templates",
|
||||
"manage_service",
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
ServicePermission.MANAGE_SERVICE,
|
||||
],
|
||||
[
|
||||
# Route has one of the permissions which the user has, and one they do not
|
||||
"manage_service",
|
||||
"send_messages",
|
||||
ServicePermission.MANAGE_SERVICE,
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
],
|
||||
[
|
||||
# Route has no specific permissions required
|
||||
@@ -52,8 +53,8 @@ def test_permissions(
|
||||
"permissions",
|
||||
[
|
||||
[
|
||||
# Route has a permission which the user doesn’t have
|
||||
"send_messages"
|
||||
# Route has a permission which the user doesn't have
|
||||
ServicePermission.SEND_MESSAGES
|
||||
],
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from app.enums import ServicePermission
|
||||
from app.utils.user_permissions import (
|
||||
translate_permissions_from_db_to_ui,
|
||||
translate_permissions_from_ui_to_db,
|
||||
@@ -11,7 +12,7 @@ from app.utils.user_permissions import (
|
||||
[
|
||||
(
|
||||
["manage_templates"],
|
||||
{"manage_templates"},
|
||||
{ServicePermission.MANAGE_TEMPLATES},
|
||||
),
|
||||
(
|
||||
[
|
||||
@@ -20,7 +21,11 @@ from app.utils.user_permissions import (
|
||||
"manage_templates",
|
||||
"some_unknown_permission",
|
||||
],
|
||||
{"send_messages", "manage_templates", "some_unknown_permission"},
|
||||
{
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
"some_unknown_permission",
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -33,7 +38,11 @@ def test_translate_permissions_from_db_to_ui(
|
||||
|
||||
|
||||
def test_translate_permissions_from_ui_to_db():
|
||||
ui_permissions = ["send_messages", "manage_templates", "some_unknown_permission"]
|
||||
ui_permissions = [
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
"some_unknown_permission",
|
||||
]
|
||||
db_permissions = translate_permissions_from_ui_to_db(ui_permissions)
|
||||
|
||||
assert db_permissions == {
|
||||
|
||||
Reference in New Issue
Block a user