diff options
Diffstat (limited to 'pydis_site/apps')
-rw-r--r-- | pydis_site/apps/api/models/bot/metricity.py | 10 | ||||
-rw-r--r-- | pydis_site/apps/api/tests/test_users.py | 10 | ||||
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/user.py | 6 |
3 files changed, 13 insertions, 13 deletions
diff --git a/pydis_site/apps/api/models/bot/metricity.py b/pydis_site/apps/api/models/bot/metricity.py index 5daa5c66..33fb7ad7 100644 --- a/pydis_site/apps/api/models/bot/metricity.py +++ b/pydis_site/apps/api/models/bot/metricity.py @@ -10,7 +10,7 @@ EXCLUDE_CHANNELS = [ ] -class NotFound(Exception): +class NotFoundError(Exception): """Raised when an entity cannot be found.""" pass @@ -37,7 +37,7 @@ class Metricity: values = self.cursor.fetchone() if not values: - raise NotFound() + raise NotFoundError() return dict(zip(columns, values)) @@ -58,7 +58,7 @@ class Metricity: values = self.cursor.fetchone() if not values: - raise NotFound() + raise NotFoundError() return values[0] @@ -88,7 +88,7 @@ class Metricity: values = self.cursor.fetchone() if not values: - raise NotFound() + raise NotFoundError() return values[0] @@ -127,6 +127,6 @@ class Metricity: values = self.cursor.fetchall() if not values: - raise NotFound() + raise NotFoundError() return values diff --git a/pydis_site/apps/api/tests/test_users.py b/pydis_site/apps/api/tests/test_users.py index c43b916a..ed5b4ce3 100644 --- a/pydis_site/apps/api/tests/test_users.py +++ b/pydis_site/apps/api/tests/test_users.py @@ -5,7 +5,7 @@ from django_hosts.resolvers import reverse from .base import APISubdomainTestCase from ..models import Role, User -from ..models.bot.metricity import NotFound +from ..models.bot.metricity import NotFoundError class UnauthedUserAPITests(APISubdomainTestCase): @@ -501,7 +501,7 @@ class UserMetricityTests(APISubdomainTestCase): self.metricity = patcher.start() self.addCleanup(patcher.stop) self.metricity = self.metricity.return_value.__enter__.return_value - self.metricity.user.side_effect = NotFound() - self.metricity.total_messages.side_effect = NotFound() - self.metricity.total_message_blocks.side_effect = NotFound() - self.metricity.top_channel_activity.side_effect = NotFound() + self.metricity.user.side_effect = NotFoundError() + self.metricity.total_messages.side_effect = NotFoundError() + self.metricity.total_message_blocks.side_effect = NotFoundError() + self.metricity.top_channel_activity.side_effect = NotFoundError() diff --git a/pydis_site/apps/api/viewsets/bot/user.py b/pydis_site/apps/api/viewsets/bot/user.py index 25722f5a..0356e193 100644 --- a/pydis_site/apps/api/viewsets/bot/user.py +++ b/pydis_site/apps/api/viewsets/bot/user.py @@ -11,7 +11,7 @@ from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import ModelViewSet from pydis_site.apps.api.models.bot.infraction import Infraction -from pydis_site.apps.api.models.bot.metricity import Metricity, NotFound +from pydis_site.apps.api.models.bot.metricity import Metricity, NotFoundError from pydis_site.apps.api.models.bot.user import User from pydis_site.apps.api.serializers import UserSerializer @@ -275,7 +275,7 @@ class UserViewSet(ModelViewSet): data["voice_banned"] = voice_banned data["activity_blocks"] = metricity.total_message_blocks(user.id) return Response(data, status=status.HTTP_200_OK) - except NotFound: + except NotFoundError: return Response(dict(detail="User not found in metricity"), status=status.HTTP_404_NOT_FOUND) @@ -290,6 +290,6 @@ class UserViewSet(ModelViewSet): data["total_messages"] = metricity.total_messages(user.id) data["top_channel_activity"] = metricity.top_channel_activity(user.id) return Response(data, status=status.HTTP_200_OK) - except NotFound: + except NotFoundError: return Response(dict(detail="User not found in metricity"), status=status.HTTP_404_NOT_FOUND) |