aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/models.py4
-rw-r--r--api/tests/base.py5
-rw-r--r--api/tests/test_documentation_links.py4
-rw-r--r--api/tests/test_members.py3
-rw-r--r--api/tests/test_off_topic_channel_names.py4
-rw-r--r--api/tests/test_snake_names.py3
-rw-r--r--api/urls.py27
-rw-r--r--api/views.py2
-rw-r--r--api/viewsets.py9
9 files changed, 39 insertions, 22 deletions
diff --git a/api/models.py b/api/models.py
index d3986ba5..5d7dfc35 100644
--- a/api/models.py
+++ b/api/models.py
@@ -28,7 +28,7 @@ class SnakeName(models.Model):
class Role(models.Model):
"""A role on our Discord server."""
- id = models.BigIntegerField(
+ id = models.BigIntegerField( # noqa
primary_key=True,
validators=(
MinValueValidator(
@@ -69,7 +69,7 @@ class Role(models.Model):
class Member(models.Model):
"""A member of our Discord server."""
- id = models.BigIntegerField(
+ id = models.BigIntegerField( # noqa
primary_key=True,
validators=(
MinValueValidator(
diff --git a/api/tests/base.py b/api/tests/base.py
index 06f7233c..395dc55c 100644
--- a/api/tests/base.py
+++ b/api/tests/base.py
@@ -1,12 +1,11 @@
from django.contrib.auth.models import User
-from rest_framework.authtoken.models import Token
-from rest_framework.test import APIClient, APITestCase
+from rest_framework.test import APITestCase
test_user, _created = User.objects.get_or_create(
username='test',
- password='testpass',
+ password='testpass', # flake8: noqa - S106
is_superuser=True,
is_staff=True
)
diff --git a/api/tests/test_documentation_links.py b/api/tests/test_documentation_links.py
index e560a2fd..f6c78391 100644
--- a/api/tests/test_documentation_links.py
+++ b/api/tests/test_documentation_links.py
@@ -57,7 +57,7 @@ class EmptyDatabaseDocumentationLinkAPITests(APISubdomainTestCase):
class DetailLookupDocumentationLinkAPITests(APISubdomainTestCase):
@classmethod
- def setUpTestData(cls):
+ def setUpTestData(cls): # noqa
cls.doc_link = DocumentationLink.objects.create(
package='testpackage',
base_url='https://example.com',
@@ -141,7 +141,7 @@ class DocumentationLinkCreationTests(APISubdomainTestCase):
class DocumentationLinkDeletionTests(APISubdomainTestCase):
@classmethod
- def setUpTestData(cls):
+ def setUpTestData(cls): # noqa
cls.doc_link = DocumentationLink.objects.create(
package='example',
base_url='https://example.com',
diff --git a/api/tests/test_members.py b/api/tests/test_members.py
index 60ad8460..47466b62 100644
--- a/api/tests/test_members.py
+++ b/api/tests/test_members.py
@@ -1,4 +1,3 @@
-from django.test import TestCase
from django_hosts.resolvers import reverse
from .base import APISubdomainTestCase
@@ -37,7 +36,7 @@ class UnauthedDocumentationLinkAPITests(APISubdomainTestCase):
class CreationTests(APISubdomainTestCase):
@classmethod
- def setUpTestData(cls):
+ def setUpTestData(cls): # noqa
cls.role = Role.objects.create(
id=5,
name="Test role pls ignore",
diff --git a/api/tests/test_off_topic_channel_names.py b/api/tests/test_off_topic_channel_names.py
index 1b222dca..60af1f62 100644
--- a/api/tests/test_off_topic_channel_names.py
+++ b/api/tests/test_off_topic_channel_names.py
@@ -58,7 +58,7 @@ class EmptyDatabaseTests(APISubdomainTestCase):
class ListTests(APISubdomainTestCase):
@classmethod
- def setUpTestData(cls):
+ def setUpTestData(cls): # noqa
cls.test_name = OffTopicChannelName.objects.create(name='lemons-lemonade-stand')
cls.test_name_2 = OffTopicChannelName.objects.create(name='bbq-with-bisk')
@@ -125,7 +125,7 @@ class CreationTests(APISubdomainTestCase):
class DeletionTests(APISubdomainTestCase):
@classmethod
- def setUpTestData(cls):
+ def setUpTestData(cls): # noqa
cls.test_name = OffTopicChannelName.objects.create(name='lemons-lemonade-stand')
cls.test_name_2 = OffTopicChannelName.objects.create(name='bbq-with-bisk')
diff --git a/api/tests/test_snake_names.py b/api/tests/test_snake_names.py
index 6a669557..41dfae63 100644
--- a/api/tests/test_snake_names.py
+++ b/api/tests/test_snake_names.py
@@ -4,7 +4,6 @@ from .base import APISubdomainTestCase
from ..models import SnakeName
-
class StatusTests(APISubdomainTestCase):
def setUp(self):
super().setUp()
@@ -41,7 +40,7 @@ class EmptyDatabaseSnakeNameTests(APISubdomainTestCase):
class SnakeNameListTests(APISubdomainTestCase):
@classmethod
- def setUpTestData(cls):
+ def setUpTestData(cls): # noqa
cls.snake_python = SnakeName.objects.create(name='Python', scientific='Totally.')
def test_endpoint_returns_all_snakes_with_get_all_param(self):
diff --git a/api/urls.py b/api/urls.py
index 1e10cddb..f4ed641c 100644
--- a/api/urls.py
+++ b/api/urls.py
@@ -2,15 +2,32 @@ from django.urls import include, path
from rest_framework.routers import SimpleRouter
from .views import HealthcheckView
-from .viewsets import DocumentationLinkViewSet, MemberViewSet, OffTopicChannelNameViewSet, SnakeNameViewSet
+from .viewsets import (
+ DocumentationLinkViewSet, MemberViewSet,
+ OffTopicChannelNameViewSet, SnakeNameViewSet
+)
# http://www.django-rest-framework.org/api-guide/routers/#simplerouter
bot_router = SimpleRouter(trailing_slash=False)
-bot_router.register('documentation-links', DocumentationLinkViewSet)
-bot_router.register('off-topic-channel-names', OffTopicChannelNameViewSet, base_name='offtopicchannelname')
-bot_router.register('members', MemberViewSet)
-bot_router.register('snake-names', SnakeNameViewSet, base_name='snakename')
+bot_router.register(
+ 'documentation-links',
+ DocumentationLinkViewSet
+)
+bot_router.register(
+ 'off-topic-channel-names',
+ OffTopicChannelNameViewSet,
+ base_name='offtopicchannelname'
+)
+bot_router.register(
+ 'members',
+ MemberViewSet
+)
+bot_router.register(
+ 'snake-names',
+ SnakeNameViewSet,
+ base_name='snakename'
+)
app_name = 'api'
diff --git a/api/views.py b/api/views.py
index dbc04b56..c5582ec0 100644
--- a/api/views.py
+++ b/api/views.py
@@ -23,5 +23,5 @@ class HealthcheckView(APIView):
authentication_classes = ()
permission_classes = ()
- def get(self, request, format=None):
+ def get(self, request, format=None): # noqa
return Response({'status': 'ok'})
diff --git a/api/viewsets.py b/api/viewsets.py
index 677110a8..9eec3a03 100644
--- a/api/viewsets.py
+++ b/api/viewsets.py
@@ -1,6 +1,9 @@
from django.shortcuts import get_object_or_404
from rest_framework.exceptions import ParseError
-from rest_framework.mixins import CreateModelMixin, DestroyModelMixin, ListModelMixin, RetrieveModelMixin
+from rest_framework.mixins import (
+ CreateModelMixin, DestroyModelMixin,
+ ListModelMixin, RetrieveModelMixin
+)
from rest_framework.response import Response
from rest_framework.status import HTTP_201_CREATED
from rest_framework.viewsets import GenericViewSet, ModelViewSet, ViewSet
@@ -144,7 +147,7 @@ class OffTopicChannelNameViewSet(DestroyModelMixin, ViewSet):
'name': ["This query parameter is required."]
})
- def list(self, request):
+ def list(self, request): # noqa
if 'random_items' in request.query_params:
param = request.query_params['random_items']
try:
@@ -204,7 +207,7 @@ class SnakeNameViewSet(ViewSet):
def get_queryset(self):
return SnakeName.objects.all()
- def list(self, request):
+ def list(self, request): # noqa
if request.query_params.get('get_all'):
queryset = self.get_queryset()
serialized = self.serializer_class(queryset, many=True)