Fix count of users on request to go live

We were counting users who had the `manage_settings` permission. This
is the old name for it, therefore there would never be any users with
this permission, so the tick would never go green.

The new name for the permission is `manage_service`. This commit fixes
the error, and adds an extra safeguard against something like this
happening again.
This commit is contained in:
Chris Hill-Scott
2018-03-09 10:47:23 +00:00
parent 5d4fc23128
commit 240f11e715
3 changed files with 5 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ from notifications_python_client.errors import HTTPError
from app.notify_client import NotifyAdminAPIClient
from app.notify_client.models import (
User,
roles,
translate_permissions_from_admin_roles_to_db,
)
@@ -134,6 +135,8 @@ class UserApiClient(NotifyAdminAPIClient):
return [User(data) for data in resp['data']]
def get_count_of_users_with_permission(self, service_id, permission):
if permission not in roles.keys():
raise TypeError('{} is not a valid permission'.format(permission))
return len([
user for user in self.get_users_for_service(service_id)
if user.has_permission_for_service(service_id, permission)